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

  • Documentation and this 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.1.tar.gz (6.2 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.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rotate_session-0.1.1.tar.gz
  • Upload date:
  • Size: 6.2 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.1.tar.gz
Algorithm Hash digest
SHA256 b1f5bef3bcad5a92e5bfeffafd858a51cb407edb424c69daf59d7ead50ff8947
MD5 418d4d5de3294aadbc82d470860af8fb
BLAKE2b-256 8fa948724747110b085132384a069b2896518a887cf49beb7a11adb0eeddfcb8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rotate_session-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 df6db4ab9052c991c8d6903f995b926315ad53112941861700e26a4d00aa6038
MD5 758962a70d130061aa7b19999b4990a5
BLAKE2b-256 aa20f588a17eeee71e27cd647c5b0a4f3070e559423d5afac34b26e0483ccd92

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