Documentation menu

Getting started

API reference

Guides

Trust and support

Screenshots

Captures a web page or an HTML document as an image or a PDF. The parameters follow ScreenshotOne.

GET  https://api.sahifa.dev/take?access_key=...&url=https://example.com
POST https://api.sahifa.dev/take   (JSON body with the same parameters)

Both methods take the same parameters. GET is convenient for simple captures; use POST with a JSON body for HTML sources and long parameter lists. The response body is the file; X-Response-Duration gives the render time in milliseconds.

Parameters

Source and output

NameTypeDefaultDescription
urlstringone ofPublic http(s):// address to capture.
htmlstringone ofHTML document to capture. Send exactly one of url and html.
formatstringpngpng, jpeg (or jpg), webp or pdf.
image_qualityintegerbrowser default1 to 100, for jpeg and webp.
omit_backgroundbooleanfalseTransparent background where the page has none (png, webp).
response_typestringby_formatby_format returns the file; json returns { "success", "content_type", "data" (base64), "size" }.

Viewport and area

NameTypeDefaultDescription
viewport_widthinteger1280Browser width in CSS pixels.
viewport_heightinteger720Browser height in CSS pixels.
device_scale_factornumber1Pixel density, up to 4. 2 gives a sharp image for high-resolution screens, at four times the pixels.
full_pagebooleanfalseCapture the whole scrollable page, not only the viewport.
selectorstringnoneCSS selector of one element to capture. If nothing matches, the answer is 404. Cannot be combined with full_page.
clip_x, clip_y, clip_width, clip_heightintegernoneCapture a rectangle of the page. Width and height are required.

Page behaviour

NameTypeDefaultDescription
wait_untilstringloadload, domcontentloaded, networkidle or commit. Use networkidle for pages built with JavaScript.
wait_for_selectorstringnoneWait until an element matching this selector is visible.
delaynumber0Extra wait after loading, in seconds, up to 30. Note: the PDF endpoint's delay is in milliseconds, as in PDFShift.
timeoutnumber30Maximum render time in seconds, capped at 30.
dark_modebooleanfalseEmulate a dark colour scheme (prefers-color-scheme: dark).
reduced_motionbooleanfalseEmulate prefers-reduced-motion: reduce, which stops many animations.
user_agentstringChromiumCustom user agent.
authorizationstringnoneValue of the Authorization header sent to the page.
headersstring or listnoneExtra headers as Name=value; repeat the parameter for several.
cookiesstring or listnoneCookies as name=value; repeat the parameter for several.
cachebooleanfalseAccepted for compatibility and ignored: every request is rendered fresh and nothing is cached.

Blocking and hiding

NameTypeDefaultDescription
block_cookie_bannersbooleanfalseHide cookie consent pop-ups and restore scrolling. Covers the common consent platforms (OneTrust, Sourcepoint, Didomi, Quantcast, Usercentrics, Cookiebot, TrustArc, consentmanager and others). Adds about one second.
block_adsbooleanfalseBlock ad requests and hide ad slots (EasyList).
block_trackersbooleanfalseBlock tracking and analytics requests (EasyPrivacy). Often makes pages load faster.
block_chatsbooleanfalseBlock and hide chat widgets (Intercom, Drift, Crisp, Tidio, Tawk, Zendesk, Freshchat, LiveChat, Olark, HubSpot).
hide_selectorsstring or listnoneCSS selectors to hide, comma-separated or repeated.
block_requestsstring or listnoneURL patterns to block, with * as wildcard, for example *.example.org/track*.
block_resourcesstring or listnoneResource types to block: image, font, media, script, stylesheet, xhr, fetch, websocket, other.

The filter lists are built into the server, so blocking adds no outside requests.

Not supported

store, storage_*, async and webhook_url are refused with 400, because Sahifa does not store files. block_banners_by_heuristics is also refused; use block_cookie_banners and hide_selectors.

Examples

GET /take?access_key=KEY&url=https://example.com&full_page=true&block_cookie_banners=true

One element, sharp

GET /take?access_key=KEY&url=https://example.com&selector=%23pricing&device_scale_factor=2

HTML to JPEG

POST /take
X-API-Key: KEY
Content-Type: application/json

{ "html": "<h1 dir=\"rtl\">مرحبا</h1>", "format": "jpeg", "image_quality": 85, "viewport_width": 800, "viewport_height": 400 }

Complete programs are in the code examples.