Skip to main content

Proxy-backed HTTP session utilities with retry and rotation support.

Project description

rotate-session

rotate-session is a small Python package for HTTP requests with retry support and optional proxy rotation.

Installation

pip install rotate-session

Features

  • Retry failed requests with configurable attempts and wait time
  • Rotate across a list of proxies automatically on retry
  • Fetch proxy lists from Webshare
  • Use plain requests-style proxies when provider integration is not needed

Quick start

from rotate_session import RotateSession

session = RotateSession()
response = session.get("https://httpbin.org/get", timeout=20)
print(response.status_code)

Configure retries

from rotate_session import RetryConfig, RotateSession

retry = RetryConfig(max_retries=5, wait_secs=2)
session = RotateSession(retry_config=retry)

Use your own proxy list

from rotate_session import ProxyConfig, RotateSession

proxy_config = ProxyConfig(
    proxies=[
        {"http": "http://user:pass@1.2.3.4:8080", "https": "http://user:pass@1.2.3.4:8080"},
        {"http": "http://user:pass@5.6.7.8:8080", "https": "http://user:pass@5.6.7.8:8080"},
    ]
)

session = RotateSession(proxy_config=proxy_config)
response = session.get("https://httpbin.org/ip", timeout=20)
print(response.text)

Use Webshare as proxy provider

from rotate_session import ProxyConfig, ProxyProvider, RotateSession

proxy_config = ProxyConfig(
    provider=ProxyProvider.WEBSHARE,
    api_key="YOUR_WEBSHARE_API_KEY",
)

session = RotateSession(
    proxy_config=proxy_config,
    proxies_fetch_params={"country_codes": ["US"], "mode": "direct"},
)

response = session.get("https://httpbin.org/ip", timeout=20)
print(response.text)

Notes

  • Logging, documentation and README were generated with AI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rotate_session-0.1.4.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rotate_session-0.1.4-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file rotate_session-0.1.4.tar.gz.

File metadata

  • Download URL: rotate_session-0.1.4.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rotate_session-0.1.4.tar.gz
Algorithm Hash digest
SHA256 55eb3facaa4d4a39a216a01a26ec35080be617757b47d139c11166694b779388
MD5 211243fde305ba36ad94029a3f986aa0
BLAKE2b-256 8701b60577424985dc8396f8d780bf4f4fba9f2a9022209569fd0e516608c9a7

See more details on using hashes here.

File details

Details for the file rotate_session-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: rotate_session-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rotate_session-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1485c57998171fd98c00bf4d14ef59b0c8a067c06403d0dca04cd67ed8ea6d23
MD5 cac8deeb79d9a6df91b2bc46ef72145e
BLAKE2b-256 d4a29d76125cb2e49caedbe305dad00dc2864311be6787b7f3ca0584b550709e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page