Skip to content

/scrape-js: scraping with JS rendering

POST/scrape-jsBrowser engine
APIRoadhttps://scrapeninja.apiroad.net/scrape-jsheader X-Apiroad-Key
RapidAPIhttps://scrapeninja.p.rapidapi.com/scrape-jsheader X-RapidAPI-Key

/scrape-js is the original browser endpoint. It keeps its request and response format for existing integrations, and since November 2026 it runs on the same browser engine as /v2/scrape-js. New integrations should use /v2/scrape-js.

It supports a few legacy options that v2 does not have, such as dumping the content of an iframe.

Terminal window
curl https://scrapeninja.apiroad.net/scrape-js \
-H "Content-Type: application/json" \
-H "X-Apiroad-Key: YOUR_KEY" \
-d '{
"url": "https://example.com/product",
"geo": "us",
"waitForSelector": ".price",
"postWaitTime": 2
}'
urlstringrequired

URL to scrape

Example
"https://example.com"
headersstring[]

Custom headers to send with the request. By default, regular Chrome browser headers are sent to the target URL.

Example
["X-Header: some-random-header"]
stepsobject[]

Browser actions to run after the page has loaded (after waitForSelector and postWaitTime): click, type or select, wait for an element. The format is a subset of Chrome DevTools Recorder steps. See Browser steps.

[
  {
    "type": "change",
    "selector": "input[name=q]",
    "value": "laptop"
  },
  {
    "type": "click",
    "selector": "button[type=submit]",
    "waitForNavigation": true
  },
  {
    "type": "waitForElement",
    "selector": ".results"
  }
]
steps[].typeenumWhat to do.
steps[].selectorstringCSS selector of the element (or selectors).
steps[].selectorsstring[]Alternative selectors, the first visible match wins. Recorder-style nested arrays are accepted.
steps[].valuestringFor change: the text to type or the option value to select.
steps[].waitForNavigationbooleanWait for the page navigation caused by this step.
steps[].waitForXhrRequeststringURL mask of an XHR this step triggers; the response is returned in info.log.

CSS selector to wait to appear in DOM tree before page is considered as loaded.

Example
"h1.some-class"

Wait for specified amount of seconds after page load (from 1 to 12s). Use this only if ScrapeNinja failed to wait for required page elements automatically.

Example
5

Block images from loading. This will speed up page loading and reduce bandwidth usage.

Example
true
blockMediaboolean

Block (CSS, fonts) from loading. This will speed up page loading and reduce bandwidth usage.

Example
true
screenshotboolean

Take a screenshot of the page. Pass "false" to increase the speed of the request.

Example
true
viewportobject

Advanced. Set custom viewport size. By default, viewport size is 1920x1080.

viewport.widthinteger
viewport.heightinteger
viewport.deviceScaleFactorinteger
viewport.hasTouchboolean
viewport.isMobileboolean
viewport.isLandscapeboolean

Useful to dump some XHR response. Pass URL mask here. For example, if you need to catch all requests to https://example.com/api/data.json, pass "api/data.json" here. In response, you will get new property .info.catchedAjax with the XHR response data - { url, method, headers[], body , status, responseHeaders{} }

If some particular iframe needs to be dumped, specify its name HTML value in this argument. The ScrapeNinja JS renderer will wait for <iframe name="icims_content_iframe"> to appear in DOM, then use waitForSelectorIframe CSS selector to wait for iframe DOM elements to appear inside.

Example
"icims_content_iframe"

If dumpIframe is activated, this property allows to wait for CSS selector inside this iframe.

Example
".iCIMS_PagingBatch"

If dumpIframe is activated, this property allows to run JS extractor function against iframe HTML instead of running it against base body. This is only useful if dumpIframe is activated.

Example
true
geostring

Geo location for basic proxy pools (you can purchase premium ScrapeNinja proxies for wider country selection and higher proxy quality). Read more about ScrapeNinja proxy setup

Default
"us"
Example
"eu"
proxystring

Premium or your own proxy URL (overrides geo field). Read more about ScrapeNinja proxy setup

Example
"http://user:pw@host:port"
retryNuminteger

Number of retries after the first attempt. Total attempts = retryNum + 1 (retryNum=0 disables retries). A retry is made on proxy/network errors, timeouts and when textNotExpected matches; each retry uses another proxy from the pool.

Default
1
Range
0–2
Example
1
timeoutinteger

Timeout per attempt, in seconds. Each retry will take [timeout] number of seconds.

Default
16
Example
8

Text which will trigger a retry from another proxy address.

Example
["random-captcha-text-which-might-appear"]

HTTP response statuses which will trigger a retry from another proxy address.

Default
[403,502]
Example
[403,429]
extractorstring

Custom JS function to extract JSON values from scraped HTML: function (input, cheerio) { ... } (cheerio 1.2, synchronous, 1 s CPU, no network). Write and test it in the Cheerio playground; for big pages see the fast parser option in JS extractors.

function(input, cheerio) {
    let $ = cheerio.load(input);
 return $('h1.title').text(); } 

Built-in extractor, used when extractor is empty. markdown: the whole page as Markdown. markdown_content: only the main content (article text without menus and footers) as Markdown, plus meta (title, byline, site name, excerpt). content: the main content as cleaned HTML. The result is returned in extractor.result.

Values
markdownmarkdown_contentcontent
Example
"markdown_content"
outputBodyboolean

Return the page HTML in body. Set to false when you only need the extractor result: the response gets much smaller.

Default
true

Return the response headers of the target website in info.headers.

Default
true

info.screenshot holds a URL of the screenshot when screenshot is on.

infoobject

Request metadata.

info.statusCodeinteger

HTTP status of the target website (not of ScrapeNinja).

info.finalUrlstring

URL after redirects.

info.catchedAjaxobject

XHR response caught by catchAjaxHeadersUrlMask.

info.catchedAjax.urlstring

—

info.catchedAjax.methodstring

—

info.catchedAjax.headersstring[]

Array of request headers

info.catchedAjax.bodystring

—

info.catchedAjax.bodyIframestring

If dumpIframe is activated, this property contains iframe HTML.

info.catchedAjax.statusinteger

—

info.catchedAjax.responseHeadersobject

Object with response headers

info.headersstring[]

Response headers of the target website, as name: value strings.

info.screenshotstring

URL of the page screenshot (when screenshot is on), or null.

info.logobject[]

Records produced by steps: XHRs caught by waitForXhrRequest, as { type: "xhr", stepIdx, data: { url, method, status, body } }.

bodystring

HTML body of the rendered page.

extractorobject

Present when extractor or extractorPreset is set.

extractor.resultany

What your extractor returned (any JSON value). For presets: { markdown, meta } or { html, meta }.

extractor.executionTimeinteger

Extractor run time, ms.

extractor.errstring

Extractor error message, if it failed.

extractor.errMultilinestring

Stack trace of the error inside your extractor.

extractor.errLineNumberinteger

Line of your extractor where the error happened (/scrape only).