Scraping API Prices
MenuClose

Search the site

82 providers, their alternatives and head-to-heads, targets, guides and answers

Home / Cost tools / cURL converter / Node.js fetch

cURL to Node.js fetch converter

Paste a cURL command and get the same request in Node.js (fetch), using Node's built-in fetch (Node 18 and later). It converts in your browser; nothing you paste is sent anywhere.

Converted in your browser. Nothing you paste is stored or sent, so a command with your API key in it stays on your machine.

Node.js (fetch), with Node's built-in fetch (Node 18 and later)
const response = await fetch("https://api.scraper.example/v1/scrape?url=https%3A%2F%2Fshop.example.com%2Fproducts%3Fpage%3D2&render_js=true&country=us", {
  headers: {
    "Authorization": "Bearer YOUR_API_KEY",
  },
});
console.log(response.status);
console.log(await response.text());

Running the code

Node 18 and later have fetch built in, with nothing to install. Save it as a .mjs file, or set "type": "module" in package.json, so the top-level await runs.

Where Node's built-in fetch differs from curl

As in the browser, fetch follows redirects and resolves on any HTTP status, so a 403 from a blocked scrape arrives as a normal response; test response.ok before reading the body.

What calls like this one cost

The example is a scraping API call with JavaScript rendering on and a country chosen. 100,000 of them a month cost from $49.00 on ScrapeBadger, and the same pages without rendering from $19.00 on BrowserCloud, the cheapest complete bills across 27 web scraping APIs this site prices from their own pages. What rendering adds on each API

The same command in another language