String docs
Fetch

JavaScript rendering

Pages that need JavaScript are rendered automatically. Set executeJS to always render a page in a browser.

A request with only a url returns the rendered page when the page needs JavaScript; there is no field to set. Set executeJS: true when you want every request for the page rendered in a browser, or when a browser feature requires it.

executeJS

Set executeJS: true to render the page in a browser before it is returned. It supports only GET, without headers, and bills at the browser-based fetch rate.

curl https://request.usestring.ai/v1/fetch \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://example.com/spa", "executeJS": true }'

Features that use browser rendering

These features read from a page loaded in a browser, so a request that uses one always runs in a browser. Screenshots and browser actions do so on their own and need no executeJS. Of the features below, captureXHR requires executeJS: true, with or without actions or screenshot. waitUntil, includeIframes, captureIframes and captureCookies require one of executeJS: true, actions or screenshot, so leave executeJS out when the request already has actions or screenshot.

Capture the page's API calls

A rendered page often gets its data from a JSON API. Add captureXHR: true to a rendered fetch to also get the XHR and fetch() requests the page made, with their responses, as xhr. You can filter them down to the calls you want, and include the requests of embedded iframes from other sites. See XHR capture.

curl https://request.usestring.ai/v1/fetch \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://example.com/spa", "executeJS": true, "captureXHR": { "include": [{ "url": "/api/" }] } }'

Wait for the page to load

A rendered page is read once it has loaded and settled. To also wait for a specific state, such as its load event or its network going idle, set waitUntil. See Waiting for page load.

curl https://request.usestring.ai/v1/fetch \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://example.com/spa", "executeJS": true, "waitUntil": "networkidle2" }'

Read iframes

A rendered page's HTML holds its <iframe> elements but not the documents inside them. Set includeIframes: true to inline each iframe's content into data, or captureIframes: true to list the iframes with their HTML as iframes. See Iframes.

curl https://request.usestring.ai/v1/fetch \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://example.com/spa", "executeJS": true, "includeIframes": true }'

Read the page's cookies

captureCookies is an Enterprise feature, enabled per account. Contact [email protected] to have it enabled for yours.

A rendered page can set cookies that the destination's own API calls need, such as a session or CSRF cookie. Set captureCookies: true to also get the cookies the browser would send to the final page URL once the page has loaded, HttpOnly cookies included, as cookies. Send them in a Cookie custom header on your direct requests to the same destination.

curl https://request.usestring.ai/v1/fetch \
  -H "Authorization: Bearer $STRING_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://example.com/jobs", "executeJS": true, "captureCookies": true }'

The response, trimmed to the fields shown:

{
  "statusCode": 200,
  "data": "<!DOCTYPE html>…",
  "finalUrl": "https://example.com/jobs",
  "cookies": [
    {
      "name": "session",
      "value": "8f2c…",
      "domain": "example.com",
      "path": "/",
      "expires": -1,
      "httpOnly": true,
      "secure": true
    }
  ]
}

Each cookie has name and value, plus domain, path, expires, httpOnly and secure when the browser reports them. expires is Unix time in seconds, and -1 marks a cookie that lasts only for the session. When the cookies could not be read for that response, cookies is empty and cookiesTruncated is true; retry the request to get them.

With browser actions, the cookies are read once the last action has run, so a sign-in or consent click's cookies are included. Without actions or screenshot, captureCookies requires format: "json"; a browser-actions response is JSON whatever the format. It can't be combined with jsonSchema, and a request that does returns a 400. An account without captureCookies enabled gets a 403. A 503 means cookie capture is temporarily unavailable; retry later. A request with captureCookies is billed at the browser-based fetch rate; see Pricing.

requireWSS

Set requireWSS: true to require a browser WebSocket-capable fetch path for the request.

Header restriction

Custom headers are not supported when executeJS or requireWSS is set — these run through a browser path that doesn't forward arbitrary request headers. Sending headers alongside either of them returns a 400. See Custom headers.