Scraping API Prices
MenuClose

Search the site

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

Home / Cost tools / cURL converter / Axios

cURL to Axios converter

Paste a cURL command and get the same request in Node.js (Axios), using Axios. 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 (Axios), with Axios
import axios from "axios";

const response = await axios({
  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",
  },
  maxRedirects: 0,
  validateStatus: (status) => status < 400,
});
console.log(response.status);
console.log(response.data);

Install first: npm install axios

Running the code

Install axios with npm and run it as an ES module. The request becomes one config object: method, url, headers, data, auth and timeout in milliseconds.

Where Axios differs from curl

Axios follows redirects on its own, so without -L the code sets maxRedirects to 0 and accepts a 3xx reply. It throws for any other status outside 200 to 299, so a 404 or a 403 from the target lands in catch, with the response on error.response. It parses a JSON reply into response.data for you.

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 $14.99 on FlyByAPIs AI Web Scraper, the cheapest complete bills across 32 web scraping APIs this site prices from their own pages. What rendering adds on each API

The same command in another language