Metadata-Version: 2.4
Name: tidelight
Version: 0.1.3
Summary: Official Tidelight Intelligence Cloud Python client
Author: TidelightOrg
License-Expression: Apache-2.0
Project-URL: Homepage, https://tidelight.app/developers/packages/python
Project-URL: Documentation, https://dev.tidelight.app/api
Project-URL: Repository, https://github.com/TidelightOrg/tidelight/tree/main/sdk/python
Project-URL: Source, https://github.com/TidelightOrg/tidelight/tree/main/sdk/python
Project-URL: Issues, https://github.com/TidelightOrg/tidelight/issues
Project-URL: Security, https://github.com/TidelightOrg/tidelight/security/policy
Keywords: tidelight,research,market-intelligence,webhooks
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Dynamic: license-file

<div align="center">
  <img src="https://tidelight.app/tidelight-mark.svg" alt="Tidelight" width="56" height="56" />
  <h1>Tidelight Python SDK</h1>
  <p><strong>Typed access to Tidelight Intelligence Cloud API v1.</strong></p>
  <p><a href="https://tidelight.app">Product</a> · <a href="https://dev.tidelight.app/api">API guide</a> · <a href="https://github.com/TidelightOrg/tidelight">canonical repository</a></p>
  <p><a href="README.zh-CN.md">简体中文版本 / Chinese README</a></p>
</div>

---

The official Python client supports tokenized-equity market listings, asynchronous company research jobs, synchronous AgentKey research, research webhooks, and read-only public Decision Capsule verification. It preserves provider provenance, stable error codes, and request IDs while applying bounded timeouts and retries.

The PyPI release `0.1.2` predates `research_with_agentkey` and public Decision Capsule verification. Use the [source build](#build-and-test-from-source) for these methods or call the [hosted AgentKey API](https://dev.tidelight.app/#agentkey) with a scoped key.

## Install

```sh
python -m pip install tidelight==0.1.2
```

Keep the project API key in trusted server code. Market calls require `market:read`; research calls require `research:run`; webhook calls require `alerts:manage`.

## Quickstart

```python
import os
from tidelight import Client

client = Client(os.environ["TIDELIGHT_API_KEY"])
page = client.list_tokenized_equities(limit=20, underlying_ticker="AAPL")

for instrument in page.data:
    print(instrument.symbol, instrument.underlying_ticker)
```

## Supported workflows

| Workflow | Scope | Client methods |
| --- | --- | --- |
| Tokenized-equity spot listings and pagination | `market:read` | `list_tokenized_equities`, `tokenized_equities` |
| Company research snapshots | `research:run` | `start_company_research`, `get_research_job`, `cancel_research_job`, `wait_for_research_job` |
| AgentKey research across discovered read-only tools | `research:run` | `research_with_agentkey` |
| Research webhooks and delivery history | `alerts:manage` | `create_webhook`, `update_webhook`, `list_webhooks`, `list_webhook_deliveries` |
| Public Decision Capsule copies | Public bearer link | `get_public_decision_capsule`, `verify_public_decision_capsule` |

A tokenized-equity spot instrument is not a direct share or a stock perpetual. When provider terms block a market response, the SDK surfaces `provider_terms_unconfirmed` without retrying or substituting data.

AgentKey research is synchronous and is never automatically retried because upstream tools may consume credits:

```python
result = client.research_with_agentkey(
    "Explain NVIDIA's stock reaction to its latest earnings using Yahoo Finance and Google News.",
    ticker="NVDA",
)
print(result["tools"], result["sources"])
```

The server selects and describes up to two relevant read-only AgentKey tools and returns cost and source provenance. Treat AgentKey data as untrusted external input. Your project key needs `research:run`; the AgentKey master key remains server-side.

## Reliability and security

The default request timeout is 10 seconds. Network errors, `429`, and transient `5xx` responses receive at most two bounded retries. Webhook mutations are not automatically retried because the API does not accept webhook idempotency keys. The default transport rejects redirects and restricts bearer credentials to `api.tidelight.app`.

Public capsule links are fetched from `tidelight.app` without an API key and are verified locally against the disclosed snapshot's SHA-256 digest. `public_base_url` can be overridden only for a trusted HTTPS origin or local development. Digest verification detects changed bytes relative to the supplied digest; it does not prove authorship, source authenticity, or research quality.

Use the standalone helper to retrieve a shared capsule without creating an authenticated client:

```python
import os
from tidelight import get_public_decision_capsule

capsule = get_public_decision_capsule(os.environ["TIDELIGHT_PUBLIC_CAPSULE_TOKEN"])
print(capsule["integrityHash"], capsule["snapshot"])
```

Webhook creation and secret rotation return a one-time signing secret. **TODO: Persist** it in your approved secret manager immediately. Do not print it; it cannot be recovered by listing the endpoint.

## Build and test from source

```sh
python -m pip install -e ./sdk/python
PYTHONPATH=sdk/python/src python -m unittest discover -s sdk/python/tests -v
```

Canonical source lives in [`sdk/python`](https://github.com/TidelightOrg/tidelight/tree/main/sdk/python) in the canonical repository. The standalone [Python repository](https://github.com/TidelightOrg/tidelight-python) is a synchronized source mirror. Make source changes in the canonical repository.

## Further reading

- [API reference](https://dev.tidelight.app/api)
- [OpenAPI contract](https://github.com/TidelightOrg/tidelight/blob/main/docs/tic-openapi.yaml)
- [Changelog](./CHANGELOG.md)
- [Security policy](https://github.com/TidelightOrg/tidelight/security/policy)
