Proxy API integration tutorial: buy, renew and manage proxies from code
Step-by-step ProxyZen API tutorial with curl and Python: authentication, prices, buying IPv4/IPv6, listing and renewing proxies, residential and mobile traffic, errors and limits.
If you resell proxies, run a Telegram shop or need fresh IPs for your own scripts, clicking through a dashboard does not scale. The ProxyZen REST API does the same things in code: check prices, buy, list, renew and enable auto-renewal. This tutorial walks through a full integration with curl and Python.
Full reference: API documentation.
1. Get an API key
- Sign up and top up your balance: purchases through the API are paid from the same balance as in the dashboard.
- Open Dashboard → API and create a key. Copy it right away: it is shown only once.
- Send the key in the
Authorizationheader with every request:
Authorization: Bearer pz_your_key
The base URL is https://proxyzen.net/api/v1. All responses are JSON.
2. Check your balance
curl -H "Authorization: Bearer $PROXYZEN_KEY" https://proxyzen.net/api/v1/balance
3. Countries and prices
Countries with the number of available IPv4 and IPv6 addresses:
curl -H "Authorization: Bearer $PROXYZEN_KEY" https://proxyzen.net/api/v1/countries
Prices for a country and type (ipv4 or ipv6) for every rental period:
curl -H "Authorization: Bearer $PROXYZEN_KEY" "https://proxyzen.net/api/v1/prices?country=DE&type=ipv4"
Prices returned by the API already include your personal discount, if you have one.
4. Buy proxies
curl -X POST https://proxyzen.net/api/v1/orders \
-H "Authorization: Bearer $PROXYZEN_KEY" -H "Content-Type: application/json" \
-d '{"country":"DE","type":"ipv4","quantity":2,"days":30,"auto_renew":false}'
The response contains the order and its proxies: host, http_port, socks5_port, login, password and expires_at. Every IPv4 and IPv6 proxy works over HTTP(S) and SOCKS5 at the same time.
5. List and renew your proxies
# active proxies, 100 per page
curl -H "Authorization: Bearer $PROXYZEN_KEY" "https://proxyzen.net/api/v1/proxies?status=active&per_page=100"
# renew two proxies for 30 days
curl -X POST https://proxyzen.net/api/v1/proxies/renew \
-H "Authorization: Bearer $PROXYZEN_KEY" -H "Content-Type: application/json" \
-d '{"ids":[123,124],"days":30}'
# turn on auto-renewal from the balance
curl -X POST https://proxyzen.net/api/v1/proxies/123/auto-renew \
-H "Authorization: Bearer $PROXYZEN_KEY" -H "Content-Type: application/json" \
-d '{"enabled":true}'
Renewal keeps the same IP. An expired IP is kept for you for 48 hours, so you can still renew it.
6. Residential and mobile traffic
Residential and mobile proxies are billed per GB, and the traffic never expires.
# prices per GB
curl -H "Authorization: Bearer $PROXYZEN_KEY" https://proxyzen.net/api/v1/traffic/products
# buy 1 GB of residential traffic
curl -X POST https://proxyzen.net/api/v1/traffic/orders \
-H "Authorization: Bearer $PROXYZEN_KEY" -H "Content-Type: application/json" \
-d '{"type":"residential","gb":1}'
# your plans: username, password, host, ports and remaining GB
curl -H "Authorization: Bearer $PROXYZEN_KEY" https://proxyzen.net/api/v1/traffic/plans
Country, city and sticky session are set in the username, for example USERNAME-country-DE-session-ab12cd-time-10 — a German IP that stays the same for 10 minutes. More on this in “Rotating vs sticky IP”.
7. The same in Python
The official client has no dependencies: pip install proxyzen.
from proxyzen import ProxyZen, ProxyZenError
pz = ProxyZen("pz_your_key") # or the PROXYZEN_KEY environment variable
print(pz.balance())
print(pz.prices("DE", "ipv4"))
try:
order = pz.buy("DE", quantity=2, days=30)
for p in order["proxies"]:
print(ProxyZen.proxy_url(p)) # http://login:pass@host:port
print(ProxyZen.proxy_url(p, "socks5")) # socks5://login:pass@host:port
except ProxyZenError as e:
print(e.code, e.message) # e.g. insufficient_funds
for p in pz.iter_proxies(status="active"):
print(p["host"], p["expires_at"])
Source code: github.com/ProxyZen-net/proxyzen-python. How to plug the proxies into requests, Playwright or Puppeteer: “How to use proxies in Python and Node.js” and “Proxy in Puppeteer, Playwright, Selenium and curl”.
8. Errors and limits
- Errors come back with an HTTP status and a JSON body:
{"error": {"code": "...", "message": "..."}}. Typical codes:unauthorized(wrong key),insufficient_funds,validation_error. - The rate limit is 120 requests per minute per key. Cache the country and price lists instead of requesting them before every order.
- Keep the key on the server side only. If it leaks, revoke it in Dashboard → API and create a new one.
Ready-made Telegram shop
Don't want to write code? The free open-source ProxyZen Telegram Shop bot uses this API: you set your own prices, customers pay you, and the bot buys proxies from your ProxyZen balance automatically. See “Start a proxy business with a Telegram shop”.
Try ProxyZen
Private IPv4 and IPv6 for 3 to 90 days, residential and mobile per GB. Instant delivery, HTTP(S) and SOCKS5.