Skip to main content

peak-client

PyPI version Python versions License: ISC

Modern, typed Python client for the Peak Solutions CAPTCHA Solving API. Solve Cloudflare Turnstile widgets and Cloudflare 5-second challenges (WAF / Under Attack Mode) with a single API call. Built on HTTPX.

Official API documentation: https://peak.fo/docs


Features

  • ⚡ Cloudflare Turnstile — Solves Turnstile challenges in under 1 second using proxyless or proxied modes.
  • 🛡️ Cloudflare 5s Challenge — Automated WAF clearance providing cookies, headers, and form-attributes for session continuation.
  • 💰 Account Balance — Real-time tracking of pay-per-solve credits and package subscription days remaining.
  • 🐍 Modern Python — Type-annotated, Google-style docstrings, context manager support (with Peak(...) as client:).
  • 🚨 Clear Exceptions — Structured PeakError exceptions with status codes and API error messages.

Installation

pip install peak-client

Requires Python 3.10 or higher.


Quick Start (Safe Check)

The quick check only inspects your account balance. It does not perform solves or spend credits.

import os
from peak import Peak

api_key = os.environ["PEAK_API_KEY"]

with Peak(api_key) as client:
    balance = client.get_balance()
    if balance["type"] == "pay_per_solve":
        print(f"Balance: ${balance['balance']}")
    else:
        print(f"Package: {balance['package']}, Days remaining: {balance['days_remaining']}")

Usage Guide

1. Solving Cloudflare Turnstile (Proxyless)

For sites that accept the Turnstile verification token from any IP address:

import os
from peak import Peak

with Peak(os.environ["PEAK_API_KEY"]) as client:
    res = client.solve_turnstile(
        url="https://example.com/",
        sitekey="0x4AAAAAAAx...",
    )
    print(f"cf-turnstile-response token: {res['token']}")

2. Solving Cloudflare Turnstile (With Proxy)

For sites that validate the solve origin matches the requesting IP address:

with Peak(os.environ["PEAK_API_KEY"]) as client:
    res = client.solve_turnstile(
        url="https://example.com/",
        sitekey="0x4AAAAAAAx...",
        proxy="http://user:pass@1.2.3.4:8080",
        action="login",
    )
    print(f"Token: {res['token']}")

3. Solving Cloudflare 5-Second Challenge (WAF)

Solves the Cloudflare challenge page and returns session credentials:

target_url = "https://example.com/"
proxy = "http://user:pass@1.2.3.4:8080"

with Peak(os.environ["PEAK_API_KEY"]) as client:
    solution = client.solve_cloudflare_5s(
        url=target_url,
        proxy=proxy,
        user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36...",
    )

    # Step 1: Apply clearance cookies to your session
    print("Clearance cookies:", solution["cookies"])

    # Step 2: Use the exact user-agent
    print("User-Agent:", solution["headers"]["user-agent"])

    # Step 3: Set Referer header with challenge token
    referer = f"{target_url}?__cf_chl_tk={solution['cf_rt']}"
    print("Referer:", referer)

    # Step 4: POST solution["attributes"] as form-data to the target URL
    print("Form attributes:", solution["attributes"])

Error Handling

When an error occurs, the client raises a PeakError:

from peak import Peak, PeakError

try:
    with Peak("invalid_key") as client:
        client.get_balance()
except PeakError as err:
    print(f"Peak error [HTTP {err.status_code}]: {err.message}")

Common status codes:

  • 200 with non-fatal error: solve attempt failed (not billed).
  • 400: missing or invalid parameters.
  • 401: missing, invalid, or expired API key.
  • 402: insufficient account balance.
  • 429: rate limit reached.
  • 502: target site unreachable or timed out.

License

ISC © api-kit contributors

Metadata

Release files for peak-client 0.1.0

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

Source distribution (sdist)

Source distribution for peak-client 0.1.0
File Size Uploaded Provenance
peak_client-0.1.0.tar.gz 72.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for peak-client 0.1.0
File Interpreter ABI Platform
peak_client-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 79.6 kB

Release files / peak_client-0.1.0.tar.gz

Download URL peak_client-0.1.0.tar.gz
Size 72.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e731f2aaffdd183bfbe551a8b2aed3fdf9ab6e208d3041d082a00c605a910b8c
BLAKE2b-256 checksum
How to use checksums
8f0b788846367e46cb824572798a5493f70dfdc88b8bdac46536eb07c98480ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / peak_client-0.1.0-py3-none-any.whl

Download URL peak_client-0.1.0-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b665e2d696ca64c6d2c6ec664af7e865e5904e072e89b93b9d294d6e1174d3c
BLAKE2b-256 checksum
How to use checksums
76162f65ab11bd2128caf770a097b5427c2881a3d74fa3cd7d213db26bac9e64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for peak-client 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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