Proxy basics

What is a rotating proxy API?

How proxy rotation works, what a rotation API returns, and how to rotate in your own code.


The idea.

A rotating proxy API gives your program a proxy address from a pool each time it asks. Your program then sends its own traffic through that proxy.

"Rotating" means the address changes between requests, so a website does not see all your requests arriving from one IP.

Your script gimmeproxy API Proxy address Your script Public proxy Destination

The API selects a proxy; it does not carry your web traffic.

Two kinds of proxy rotation.

Services sold as rotating proxies work in one of two ways. Which one you have decides what you configure and who does the rotating.

Rotating gatewayProxy rotation API
You configureOne fixed gateway addressAn API call that returns an address
Who rotatesThe provider, behind the gatewayYour code: ask again for another proxy
Your traffic passesThe provider's serversOnly the proxy; the API stays out of the path
You can seeLittle about the exit addressIP, country, protocol, speed and age of each proxy
Usual pricePaid per gigabyte or per IPOften free when the proxies are public

gimmeproxy is the second kind: a free rotating proxy API over public proxies. It fits scripts that can retry: collecting public pages, checking how a site looks from another country, experiments. The last section says where it does not fit.

Make your first request.

$ curl 'https://gimmeproxy.com/api/getProxy?curl=true'
Sample response
http://192.0.2.24:8080
HTTPS checked

Use the returned address with your HTTP client.

Read the response.

With curl=true the answer is one line, protocol://ip:port. Without it you get a JSON record that describes the proxy.

{
  "supportsHttps": true,
  "protocol": "http",
  "ip": "192.0.2.24",
  "port": "8080",
  "anonymityLevel": 1,
  "country": "US",
  "curl": "http://192.0.2.24:8080",
  "speed": 15.45,
  "verifiedSecondsAgo": 240
}

Shortened; the reference has the rest.

FieldMeaning
ip, portWhere to connect. The port is a string.
protocolhttp, socks4 or socks5
countryWhere the proxy's traffic comes out
anonymityLevel1: the destination saw the proxy's address, not the caller's
speedMeasured download speed in KB/s
verifiedSecondsAgoSeconds since the proxy last passed the check
curlThe address in the form curl -x takes

Choose your filters.

A filter narrows the current public pool. The API then draws at random from what is left.

FilterExample
Countrycountry=BR or country=BR,AR
Not a countrynotCountry=US
Protocolprotocol=socks5
Portport=8080
SpeedminSpeed=100
FreshnessmaxCheckPeriod=600
AnonymityanonymityLevel=1

When nothing matches, the answer is still HTTP 200, with the body {"error":"no more proxies left"}. Loosen a filter and ask again. The live list shows how many proxies each country and protocol has right now.

Rotation is random.

A later API call can return the same proxy. This is not a guarantee of a new IP on every request.

Rotate in your code.

With a rotation API you decide when to change proxy. Three patterns cover most scripts.

  • On failure. Keep a proxy while it works and ask for another when a request fails. This uses the fewest API calls.
  • Per batch. Ask for a new proxy every few requests or every few minutes, so no single address carries the whole job.
  • Per request. Ask before every request. Each one comes from a random proxy, at the price of one API call each time.

Rotation on failure in Python, with the requests library:

import requests

API = "https://gimmeproxy.com/api/getProxy"

def new_proxy(**filters):
    r = requests.get(API, params={"curl": "true", "protocol": "http", **filters}, timeout=10)
    return None if r.text.startswith("{") else r.text   # {"error": ...}: nothing matched

def fetch(url, attempts=8):
    for _ in range(attempts):
        proxy = new_proxy(maxCheckPeriod=600)
        if not proxy:
            continue
        try:
            return requests.get(url, proxies={"http": proxy, "https": proxy}, timeout=(5, 30))
        except requests.RequestException:
            pass                                          # dead proxy: rotate
    raise RuntimeError("no working proxy")

To hold one address for a whole session, call new_proxy() once, reuse the result, and call it again only after a failure. The Python guide goes through SOCKS proxies and error handling.

Stay inside the limits.

Without a key you have 50 API requests per IP per day. Each call counts once, however many requests you then send through the proxy it returned.

The response headers Rate-Limit-Remaining and Rate-Limit-Reset say how many calls are left and when the count starts again. Past the limit the API answers 429. Rotating on failure or per batch stretches the allowance much further than rotating per request. A paid key raises the limit; the reference lists every code and header.

Plan for timeouts.

A public proxy can stop answering between the check and your request. That is normal, and a script that expects it runs fine.

  1. Set a request timeout.
  2. Request another proxy after failure.
  3. Back off when you hit API limits.
Timeouts and retries in detail

What verification tells you.

Every proxy in the pool passed four steps: a TCP connection, a tunnel in its protocol, validation of the TLS certificate, and a real HTTPS request. Live proxies are checked again about every 45 minutes, and one that has not passed within 60 minutes is no longer served.

So a proxy passed an HTTPS check at the recorded time. It may still stop working afterward.

Read how verification works

When a free rotating proxy API is the wrong tool.

  • Logins and secrets. A public proxy is run by a stranger. Over plain HTTP its operator can read and change what passes. Use HTTPS, and keep accounts and payments off public proxies.
  • One address for hours. Public proxies come and go. If a session must keep its IP, you need a private or static proxy.
  • A city or a provider. The filters go down to the country. Finer targeting is what paid residential networks sell.
  • Large jobs on a deadline. Retries make public proxies usable, not fast. For volume with a success rate to meet, a paid rotating gateway is the better buy.

Keep building.

More guides to help you get the most from gimmeproxy.

Get a free proxy