tenor-api-client
Python client for the Tenor Trading API: quotes and ready-to-sign payloads for lending and borrowing on Tenor, at a fixed or a variable rate. Tenor never signs, sends or holds a key.
pip install tenor-api-client
Python 3.11+. Sync and async.
Usage
from tenor_api_client import Tenor
with Tenor(api_key="tnr_sk_live_…") as tenor:
market = tenor.list_markets(chain_id=8453).data[0]
maturity = tenor.list_market_maturities(market.market_id, chain_id=8453).data[0]
quote = tenor.get_quote(body={
"chain_id": 8453,
"maturity_id": maturity.maturity_id,
"action": "lend",
"size": {"principal": "1000000"}, # 1 USDC, in the token's smallest unit
})
print(quote.data.rate)
- There is one method per API operation, named after it:
get_quote,prepare_lend,list_positions, …. - Path parameters come first. Query parameters are keywords.
- A body is a model from
tenor_api_client.modelsor a dict in the API's format. - Every method returns a model with
dataandmeta.metaholdsrequest_idand, on paged lists,next_cursor. - Fields this client doesn't know yet are kept in
additional_properties. - Amounts and rates are strings, as on the wire.
import asyncio
from tenor_api_client import AsyncTenor
async def main() -> None:
async with AsyncTenor() as tenor:
chains = await tenor.list_chains()
asyncio.run(main())
Configuration
Tenor(
api_key="tnr_sk_live_…", # defaults to $TENOR_API_KEY; reads and quotes work without one
timeout=30.0, # per attempt, in seconds
max_retries=2, # 429 (after Retry-After), 502, 503, 504 and network errors
headers={"X-Request-Id": "my-trace-id"},
)
Errors
from tenor_api_client import TenorApiError
try:
tenor.prepare_lend(body={...})
except TenorApiError as e:
e.status # 422
e.code # "INSUFFICIENT_LIQUIDITY"
e.treatment # "fix_request" | "refetch_state" | "fund_account" | "retry"
e.details # as sent by the API
e.request_id # quote it when you contact us
Branch on code, and fall back on treatment for codes you don't know. Network failures and timeouts raise TenorConnectionError.
Development
The client is generated from openapi/trading-api.json by uv run python scripts/generate.py. The output is git-ignored:
src/tenor_api_client/_generated/: models and one module per endpoint, from openapi-python-client. The settings are inopenapi-python-client.yaml.src/tenor_api_client/client.py:TenorandAsyncTenor. The script reads the generated endpoint modules and writes one method per endpoint.
templates/literal_enum.py.jinja overrides one generator template so that an enum value added to the API later is accepted rather than raising. _base.py (config, auth, retries) and errors.py are written by hand.
uv sync
uv run python scripts/generate.py
uv run pytest # unit tests
uv run pytest -m live # read-only calls against prod
uv run pyright && uv run ruff check .
Metadata
Release files for tenor-api-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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tenor_api_client-0.1.0.tar.gz | 203.6 kB | Without provenance | Details for tenor_api_client-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tenor_api_client-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for tenor_api_client-0.1.0-py3-none-any.whl |
Total release size: 669.6 kB
Release files / tenor_api_client-0.1.0.tar.gz
| Download URL | tenor_api_client-0.1.0.tar.gz |
|---|---|
| Size | 203.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2290889c4bf7d626930c8ab85c3141f723048025010f6f388e7f2816a9102603
|
|
BLAKE2b-256 checksum How to use checksums |
c4852407305001ac39032545d82bbe73d277161601cbf5b40401a1f5d4054798
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / tenor_api_client-0.1.0-py3-none-any.whl
| Download URL | tenor_api_client-0.1.0-py3-none-any.whl |
|---|---|
| Size | 466.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
795d3bb081f212a6a46fc6edd3cd10dbac0246446d25343c4849a8bb8360645e
|
|
BLAKE2b-256 checksum How to use checksums |
00a8850e3b716c149f5c54a57e6178fefc4cc5b681da42cc795a8d2f4320109b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for tenor-api-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.