Python SDK for the Data Ingestion API
Project description
Data Ingestion Python SDK
Overview
- Endpoints:
GET /healthz,POST /jobs,GET /jobs/{id} - Models: All requests/responses are strict Pydantic models
- Auth: Bearer token required
- Python: 3.11+
Install
- From PyPI (once published):
uv pip install data-ingestion-sdk
- From source (editable):
uv pip install -e ./sdk/python
Configuration
Provide a base URL and bearer token via env or explicitly.
- Required env vars for
SDKConfig.from_env():DATA_INGESTION_API_URL(orDATA_INGESTION_API_BASE_URL)DATA_INGESTION_API_TOKEN
from trelent_data_ingestion_sdk import SDKConfig
# From env (raises if missing)
cfg = SDKConfig.from_env()
# Or explicit
# cfg = SDKConfig(base_url="https://api.example.com", token="<bearer>")
Quickstart
from trelent_data_ingestion_sdk import (
SDKConfig, DataIngestionClient,
S3KeysConnector, S3PrefixConnector, UrlConnector,
BucketOutput, S3SignedUrlOutput, JobInput,
)
cfg = SDKConfig.from_env()
with DataIngestionClient(cfg) as client:
# Health check
print(client.healthz())
# Submit a job using S3 keys
job = JobInput(
connector=S3KeysConnector(type="s3", bucket_name="my-bucket", object_keys=["docs/a.pdf", "vids/b.mp4"]),
output=S3SignedUrlOutput(type="s3-signed-url", expires_minutes=60),
)
resp = client.submit_job(job)
print("submitted:", resp.job_id)
# Poll status (optionally include markdown bodies)
status = client.get_job_status(resp.job_id, exclude_markdown=False)
print(status.status)
Connectors
S3KeysConnector(type="s3"):bucket_name,object_keys: list[str]S3PrefixConnector(type="s3_prefix"):bucket_name,prefixUrlConnector(type="url"):urls: list[str]
Outputs
S3SignedUrlOutput:type="s3-signed-url",expires_minutesBucketOutput:type="bucket",bucket_name,prefix
API Methods
client.healthz() -> HealthzResponseclient.submit_job(JobInput) -> ProcessResponseclient.get_job_status(job_id, exclude_markdown=False) -> JobStatusResponse
Delivery payloads
- When status is Completed,
JobStatusResponse.deliverymaps input identifiers to one of:
Signed URLs
{
"docs/a.pdf": {
"images": {"<nanoid>": "https://signed.example/img1"},
"markdown_delivery": "https://signed.example/a.md",
"markdown": "# Document..."
}
}
Bucket pointers
{
"docs/a.pdf": {
"images": {"<nanoid>": {"bucket": "my-bucket", "key": "images/img1.png"}},
"markdown_delivery": {"bucket": "my-bucket", "key": "converted/a.md"},
"markdown": "# Document..."
}
}
Error handling
- Config validation:
ValueErrorif missingbase_urlortoken - HTTP errors:
httpx.HTTPStatusErroron non-2xx responses - Parsing:
pydantic.ValidationErroron invalid payloads
Development
- Build locally:
uv build --directory sdk/python
- Bump version, e.g. patch:
uv version --bump patch --directory sdk/python --no-sync
- Publish via the repo’s GitHub Action (PyPI Trusted Publisher), which builds with
uvand uploads artifacts.
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 data_ingestion_sdk-0.1.0.tar.gz.
File metadata
- Download URL: data_ingestion_sdk-0.1.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02d2067be7de4e229222665fd10e9353a4960ef8ade4859763ea2f0560ff0012
|
|
| MD5 |
ba3bbe4190bbacdee903e9fc1f9bf9fa
|
|
| BLAKE2b-256 |
d9597a1e40597299e61491e607aac3c62dfdbfdd9d441cb1a44ad0b319e2238e
|
File details
Details for the file data_ingestion_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: data_ingestion_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45088e1bce817cfc26a3beace86dd4993a9dce50a2133bd7e9fd356e2528eeac
|
|
| MD5 |
81bb6f648a3f2ddc7a202a419d737cfe
|
|
| BLAKE2b-256 |
eb2a5d246df1ef9c41d52a65d93d880f7e5a11291bd90221fed5bb46ccd5b963
|