Dateno Python SDK — Usage & Examples
Overview
This document provides practical examples of using the Dateno Python SDK to interact with the Dateno API.
All SDK responses are returned as Pydantic models.
Creating an SDK Client
Synchronous client
from dateno import SDK
with SDK(api_key_query="YOUR_API_KEY") as sdk:
# use sdk here
pass
Asynchronous client
import asyncio
from dateno import SDK
async def main():
async with SDK(api_key_query="YOUR_API_KEY") as sdk:
pass
asyncio.run(main())
Working with Data Catalogs
Get a catalog by ID
from dateno import SDK
with SDK(api_key_query="YOUR_API_KEY") as sdk:
catalog = sdk.data_catalogs_api.get_catalog_by_id(
catalog_id="cdi00001616"
)
print(catalog)
Async version
catalog = await sdk.data_catalogs_api.get_catalog_by_id_async(
catalog_id="cdi00001616"
)
Searching Datasets
Simple search
from dateno import SDK
with SDK(api_key_query="YOUR_API_KEY") as sdk:
resp = sdk.search_api.search_datasets(
q="environment",
limit=20,
offset=0,
)
for hit in resp.hits.hits:
print(hit.id, hit.source.dataset.title)
Pagination & Limits
⚠️ Important
For dataset search endpoints, the API enforces:
- Maximum
limit= 500 - Values greater than
500are silently clamped
Correct pagination example
PAGE_SIZE = 500
offset = 0
with SDK(api_key_query="YOUR_API_KEY") as sdk:
while True:
resp = sdk.search_api.search_datasets(
q="economy",
limit=PAGE_SIZE,
offset=offset,
)
hits = resp.hits.hits
if not hits:
break
for hit in hits:
print(hit.id)
offset += PAGE_SIZE
Working with Service Endpoints
Health check
from dateno import SDK
with SDK(api_key_query="YOUR_API_KEY") as sdk:
health = sdk.service.get_healthz()
print(health)
Error Handling
All SDK-level errors inherit from SDKError.
from dateno import SDK, errors
try:
with SDK(api_key_query="YOUR_API_KEY") as sdk:
sdk.service.get_healthz()
except errors.SDKError as exc:
print("SDK error:", exc)
Async vs Sync — When to Use Which
-
Sync:
- Scripts
- CLI tools
- Simple integrations
-
Async:
- Web services (FastAPI, aiohttp)
- High-concurrency workloads
- Batch processing