A modern Python client for the Odos DEX Aggregator API
Project description
odos-py
A modern, fully-typed Python client for the Odos DEX Aggregator API.
- Sync (
OdosClient) and async (AsyncOdosClient) clients built onhttpx pydanticv2 models for all requests and responses- Automatic HTTP 429 handling with exponential backoff
- Configurable base URL and API-key header
mypy --strictclean, ships apy.typedmarker
Install
pip install odos-py
Optional extra for signing/sending the assembled transaction with web3.py:
pip install "odos-py[exec]"
Quickstart
Odos works in two steps: quote returns a pathId, then assemble turns that
pathId into ready-to-sign transaction calldata. The swap() helper chains
both:
from odos_py import OdosClient, QuoteRequest, InputToken, OutputToken
client = OdosClient(api_key="YOUR_KEY") # api_key optional but recommended
quote, assembled = client.swap(QuoteRequest(
chain_id=1,
input_tokens=[InputToken(token_address="0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", # WETH
amount="1000000000000000000")], # 1 WETH (wei)
output_tokens=[OutputToken(token_address="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", # USDC
proportion=1)],
user_addr="0x47E2D28169738039755586743E2dfCF3bd643f86",
slippage_limit_percent=0.3,
))
print(quote.path_id, assembled.transaction.to)
Async is identical with await:
import asyncio
from odos_py import AsyncOdosClient
async def main(request):
async with AsyncOdosClient() as client:
quote = await client.quote(request)
print(quote.path_id)
Auth & rate limits
There is a free, keyless tier, but it is heavily rate limited — POST /sor/quote/v2 returns HTTP 429 quickly without a key. Pass an api_key to
raise limits. The exact API-key header name is not publicly documented, so it
is configurable:
OdosClient(api_key="YOUR_KEY", api_key_header="x-api-key") # default header name
The client retries 429 responses with exponential backoff (honouring any
Retry-After header) and raises OdosRateLimitError once retries are
exhausted. Tune with max_retries and backoff_base.
Endpoints
| Method | Endpoint |
|---|---|
quote(request) |
POST /sor/quote/v2 |
assemble(user_addr=, path_id=) |
POST /sor/assemble |
execute(user_addr=, path_id=) |
POST /sor/execute |
swap(request) / quote_and_assemble(request) |
quote then assemble |
get_chains() |
GET /info/chains |
get_tokens(chain_id) |
GET /info/tokens/{chainId} |
get_router(chain_id) |
GET /info/router/v2/{chainId} |
get_contract_info(chain_id) |
GET /info/contract-info/v2/{chainId} |
get_token_price(chain_id, token_address) |
GET /pricing/token/{chainId}/{tokenAddress} |
Multi-chain is handled per call via chain_id on QuoteRequest and the info
endpoints.
Configuration
OdosClient(
base_url="https://api.odos.xyz", # configurable / proxyable
api_key=None,
api_key_header="x-api-key",
max_retries=3,
backoff_base=0.5,
timeout=30.0,
)
Development
pip install -e ".[dev,exec]"
pytest # unit tests (HTTP mocked, no network)
pytest -m integration # live smoke test against /info/chains
ruff check .
mypy
License
MIT
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 odos_py-0.1.0.tar.gz.
File metadata
- Download URL: odos_py-0.1.0.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d000f21fbaad58186c7143ce6d15d0065f6c92c8b1d5292211573b933bddae9b
|
|
| MD5 |
36507fcef6563367c3204fb2c54721d4
|
|
| BLAKE2b-256 |
b98f13f4fa2c93761854bbde223407e7194dad183fb919e7668dfdfa6461559e
|
File details
Details for the file odos_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: odos_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
384397fcee61b96c30d16fed2e30b30a467bf301ca4cedbaaef36a03223a3f75
|
|
| MD5 |
0e66b364cce95c03ae7d51b4211c53c6
|
|
| BLAKE2b-256 |
d72aab88737df73760ee8a8b6609e31d0845b27c752fc7d6ae7630fda679cfa8
|