Skip to main content
Axios is a promise-based HTTP client for Node.js and the browser. Integrating 2extract.com proxies is simple and requires passing a proxy configuration object with your request.

Basic Setup

To route your requests through our gateway, you need to provide the host, port, and auth details in the proxy object.
You’ll need to have axios installed in your project: npm install axios
basic_setup.js

Real-World Example: Scraping Reddit API for subreddit data

A common task is to collect structured data from public APIs. Let’s use Axios to scrape data from Reddit’s JSON API for a highly relevant subreddit: /r/webscraping. Reddit, like many sites, may serve different content or ads based on geography. We’ll check the “hot” posts from both the US and Great Britain (GB) to demonstrate this capability. This example shows how to create a reusable function to dynamically change the proxy’s country for each request.
reddit_scraper.js

Expected Output

Running this script will produce an output similar to this:
Terminal
(Note: Reddit’s content may not vary significantly between US/GB, but this demonstrates the technical capability) This example shows how to build a flexible scraper with Axios and 2extract.com, allowing you to reuse your scraping logic while dynamically changing proxy parameters for each targeted request.