Geographic Location

Certain websites (typically e-commerce stores and search engines) display different data to different users based on the geolocation of the IP used to make the request to the website. In cases like these, you can use the API’s geotargeting functionality to easily use proxies from the required country to retrieve the correct data from the website.

To control the geolocation of the IP used to make the request, simply set the country_code parameter to the country you want the proxy to be from and the API will automatically use the correct IP for that request.

For example: to ensure your requests come from the United States, set the country_code parameter to country_code=us.

Business and Enterprise Plan users can geotarget their requests to the following 13 countries (Hobby and Startup Plans can only use US and EU geotargeting) by using the country_code in their request:

Other countries are available to Enterprise customers upon request.

  • API REQUEST

import fetch from 'node-fetch';

fetch('http://api.scraperapi.com/?api_key=APIKEY&url=http://httpbin.org/ip&country_code=us')
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error)
})
  • PROXY MODE

const axios = require('axios');
axios.get('http://httpbin.org/ip', {
  method: 'GET',
  proxy: {
    host: 'proxy-server.scraperapi.com',
    port: 8001,
    auth: {
      user: 'scraperapi.country_code=us',
      password: 'APIKEY'  
    },
    protocol: 'http'
  }
})
  .then(response => {
    console.log(response)
  })
  .catch(error => {
    console.log(error)
  });
  • SDK Method

// remember to install the library: npm install scraperapi-sdk --save
const scraperapiClient = require('scraperapi-sdk')('APIKEY')
scraperapiClient.get('http://httpbin.org/ip', {country_code: 'us'})
.then(response => {
  console.log(response)
})
.catch(error => {
  console.log(error)
})

Last updated