This is a practical quick reference for Mercury REST API.
Generate access token from UI (Settings -> Keys) and use:
curl -H "Authorization: Bearer YOUR_TOKEN" https://YOUR_DOMAIN/api/v1/user- OpenAPI JSON:
https://YOUR_DOMAIN/api/v1/scheme - Alias (compatible):
https://YOUR_DOMAIN/api/v1/swagger.json - Swagger UI:
https://YOUR_DOMAIN/api/v1/docs - Swagger YAML in repo:
lib/units/api/swagger/api_v1.yaml - Swagger docs endpoints are publicly reachable (no Bearer token required to open docs pages).
GET /api/v1/devicesGET /api/v1/devices/{serial}PUT /api/v1/devices/{serial}
GET /api/v1/userGET /api/v1/user/devicesPOST /api/v1/user/devicesDELETE /api/v1/user/devices/{serial}POST /api/v1/user/devices/{serial}/remoteConnectDELETE /api/v1/user/devices/{serial}/remoteConnectPOST /api/v1/user/adbPublicKeys— register the Appium/ADB host public keyDELETE /api/v1/user/adbPublicKeys— remove a registered ADB key by fingerprint
GET /api/v1/autotestsDELETE /api/v1/autotestsGET /api/v1/autotests/{id}/addDevicesPOST /api/v1/autotests/useDevicePOST /api/v1/autotests/install/{serial}GET /api/v1/buildsDELETE /api/v1/builds/{id}DELETE /api/v1/builds
For complete parameters, topology rules, and examples, see
Automation API. Key rules: run and timeout
(60..10800) are required; provide either amount or serials; serials
takes precedence over filters.
List devices:
curl -H "Authorization: Bearer YOUR_TOKEN" https://YOUR_DOMAIN/api/v1/devicesUse one device:
curl -X POST -H "Authorization: Bearer YOUR_TOKEN" -H "Content-Type: application/json" \
-d '{"serial":"DEVICE_SERIAL"}' \
https://YOUR_DOMAIN/api/v1/user/devicesStart remote connect:
curl -X POST -H "Authorization: Bearer YOUR_TOKEN" \
https://YOUR_DOMAIN/api/v1/user/devices/DEVICE_SERIAL/remoteConnectReserve, use, and release one automation device:
CAPTURE="$(curl -sS -H "Authorization: Bearer YOUR_TOKEN" \
"https://YOUR_DOMAIN/api/v1/autotests?amount=1&timeout=600&run=api-smoke&type=android&need_amount=true")"
GROUP_ID="$(printf '%s' "$CAPTURE" | jq -r '.group.id')"
SERIAL="$(printf '%s' "$CAPTURE" | jq -r '.group.devices[0].serial')"
curl -sS -X POST -H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" -d "{\"serial\":\"$SERIAL\"}" \
https://YOUR_DOMAIN/api/v1/autotests/useDevice
# Always run this in cleanup/finally:
curl -sS -X DELETE -H "Authorization: Bearer YOUR_TOKEN" \
"https://YOUR_DOMAIN/api/v1/autotests?group=$GROUP_ID"The resulting Builds state Finished means the reservation closed (explicit
release or timeout), not that test assertions passed. Add
&result=passed|failed to the release call to show a PASSED/FAILED badge on
the Builds page.
UI'dan (Settings -> Keys) token üretin ve şu şekilde kullanın:
curl -H "Authorization: Bearer YOUR_TOKEN" https://YOUR_DOMAIN/api/v1/user- OpenAPI JSON:
https://YOUR_DOMAIN/api/v1/scheme - Alternatif (uyumlu alias):
https://YOUR_DOMAIN/api/v1/swagger.json - Swagger UI:
https://YOUR_DOMAIN/api/v1/docs - Repodaki Swagger YAML:
lib/units/api/swagger/api_v1.yaml - Swagger doküman endpointleri herkese açık (dokümanı açmak için Bearer token gerekmez).
GET /api/v1/devicesGET /api/v1/devices/{serial}PUT /api/v1/devices/{serial}
GET /api/v1/userGET /api/v1/user/devicesPOST /api/v1/user/devicesDELETE /api/v1/user/devices/{serial}POST /api/v1/user/devices/{serial}/remoteConnectDELETE /api/v1/user/devices/{serial}/remoteConnectPOST /api/v1/user/adbPublicKeys— Appium/ADB hostunun public key'ini kaydederDELETE /api/v1/user/adbPublicKeys— kayıtlı ADB key'i fingerprint ile siler
GET /api/v1/autotestsDELETE /api/v1/autotestsGET /api/v1/autotests/{id}/addDevicesPOST /api/v1/autotests/useDevicePOST /api/v1/autotests/install/{serial}GET /api/v1/buildsDELETE /api/v1/builds/{id}DELETE /api/v1/builds
Tüm parametreler, topoloji kuralları ve örnekler için
Automation API dokümanına bak. Temel kurallar: run ve
timeout (60..10800) zorunludur; amount veya serials verilir; serials
filtrelerden önceliklidir.
Cihazları listele:
curl -H "Authorization: Bearer YOUR_TOKEN" https://YOUR_DOMAIN/api/v1/devicesBir otomasyon cihazı ayır, kullan ve bırak:
CAPTURE="$(curl -sS -H "Authorization: Bearer YOUR_TOKEN" \
"https://YOUR_DOMAIN/api/v1/autotests?amount=1&timeout=600&run=api-smoke&type=android&need_amount=true")"
GROUP_ID="$(printf '%s' "$CAPTURE" | jq -r '.group.id')"
SERIAL="$(printf '%s' "$CAPTURE" | jq -r '.group.devices[0].serial')"
curl -sS -X POST -H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" -d "{\"serial\":\"$SERIAL\"}" \
https://YOUR_DOMAIN/api/v1/autotests/useDevice
# Bunu her zaman cleanup/finally içinde çalıştır:
curl -sS -X DELETE -H "Authorization: Bearer YOUR_TOKEN" \
"https://YOUR_DOMAIN/api/v1/autotests?group=$GROUP_ID"Builds kaydındaki Tamamlandı, rezervasyonun kapandığını (açık release veya
timeout) gösterir; test assertion'larının geçtiği anlamına gelmez. Builds
sayfasında PASSED/FAILED rozeti göstermek için release çağrısına
&result=passed|failed ekle.