How to use rotating proxies with Python requests
Connect to the BullProxy gateway, rotate IPs on every request and keep sticky sessions when you need them — in under 20 lines of code.
Rotating proxies give you a new IP address for every request, which spreads your traffic across thousands of addresses and keeps rate limits away.
1. Get your credentials
Open Dashboard → My proxies, pick a plan and copy the host, port, username and password.
2. Send a request through the gateway
import requests
proxy = "http://USERNAME:[email protected]:8000"
proxies = {"http": proxy, "https": proxy}
r = requests.get("https://api.ipify.org?format=json", proxies=proxies, timeout=30)
print(r.json())
Run it a few times — you will see a different IP each time.
3. Target a country
Add the country to your username, for example USERNAME-country-us. The proxy generator in your dashboard builds these strings for you.
4. Keep the same IP (sticky sessions)
Some flows, like logging in, need the same IP for a few minutes. Add a session id: USERNAME-session-abc123. Requests with the same id keep their IP.
Tips for reliable scraping
- Set a timeout on every request.
- Retry failed requests with a short back-off.
- Send realistic headers, including a current
User-Agent.