Skip to main content

sitesonar-client

Typed Python client for the SiteSonar v2 API, sync and async, generated from the API's OpenAPI schema (../openapi.json) by openapi-python-client. Every route is a module with sync, sync_detailed, asyncio and asyncio_detailed; bodies and responses are attrs classes, so mypy or pyright catches a misspelled field, a wrong enum value or an attribute the response doesn't have. Runtime: httpx and attrs.

Install

uv add sitesonar-client   # or: pip install sitesonar-client

Use

from sitesonar_client import connect, unwrap, wait_for_job
from sitesonar_client.api.leads import companies_search, leads_scrape
from sitesonar_client.models import CompanySearchRequest, LeadScrapeRequest, LeadScrapeResult

with connect("https://sonar.example.com", api_key) as sonar:  # no /v2
    page = unwrap(companies_search.sync_detailed(
        client=sonar,
        body=CompanySearchRequest(industry=["dentist"], city="Montreal", limit=25),
    ))
    for company in page.companies:
        print(company.name, company.email and company.email.value)

    job = unwrap(leads_scrape.sync_detailed(
        client=sonar, body=LeadScrapeRequest(industry="dentist", location="Laval")))
    done = wait_for_job(sonar, job.job_id, interval=3)
    if isinstance(done.result, LeadScrapeResult):
        print(len(done.result.leads))

Async is the same with asyncio_detailed, async with connect(...) and await wait_for_job_async(...).

  • unwrap(response) returns the parsed body, or raises SiteSonarError with status, code (the API's detail.error: rate_limited, fetch_failed, blocked_destination…; validation_failed for an invalid body) and body.
  • wait_for_job polls /v2/jobs/{id} and raises SiteSonarError (job_failed, job_timeout); job.result is a CrawlResult or a LeadScrapeResult.
  • Fields are snake_case in Python (review_count) and camelCase on the wire (reviewCount); unset optional fields stay out of the request body.

Responses are typed for scrape, crawl, jobs, the leads routes, company and people search, lookup, verdicts and usage. Other routes parse into a model whose fields live in .additional_properties until their response model is added to sitesonar/responses.py.

Develop

uv run --extra dev pytest        # helpers, against a mocked transport
uv run --extra dev mypy          # typing, including mistakes that must stay errors
uv run python generate.py        # regenerate after the schema changes
uv run python generate.py --check

generate.py replaces only the generated parts (api/, models/, client.py, errors.py, types.py); __init__.py and helpers.py are hand-written. The server's tests/test_python_client.py runs this client against the real app.

Metadata

Release files for sitesonar-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 sitesonar-client 0.1.0
File Size Uploaded
sitesonar_client-0.1.0.tar.gz 87.9 kB Details

Built distribution (wheel)

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

Total release size: 250.6 kB

Release files / sitesonar_client-0.1.0.tar.gz

Download URL sitesonar_client-0.1.0.tar.gz
Size 87.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5af746e132b6c5b59c23465e48b5ed969967d8496c616434b8af8b72c2a0a20a
BLAKE2b-256 checksum
How to use checksums
ac16fc157c16c73ca5a0f3ff8d76a9ff7e65add42d12a99ca124612662fb5c49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

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

Download URL sitesonar_client-0.1.0-py3-none-any.whl
Size 162.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8cfeebba4e0fc7c66fa53e00b370a3b62c39e7ca7ac8d6ae81ce572de505c10e
BLAKE2b-256 checksum
How to use checksums
63c3adc9f6ea543055fc87919802bbc3bcda5ba1c067015a4044098da9216ede
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.0 This release

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