Python client, CLI, and MCP server for The Trade Desk's OpenSincera advertising-metadata API
Project description
opensincera-python
Unofficial Python client, CLI, and MCP server for The Trade Desk's OpenSincera advertising-metadata API. Not affiliated with The Trade Desk.
Status
Early development. v0.1.0 ships a sync library + CLI; v0.2.0 adds an MCP server; v0.3.0 adds an async batch verb. See CHANGELOG.md for what's landed.
Installation
pip install opensincera-python
The distribution is opensincera-python; the import is opensincera.
Configuration
The library and CLI read the API key from the OPENSINCERA_API_KEY environment variable. Using direnv with a gitignored .envrc is the recommended local pattern — never commit .env files.
export OPENSINCERA_API_KEY="..."
The CLI also accepts --api-key TOKEN for ad-hoc overrides.
Quickstart — library
import opensincera
with opensincera.Client(api_key="...") as client:
pub = client.get_publisher_by_domain("nytimes.com")
print(pub.publisher_id, pub.name, pub.domain)
# 75 NY Times nytimes.com
# Look up by ID
same = client.get_publisher_by_id(75)
Client honors Retry-After on 429 with capped exponential-backoff fallback (3 attempts by default — max_retry_attempts is configurable). All errors derive from opensincera.OpenSinceraError; specific subclasses cover auth, not-found, rate-limit (with retry_after), server, and timeout cases.
Quickstart — CLI
opensincera get nytimes.com
Default format is a Rich table on a TTY, JSON when piped. The full publisher record looks like:
{
"publisher_id": 75,
"name": "NY Times",
"domain": "nytimes.com",
"visit_enabled": true,
"status": "available",
"primary_supply_type": "web",
"categories": null,
"avg_ads_to_content_ratio": 0.14832,
"avg_ads_in_view": 0.50104,
"avg_ad_refresh": null,
"device_level_metrics": {
"mobile": { "avg_ad_units_in_view": 0.41351, "avg_ads_to_content_ratio": 0.15914, "...": "..." },
"desktop": { "avg_ad_units_in_view": 0.58246, "avg_ads_to_content_ratio": 0.13825, "...": "..." }
},
"total_supply_paths": 30,
"owner_domain": "nytimes.com",
"...": "..."
}
Project to just the fields you care about — repeat --field to add more:
opensincera get nytimes.com --field publisher_id --field status
# {"publisher_id": 75, "status": "available"}
Drill into a single device-metrics block (identifier fields are always preserved):
opensincera get nytimes.com --device mobile --format json
# { "publisher_id": 75, "name": "NY Times", "domain": "nytimes.com",
# "avg_ad_units_in_view": 0.41351, "avg_ads_to_content_ratio": 0.15914, ... }
Look up by publisher ID instead of domain:
opensincera get --id 75
Other useful flags: --format json|csv|table, --timeout SECONDS, --version, --install-completion. Run opensincera get --help for the full list.
Development
uv sync --all-groups # install runtime + dev deps
uv run pre-commit install # one-time, enables the local git hook
uv run pytest # run the test suite
uv run pre-commit run --all-files
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opensincera_python-0.1.0.tar.gz.
File metadata
- Download URL: opensincera_python-0.1.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d372eb733dfac2578ada871e0f06930c124b2cd0ab31c835f798408ca2d26ad
|
|
| MD5 |
76095b3183b8718e2a55c3ebe32f9f24
|
|
| BLAKE2b-256 |
a0f6d4b9b93a6f49785cdadc34057a1b054579e33ed9fad379f3fb915ba117a1
|
File details
Details for the file opensincera_python-0.1.0-py3-none-any.whl.
File metadata
- Download URL: opensincera_python-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54c85297d49a250513f9bcdb48f2fa11a7be7050717b28f266b8521df763e5af
|
|
| MD5 |
d490f1d3ccab6c95af223306cf24c63d
|
|
| BLAKE2b-256 |
c4875e8ed3714b9c401d0fb5ffeff5c060654c4fde2f45f46d1873ddd1bbee40
|