Getting started

The first thing you need is an Auth Key. This is unique to you. You will get it the moment you sign up on Proxies API.

Before you proceed go ahead and sign up here to get the Auth Key. You will get an Auth Key even on the free plan and the key will allow you access the API 1000 times.

Once you have the Auth Key, its time to create a simple page fetcher...

Hello Internet

The simplest implementation of Proxies API is by sending a request like this...

curl "http://api.proxiesapi.com/?auth_key=YOUR_KEY&url=URL" 

The api.proxiesapi.com endpoint is essentially the only endpoint you will need to use to access all the features of Proxies API. Here you pass the Auth Key which you will receive once you sign up and the URL you want to retrieve to the end point and the result should look like this...
<!doctype html>
<html>
<head>
<title>Example Domain</title>
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
... 
Some points to note here...
  • The URL can be HTTP or HTTPS protocol
  • It's best to url encode the URL value if it contains any variables
  • If the Auth key has expired or if you have run out of your quota, this call will return an error
  • It will also return an error if the page cannot be found. This will only happen after automatically retrying for atleast 60 seconds on our end
Sample code
 bash
  <?php
  $ch = curl_init();
  $url = "https://example.com";
  curl_setopt($ch, CURLOPT_URL,"http://api.proxiesapi.com/?
  auth_key=YOURKEY&url=".url_encode($url));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($ch, CURLOPT_HEADER, FALSE);
  $response = curl_exec($ch);
  curl_close($ch);

  var_dump($response);

          
var request = require('request');
var url = 'https://example.com';

request(
  {
    method: 'GET',
    url: 'http://api.proxiesapi.com/?auth_key=YOURKEY&url=' + url,
    headers: {
      Accept: 'application/json',
    },
  },
  function(error, response, body) {
    console.log(body);
  }
);
          
# importing the requests library 
import requests 
  
# Proxies api-endpoint 
URL = "http://api.proxiesapi.com"
  
# insert your auth key here
auth_key = "xxxyyy"
url = "https://example.com"
  
# defining a params dict for the parameters to be sent to the API 
PARAMS = {'auth_key':auth_key, 'url':url} 
  
# sending get request and saving the response as response object 
r = requests.get(url = URL, params = PARAMS) 
  
print r.text() 
          
require 'httparty'

url = 'http://api.proxiesapi.com'
query = {
  'auth_key' => 'your auth_key',
  'url' => 'https://example.com'
}

response = HTTParty.get('http://api.proxiesapi.com', query: query)
results = response.body
puts results
          
Results
<!doctype html>
<html>
<head>
<title>Example Domain</title>
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
... 


Javascript Rendering

For web pages that use a lot of Javascript to render content using AJAX the normal calls wont cut it. We use a swarm of headless browsers to get the job done by actually rendering each page. This process is slower than normal fetches but very effective.

To render your URLs you just have to pass the render=true parameter and our API will do the job for you. Please note that rendering web pages uses 5 credits in place of 1 credit if it was a normal call.

Sample code
curl "http://api.proxiesapi.com/?auth_key=YOURKEY&url=http://httpbin.org/ip&render=true"
curl "http://api.proxiesapi.com/?auth_key=YOURKEY&url=http://httpbin.org/ip&render=true"
  <?php
  $ch = curl_init();
  $url = "http://httpbin.org/anything";
  curl_setopt($ch, CURLOPT_URL,"http://api.proxiesapi.com/?
  auth_key=YOURKEY&url=".url_encode($url)."&render=true");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($ch, CURLOPT_HEADER, FALSE);
  $response = curl_exec($ch);
  curl_close($ch);

  var_dump($response);



  $response1 = curl_exec($ch);
  curl_close($ch);

  var_dump($response1);
          
var request = require('request');
var url = 'http://httpbin.org/anything';

request(
  {
    method: 'GET',
    url: 'http://api.proxiesapi.com/?auth_key=YOURKEY&url=' + url + 'render=true',
    headers: {
      Accept: 'application/json',
    },
  },
  function(error, response, body) {
    console.log(body);
  }
);



request(
  {
    method: 'GET',
    url: 'http://api.proxiesapi.com/?auth_key=YOURKEY&url=' + url + 'render=true',
    headers: {
      Accept: 'application/json',
    },
  },
  function(error, response, body) {
    console.log(body);
  }
);
          
# importing the requests library 
import requests 
  
# Proxies api-endpoint 
URL = "http://api.proxiesapi.com"
  
# insert your auth key here
auth_key = "xxxyyy"
url = "http://httpbin.org/anything"
session = "444"

  
# defining a params dict for the parameters to be sent to the API 
PARAMS = {'auth_key':auth_key, 'url':url, 'render':'true'} 
  
# sending get request and saving the response as response object 
r = requests.get(url = URL, params = PARAMS) 
  
print r.text() 

  
# sending get request and saving the response as response object 
r = requests.get(url = URL, params = PARAMS) 
  
print r.text() 
          
require 'httparty'

url = 'http://api.proxiesapi.com'
query = {
  'auth_key' => 'your auth_key',
  'url' => 'http://httpbin.org/anything'
  'render' => 'true'
}

response = HTTParty.get('http://api.proxiesapi.com', query: query)
results = response.body
puts results

response1 = HTTParty.get('http://api.proxiesapi.com', query: query)
results1 = response1.body
puts results1
          
Results

<html>
  <head>
  </head>
  <body>
    <pre style="word-wrap: break-word; white-space: pre-wrap;">
      {"origin":"7.2.87.54"}
    </pre>
  </body>
</html>
<html>
  <head>
  </head>
  <body>
    <pre style="word-wrap: break-word; white-space: pre-wrap;">
      {"origin":"76.12.30.14"}
    </pre>
  </body>
</html>


Session handling

Sometimes we need to make multiple calls through the same proxy to keep the session. You can do that simply by passing a session number to each session you want to create.

Sample code
curl "http://api.proxiesapi.com/?auth_key=YOURKEY&url=http://httpbin.org/ip&session=444"
curl "http://api.proxiesapi.com/?auth_key=YOURKEY&url=http://httpbin.org/ip&session=444"
  <?php
  $ch = curl_init();
  $url = "http://httpbin.org/anything";
  curl_setopt($ch, CURLOPT_URL,"http://api.proxiesapi.com/?
  auth_key=YOURKEY&url=".url_encode($url)&session=444);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($ch, CURLOPT_HEADER, FALSE);
  $response = curl_exec($ch);
  curl_close($ch);

  var_dump($response);



  $response1 = curl_exec($ch);
  curl_close($ch);

  var_dump($response1);
          
var request = require('request');
var url = 'http://httpbin.org/anything';

request(
  {
    method: 'GET',
    url: 'http://api.proxiesapi.com/?auth_key=YOURKEY&url=' + url + 'session=444',
    headers: {
      Accept: 'application/json',
    },
  },
  function(error, response, body) {
    console.log(body);
  }
);



request(
  {
    method: 'GET',
    url: 'http://api.proxiesapi.com/?auth_key=YOURKEY&url=' + url + 'session=444',
    headers: {
      Accept: 'application/json',
    },
  },
  function(error, response, body) {
    console.log(body);
  }
);
          
# importing the requests library 
import requests 
  
# Proxies api-endpoint 
URL = "http://api.proxiesapi.com"
  
# insert your auth key here
auth_key = "xxxyyy"
url = "http://httpbin.org/anything"
session = "444"

  
# defining a params dict for the parameters to be sent to the API 
PARAMS = {'auth_key':auth_key, 'url':url, 'session':session} 
  
# sending get request and saving the response as response object 
r = requests.get(url = URL, params = PARAMS) 
  
print r.text() 

  
# sending get request and saving the response as response object 
r = requests.get(url = URL, params = PARAMS) 
  
print r.text() 
          
require 'httparty'

url = 'http://api.proxiesapi.com'
query = {
  'auth_key' => 'your auth_key',
  'url' => 'http://httpbin.org/anything'
  'session' => '444'
}

response = HTTParty.get('http://api.proxiesapi.com', query: query)
results = response.body
puts results

response1 = HTTParty.get('http://api.proxiesapi.com', query: query)
results1 = response1.body
puts results1
          
Results

Notice that both the requests have come from the same IP address

<html>
  <head>
  </head>
  <body>
    <pre style="word-wrap: break-word; white-space: pre-wrap;">
      {"origin":"7.2.87.54"}
    </pre>
  </body>
</html>
<html>
  <head>
  </head>
  <body>
    <pre style="word-wrap: break-word; white-space: pre-wrap;">
      {"origin":"76.12.30.14"}
    </pre>
  </body>
</html>


Passing custom headers

You can choose to pass your own headers to force a particular behaviour by setting the use_headers variable to true. This could be usefun in scenarios where you need to send a particular User-Agent string or force a response format like json or even send cookies. Check he example below where we try to send a custom header...

Sample code
curl --header "My-Custom-Header: MY custom header data" \
"http://api.proxiesapi.com/?auth_key=Yauthkey&url=http://httpbin.org/anything&use_headers=true"

          
  <?php
  $ch = curl_init();
  $url = "http://httpbin.org/anything";
  curl_setopt($ch, CURLOPT_URL,"http://api.proxiesapi.com/?
  auth_key=YOURKEY&url=".url_encode($url)."use_headers=yes");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($ch, CURLOPT_HEADER, FALSE);

  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "My-Custom-Header: MY custom header data",
  ));

  $response = curl_exec($ch);
  curl_close($ch);

  var_dump($response);
          
var request = require('request');
var url = 'http://httpbin.org/anything';

request(
  {
    method: 'GET',
    url: 'http://api.proxiesapi.com/?auth_key=YOURKEY&url=' + url+'use_headers=true',
    headers: {
      My-Custom-Header: 'MY custom header data',
    },
  },
  function(error, response, body) {
    console.log(body);
  }
);
          
# importing the requests library 
import requests 
  
# Proxies api-endpoint 
URL = "http://api.proxiesapi.com"
  
# insert your auth key here
auth_key = "xxxyyy"
url = "http://httpbin.org/anything"
use_headers = "true"
  

headers = {
  'My-Custom-Header': 'MY custom header data',
}

# defining a params dict for the parameters to be sent to the API 
PARAMS = {'auth_key':auth_key, 'url':url, 'use_headers':true} 
  
# sending get request and saving the response as response object 
r = requests.get(url = URL, params = PARAMS, headers=headers) 
  
print r.text() 
          
require 'httparty'

headers = {
  'My-Custom-Header': 'MY custom header data'
}

url = 'http://api.proxiesapi.com'
query = {
  'auth_key' => 'your auth_key',
  'url' => 'http://httpbin.org/anything',
  'use_headers' => 'true'
}

response = HTTParty.get('http://api.proxiesapi.com', query: query, headers: headers)
results = response.body
puts results
          
Results

See how the custom header value is kept through to the final url

<!doctype html>
<html>
  <head>
  </head>
  <body>
    <pre style="word-wrap: break-word; white-space: pre-wrap;">
    {
        "My-Custom-Header":"MY custom header data"
...


Geotargetting

By default, Proxies API selects a random proxy from any of the 10 countries we support. To force the selection of a proxy from a particular country, just set the country_code variable to the country's code.

Here is the list of country codes we support at the moment. United States of America (US), Canada (CA), Great Britain (GB), Germany (DE), France (FR), Spain (ES), Australia (AU), India (IN), Brazil (BR), Mexico (MX)

curl "http://api.proxiesapi.com/?auth_key=YOUR_KEY&url=URL
&country_code=AU"



Sending POST data

You can use Proxies API to send POST, PUT and submit form data. Here is a breakdown on how to accomplish this...

Simple POST request (You can change it to -X PUT to PUT requests)

curl -d "param1=value1&param2=value2" -X POST 
http://api.proxiesapi.com/?auth_key=YOURKEY&url=http://example.com

Explicit

curl -d "param1=value1&param2=value2" -H "Content-Type: 
application/x-www-form-urlencoded" -X POST 
http://api.proxiesapi.com/?auth_key=YOURKEY&url=http://example.com

Sending a file

curl -d "@data.txt" -X POST 
http://api.proxiesapi.com/?auth_key=YOURKEY&url=http://example.com

POST application/json

curl -d '{"key1":"value1", "key2":"value2"}' 
-H "Content-Type: application/json" -X POST 
http://api.proxiesapi.com/?auth_key=YOURKEY&url=http://example.com



Debugging

To get debugging data, just turn it on by setting debug=true. It will give you a breakdown of all the headers, GET and POST data that was sent by you, the data and headers forwarded by Proxies API and the final return headers, cookies returned by the target...

curl "http://api.proxiesapi.com/?auth_key=YOUR_KEY&url=URL&debug=true"



Auto retries and timeouts

Here are a few things you need to know about the API...

  • Proxies API will automatically retry your requests for 60 seconds after which it will timeout. It's best to set a timeout for 60 seconds in your code as well.
  • Data will be cut off at 2 MB for every request.
  • You will not be charged for any failed requests.

Ready to start?

Make use of our 1000 free API calls to get started risk free
Icon