Morpho Browser

Automatisierungs-API

Starten Sie Profile von Morpho Browser aus Ihren eigenen Skripten und steuern Sie sie mit Playwright, Puppeteer oder Selenium.

Grundlagen

Die API läuft innerhalb der Desktop-App unter http://127.0.0.1:7777 und akzeptiert nur Verbindungen von Ihrem eigenen PC. Kopieren Sie den API-Schlüssel von der Seite „Automation API“ in der App und senden Sie ihn mit jeder Anfrage in einem dieser Header:

Authorization: Bearer YOUR_API_KEY
X-Morpho-Token: YOUR_API_KEY

Endpunkte

MethodePfadFunktion
GET/api/v1/profilesListet Profile auf: ID, Name, Engine und ob das Profil geöffnet ist.
POST/api/v1/profiles/{id}/startStartet ein Profil und gibt seinen ws_endpoint zurück. Wartet bis zu ?timeout=60 Sekunden, höchstens 180.
GET/api/v1/profiles/{id}Zeigt den Status an, bei geöffnetem Profil mit der Verbindungsadresse.
POST/api/v1/profiles/{id}/stopSchließt das Profil.

Profil mit curl starten

curl -X POST -H "Authorization: Bearer $MORPHO_KEY" \
  "http://127.0.0.1:7777/api/v1/profiles/PROFILE_ID/start?timeout=60"
# -> {"ws_endpoint": "ws://127.0.0.1:<port>/devtools/browser/...", ...}

Mit Playwright verbinden (Python)

import requests
from playwright.sync_api import sync_playwright

API = "http://127.0.0.1:7777/api/v1"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY"}

ws = requests.post(f"{API}/profiles/PROFILE_ID/start", headers=HEADERS,
                   params={"timeout": 60}).json()["ws_endpoint"]

with sync_playwright() as p:
    browser = p.chromium.connect_over_cdp(ws)
    context = browser.contexts[0]          # the profile's own context
    page = context.new_page()
    page.goto("https://example.com")
    print(page.title())

requests.post(f"{API}/profiles/PROFILE_ID/stop", headers=HEADERS)

Mit Puppeteer verbinden (Node.js)

import puppeteer from "puppeteer-core";

const API = "http://127.0.0.1:7777/api/v1";
const headers = { Authorization: "Bearer YOUR_API_KEY" };

const res = await fetch(`${API}/profiles/PROFILE_ID/start?timeout=60`, { method: "POST", headers });
const { ws_endpoint } = await res.json();

const browser = await puppeteer.connect({ browserWSEndpoint: ws_endpoint });
const page = await browser.newPage();
await page.goto("https://example.com");
console.log(await page.title());
browser.disconnect();   // leaves the profile running; stop it with POST .../stop

Hinweise

  • Nur Chromium-Profile geben einen DevTools-Endpunkt zurück.
  • Das Profil behält seinen eigenen Fingerprint und Proxy, während Ihr Skript es steuert.
  • Für Selenium verbinden Sie ChromeDriver mit Host und Port aus dem ws_endpoint (debuggerAddress).
  • Sie können den API-Schlüssel jederzeit in der App ersetzen; der alte Schlüssel funktioniert dann sofort nicht mehr.