Home / Cost tools / cURL converter / Node.js request
cURL to Node.js request converter
Paste a cURL command and get the same request in Node.js (request), using the request package (deprecated). 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.
// The request package is deprecated; it still works, but new code should use fetch or axios.
const request = require("request");
request({
method: "GET",
url: "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",
},
}, (error, response, body) => {
if (error) throw error;
console.log(response.statusCode);
console.log(body);
}); Install first: npm install request
Running the code
Install the request package with npm and run it with node. The package was deprecated in 2020 and gets no fixes; the code is here for projects that still use it, and the fetch and Axios pages give the same call in current code.
Where request package differs from curl
request calls back with an error only when the connection fails; any HTTP status, a 403 included, comes back as a response. json: sends a JSON body and parses the reply.
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