SPHYNX
esc
  • Loading
Open console

API reference

Screenshot

Capture the viewport, the full page or one element of a session's current page.

The image comes back inside the JSON response as base64. To capture a URL without creating a session first, use Stateless screenshot.

Take a screenshot

POST/v1/sessions/{id}/screenshot

Every field is optional: an empty object captures the viewport of the active tab as a JPEG.

Path

  • idstringrequired

    The session to drive.

Body

  • full_pagebooldefaultfalse

    Capture the whole page instead of the viewport. The capture stops at 16384 CSS px per side.

  • selectorstring

    Capture one element, found by CSS selector. At most 16384 CSS px per side, from its top left.

  • xpathstring

    Capture one element, found by XPath, with the same bound. Use selector or xpath, not both.

  • formatjpeg or pngdefaultjpeg

    The image format.

  • qualityint, 1–100default70

    JPEG quality. jpeg only.

  • tab_idstringdefaultthe active tab

    The tab to capture.

A page or element longer than 16384 CSS px on a side is captured from its top left, up to that size.

Response

  • formatstring

    jpeg or png.

  • image_base64string

    The image, base64-encoded.

curl -s -X POST \
  "$SPHYNX_URL/v1/sessions/$SESSION/screenshot" \
  -H "Authorization: Bearer $SPHYNX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"full_page": true, "format": "png"}' \
  | jq -r .image_base64 | base64 -d > page.png
200
{
  "format": "png",
  "image_base64": "iVBORw0KGgo..."
}
Body · one element as a JPEG
{
  "selector": "#prices",
  "format": "jpeg",
  "quality": 85
}

Errors

The shape is the same as everywhere else: see Errors.

HTTPCodeWhen
400invalid_requestBoth selector and xpath, bad selector or XPath, unknown field, bad value
401unauthorizedMissing or invalid API key
404session_not_foundNo such session for this key
404element_not_foundNo element matched selector or xpath
404tab_not_foundNo such tab
409no_page_loadedThe tab is blank
409session_in_useAnother drive call has been running on this session for more than 3 s
410session_closedThe session has ended
500internalOur fault. Send us the request_id