Metadata-Version: 2.4
Name: proxyzen
Version: 0.1.0
Summary: Official Python client for the ProxyZen proxy API: buy, renew and list IPv4/IPv6, residential and mobile proxies.
Project-URL: Homepage, https://proxyzen.net/
Project-URL: Documentation, https://proxyzen.net/en/api
Project-URL: Buy proxies, https://proxyzen.net/en/prices
Project-URL: Source, https://github.com/ProxyZen-net/proxyzen-python
Author: ProxyZen
License-Expression: MIT
License-File: LICENSE
Keywords: api,http proxy,ipv4,ipv6,mobile proxies,proxies,proxy,proxyzen,residential proxies,socks5
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Internet :: Proxy Servers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# proxyzen — Python client for the ProxyZen proxy API

Official, dependency-free Python client for the [ProxyZen](https://proxyzen.net/) API. Buy, renew and list private **IPv4 / IPv6** proxies and **residential / mobile** traffic from your own code, scripts or bots.

- Private IPv4 and IPv6 proxies in many countries, HTTP(S) and SOCKS5 on every proxy
- Residential (140+ countries) and mobile proxies billed per GB, traffic never expires
- Standard library only, Python 3.8+

Docs: **https://proxyzen.net/en/api** · Prices: **https://proxyzen.net/en/prices**

## Install

```bash
pip install proxyzen
```

## Quick start

Create an API key in your dashboard: https://proxyzen.net/cabinet/api

```python
from proxyzen import ProxyZen

pz = ProxyZen("pz_your_key")        # or set the PROXYZEN_KEY environment variable

print(pz.balance())

# countries with IPv4 in stock and prices
in_stock = [c["code"] for c in pz.countries() if c["available"]["ipv4"] > 0]
print(in_stock)
print(pz.prices("DE", "ipv4"))

# buy 2 IPv4 proxies in Germany for 30 days (spends money from the balance)
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
```

## Manage your proxies

```python
for p in pz.iter_proxies(status="active"):
    print(p["host"], p["http_port"], p["expires_at"])

pz.renew([123, 124], days=30)          # renew by id
pz.set_auto_renew(123, True)           # auto-renew from the balance
```

## Residential and mobile proxies (per GB)

```python
print(pz.traffic_products())                       # prices
pz.buy_traffic(1, "residential")                   # 1 GB, spends money
for plan in pz.traffic_plans():
    user = f"{plan['username']}-country-US-session-ab12cd-time-10"   # US, sticky IP for 10 minutes
    print(f"http://{user}:{plan['password']}@{plan['host']}:{plan['http_port']}")
```

## Use with requests

```python
import requests
proxy = ProxyZen.proxy_url(order["proxies"][0])
print(requests.get("https://api.ipify.org", proxies={"http": proxy, "https": proxy}).text)
```

More examples: [how to use proxies in Python and Node.js](https://proxyzen.net/en/blog/proxy-in-python-nodejs), [Puppeteer, Playwright, Selenium and curl](https://proxyzen.net/en/blog/proxy-puppeteer-playwright-curl).

## Errors

API errors raise `ProxyZenError` with `.status`, `.code` and `.message`:

```python
from proxyzen import ProxyZenError
try:
    pz.buy("DE", quantity=1, days=30)
except ProxyZenError as e:
    print(e.code, e.message)            # e.g. insufficient_funds
```

## Links

- Website: https://proxyzen.net/
- API documentation: https://proxyzen.net/en/api
- Free tools: [My IP](https://proxyzen.net/en/tools/my-ip), [proxy checker](https://proxyzen.net/en/tools/proxy-checker), [IP check](https://proxyzen.net/en/tools/ip-check)
- Telegram bot: https://t.me/proxyzen_app

MIT License.
