Skip to main content

Official Python SDK for the NSLSolver captcha solving API

Project description

NSLSolver Python SDK

Python SDK for the NSLSolver captcha solving API.

Installation

pip install nslsolver

# async support
pip install nslsolver[async]

Quick Start

from nslsolver import NSLSolver

solver = NSLSolver("your-api-key")

# Turnstile
result = solver.solve_turnstile(
    site_key="0x4AAAAAAAB...",
    url="https://example.com",
)
print(result.token)

# Cloudflare challenge (proxy required)
result = solver.solve_challenge(
    url="https://example.com/protected",
    proxy="http://user:pass@host:port",
)
print(result.cookies, result.user_agent)

# Kasada
from nslsolver import KasadaConfig

result = solver.solve_kasada(
    url="https://example.com/api",
    user_agent="Mozilla/5.0 ...",
    ua_version=131,
    kasada_config=KasadaConfig(
        p_js_path="/149e9513-01fa-4fb0-aad4-566afd725d1b/2d206a39-8ed7-437e-a3be-862e0f06eea3/p.js",
        fp_host="https://fp.example.com",
        tl_host="https://tl.example.com",
    ),
)
print(result.headers)
print(result.ct, result.cd)

# Balance
balance = solver.get_balance()
print(balance.balance, balance.max_threads, balance.allowed_types)

Async

import asyncio
from nslsolver import AsyncNSLSolver

async def main():
    async with AsyncNSLSolver("your-api-key") as solver:
        result = await solver.solve_turnstile(
            site_key="0x4AAAAAAAB...",
            url="https://example.com",
        )
        print(result.token)

asyncio.run(main())

Error Handling

from nslsolver import (
    NSLSolver,
    AuthenticationError,
    InsufficientBalanceError,
    RateLimitError,
    SolveError,
    NSLSolverError,
)

solver = NSLSolver("your-api-key")

try:
    result = solver.solve_turnstile(
        site_key="0x4AAAAAAAB...",
        url="https://example.com",
    )
except AuthenticationError:
    print("Bad API key.")
except InsufficientBalanceError:
    print("Top up your balance.")
except RateLimitError:
    print("Rate limited after all retries.")
except SolveError as e:
    print(f"Solve failed: {e.message}")
except NSLSolverError as e:
    print(f"API error (HTTP {e.status_code}): {e.message}")

Rate-limit (429) and backend (503) errors are retried automatically with exponential backoff before raising.

Configuration

solver = NSLSolver(
    api_key="your-api-key",
    base_url="https://api.nslsolver.com",  # default
    timeout=120,       # seconds (default: 120)
    max_retries=3,     # retries for 429/503 (default: 3)
)

Both clients support context managers (with / async with) for session cleanup.

Requirements

  • Python 3.8+
  • requests (sync client)
  • aiohttp (async client, optional)

Documentation

For more information, check out the full documentation at https://docs.nslsolver.com

License

MIT

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

nslsolver-1.1.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nslsolver-1.1.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file nslsolver-1.1.0.tar.gz.

File metadata

  • Download URL: nslsolver-1.1.0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for nslsolver-1.1.0.tar.gz
Algorithm Hash digest
SHA256 f6797bb69038fc0618bb0e97048169eb6670e620887e7ee557bbd3b26a4bb961
MD5 1caa7742ccf673d93e59c841db2f6796
BLAKE2b-256 cbcefec916b5e090bb37dce539612649c8e421dfbfa3bb3105cee6b200c6c1da

See more details on using hashes here.

File details

Details for the file nslsolver-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: nslsolver-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for nslsolver-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2dec495a096d8c204d2e1812c20694c8ee8787fac5521610ce4a9c24b92b07e5
MD5 eca9dafe77b0e62fa79703a76b34bb1f
BLAKE2b-256 778e8c1b57d4abe7d9354b64b8b9ebf492d6939e31b5b340da34b49831afee6f

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