Skip to main content

cmdop-proxy

cmdop-proxy gives Python applications one provider-neutral contract for acquiring and using bounded proxy leases. It is a client library, not a proxy server and not a scraping framework.

The package intentionally separates two responsibilities:

  • a broker selects and leases an endpoint;
  • the application sends traffic directly through that endpoint with its native HTTP client.

Provider management APIs and account keys do not belong in this package.

Install

pip install cmdop-proxy

SOCKS5 support is installed by default.

Managed production proxy

The normal consumer API does not require a broker URL, pool, provider or target profile. The library reads CMDOP_PROXY_TOKEN or the Docker secret /run/secrets/cmdop_proxy_token, then owns lease, renewal and release:

from cmdop_proxy import ProxySession

async with await ProxySession.open() as proxy:
    async with proxy.async_httpx_client(timeout=30) as client:
        response = await client.get("https://example.com/")

Static/offline use

import asyncio
from datetime import timedelta

from cmdop_proxy import (
    AcquireRequest,
    IdentityMode,
    ProxyEndpoint,
    ProxyProtocol,
    StaticBroker,
    create_async_client,
)


async def main() -> None:
    broker = StaticBroker(
        pools={
            "parser": [
                ProxyEndpoint(
                    endpoint_id="local-1",
                    host="127.0.0.1",
                    port=8080,
                    protocol=ProxyProtocol.HTTP,
                    username="user",
                    password="secret",
                )
            ]
        }
    )
    lease = await broker.acquire(
        AcquireRequest(
            pool="parser",
            purpose="source-acquisition",
            target="example",
            protocols=(ProxyProtocol.HTTP,),
            identity_mode=IdentityMode.FIXED,
            affinity="account-primary",
            ttl=timedelta(minutes=15),
        ),
        idempotency_key="run-001",
    )

    async with create_async_client(lease, timeout=30) as client:
        response = await client.get("https://example.com/")
        response.raise_for_status()


asyncio.run(main())

StaticBroker is deterministic, process-local and network-free. It is useful for tests, local deployments and as the reference semantics for remote broker contract tests. It does not persist leases across process restarts.

Security properties

  • Credentials never appear in endpoint or lease repr output.
  • Proxy URLs percent-encode user information.
  • The library does not set HTTP_PROXY, HTTPS_PROXY or any other global environment variable.
  • Observations are typed categories and cannot carry response bodies, cookies, headers or arbitrary error messages.
  • A renewal preserves identity or fails; it never silently changes endpoint.

Applications should keep leases in memory and persist only the lease ID when a remote broker supports lease recovery.

Cloudflare control plane

CloudflareBroker implements the same async contract over the versioned proxy.sdkrouter.com API. The workload receives only its broker token; provider management keys stay in Worker secrets.

from cmdop_proxy import CloudflareBroker

async with CloudflareBroker(
    token=workload_token,
) as broker:
    lease = await broker.acquire(request, idempotency_key="parser-run-001")

The broker token is excluded from repr, remote error messages are mapped to stable typed exceptions, and arbitrary response bodies are never copied into exceptions.

Metadata

Release files for cmdop-proxy 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cmdop-proxy 0.1.1
File Size Uploaded
cmdop_proxy-0.1.1.tar.gz 13.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cmdop-proxy 0.1.1
File Interpreter ABI Platform
cmdop_proxy-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.3 kB

Release files / cmdop_proxy-0.1.1.tar.gz

Download URL cmdop_proxy-0.1.1.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
53a42cac3f5d430834c9c10dcafee2dfed1b351bc8e1e1424c4f5a2fd22cf21a
BLAKE2b-256 checksum
How to use checksums
87b198b7cf356cf41dba640e112ad5d06ffebd2b9afca97af503de199f91e978
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Release files / cmdop_proxy-0.1.1-py3-none-any.whl

Download URL cmdop_proxy-0.1.1-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3104ddedaed69bca2327ce4d7227c7dd54b7dd62b1165e7c64ad8b5022b6f23e
BLAKE2b-256 checksum
How to use checksums
98d91bcab63d6ac2f91b3f15efaf86749f9169999cc88ad5353c8177126f1aa2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page