Documentation / API

API examples

#Copy, paste, run

The examples below use the default port and a key that looks like mbx_.... In Settings → API the same examples are shown with your key and port already filled in, with a Copy button. Turn the API on first.

#Python

One file (mobyx_client.py), standard library only. Download it from the API reference (http://127.0.0.1:50326/mobyx_client.py) and put it next to your script.

from mobyx_client import MobyxClient      # download it from the docs page

mobyx = MobyxClient(key="mbx_YOUR_KEY", port=50326)
browser = mobyx.create_browser(engine="chrome", proxy="", start=True)
mobyx.open(browser["id"], "https://example.com")
print(mobyx.js(browser["id"], "return document.title"))

for phone in mobyx.phones():
    mobyx.key(phone["serial"], "home")

#curl

Works from any shell. On Windows PowerShell use curl.exe (plain curl is an alias of something else there).

curl -H "X-API-Key: mbx_YOUR_KEY" http://127.0.0.1:50326/api/v1/browsers

curl -X POST -H "X-API-Key: mbx_YOUR_KEY" -H "Content-Type: application/json" -d "{\"engine\":\"chrome\",\"start\":true}" http://127.0.0.1:50326/api/v1/browsers

#Playwright

Start a Chrome profile with debug: true; the answer carries a debug_url. Puppeteer and Selenium connect to it the same way.

started = mobyx.start_browser(browser_id, debug=True)     # a Chrome profile opens a debugging port

from playwright.sync_api import sync_playwright
with sync_playwright() as p:
    chrome = p.chromium.connect_over_cdp(started["debug_url"])
    page = chrome.contexts[0].pages[0]
    page.goto("https://example.com")

#Node.js

Plain fetch (Node 18 or newer), no packages.

const API = "http://127.0.0.1:50326/api/v1", KEY = "mbx_YOUR_KEY";
const call = (method, path, body) => fetch(API + path, {method,
  headers: {"X-API-Key": KEY, "Content-Type": "application/json"}, body: body && JSON.stringify(body)})
  .then(r => r.json()).then(r => { if (!r.ok) throw r.error; return r.data; });

const phones = await call("GET", "/phones");
await call("POST", `/phones/${phones[0].serial}/key`, {key: "home"});