Python SDK for the Trelent 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 (used by default when you instantiate
DataIngestionClient()):DATA_INGESTION_API_URL(orDATA_INGESTION_API_BASE_URL) orTRELENT_DATA_INGESTION_API_URL(orTRELENT_DATA_INGESTION_API_BASE_URL)DATA_INGESTION_API_TOKENorTRELENT_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,
)
with DataIngestionClient() 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, include_markdown=False)
print(status.status)
If you need to override the environment at runtime, you can either pass an explicit SDKConfig or supply credentials directly to the client:
cfg = SDKConfig(base_url="https://api.example.com", token="<bearer>")
client = DataIngestionClient(cfg)
client = DataIngestionClient(base_url="https://api.example.com", token="<bearer>")
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, include_markdown=False) -> JobStatusResponseclient.generate_token(GenerateTokenRequest) -> GenerateTokenResponseclient.upload_file(file_data, filename, content_type, expires_in_days) -> FileUploadResponseclient.list_files() -> FileListResponse
Token Generation
Generate scoped JWT tokens for delegated access:
from trelent_data_ingestion_sdk import (
DataIngestionClient, GenerateTokenRequest, TokenPermission
)
with DataIngestionClient() as client:
req = GenerateTokenRequest(
subject="user@example.com",
permissions={TokenPermission.WORKFLOW_DOCUMENT, TokenPermission.FILE_UPLOAD},
expires_seconds=3600,
)
resp = client.generate_token(req)
print(resp.token)
Available permissions:
TokenPermission.WORKFLOW_VIDEO- Run video processing workflowsTokenPermission.WORKFLOW_DOCUMENT- Run document processing workflowsTokenPermission.FILE_UPLOAD- Upload files via /v1/files/
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:
requests.HTTPErroron 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.4.17.tar.gz.
File metadata
- Download URL: data_ingestion_sdk-0.4.17.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94ccc3c354c2c6c9dfebbb9c6ea9368d2b0005cbeaa6341e60c981a7eae27788
|
|
| MD5 |
2851e5b8bbed31a73abee63ded749b8d
|
|
| BLAKE2b-256 |
db4d47001bcce54011e8b347427a146ea7242b28066ab3d5ad1f281db4330d9c
|
File details
Details for the file data_ingestion_sdk-0.4.17-py3-none-any.whl.
File metadata
- Download URL: data_ingestion_sdk-0.4.17-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3261d4dd96d1783d02f836d2d99b199c645333cdda11eca0fd4d2a8aeef1e73
|
|
| MD5 |
ddb1b93a3039ab9d99d6f8a69c122839
|
|
| BLAKE2b-256 |
44d2ee961f73aa18d8d111fb12687a69da092bdce32ffa89fa0e3c418bf146d1
|