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.3.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.3-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rotate_session-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 d84e2a9533c48d7d43489cfbf5ef1ac7e457d42e5262f1012c103707ef36470e
MD5 068ff44384a89ea0078ea4d36b291305
BLAKE2b-256 5cbde9e49e0e21cb61ad040045768ca1b6f8a37f08e5e1f19080d42f28853a97

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rotate_session-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a849e16c3f4be26aa4abf2ce85635840dfe9d257923a8eb5b077de153abe20e8
MD5 351b8baf9eb938acb88e3fe9d556a499
BLAKE2b-256 be848262acae112435826d317cedb88f4414b4f902852fabfdc2dc4e8f7b1cb5

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