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.2.tar.gz (6.4 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.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rotate_session-0.1.2.tar.gz
  • Upload date:
  • Size: 6.4 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.2.tar.gz
Algorithm Hash digest
SHA256 a42aa2c460db9af5cc287c884170af3c56a7fc5b0d9656163d37a5d23f8c71d4
MD5 b1631e6d76d232606152bc3897f4c8f3
BLAKE2b-256 5ef60d9e9df77fa60d64e1040eaa625fcc120d020ce698033a6d151a5802d0c1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rotate_session-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.6 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7755e7b0909e3a798a3d8b3bc4f04cf77bc414856f18084f5e8c620bb8abe172
MD5 f4678628f9be4f6f526bcc6d9d31b8b4
BLAKE2b-256 528ab6d633128bbe799bec46e9cde903d362f44392f6b0ea31252267396ad242

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