Skip to main content

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 (or DATA_INGESTION_API_BASE_URL) or TRELENT_DATA_INGESTION_API_URL (or TRELENT_DATA_INGESTION_API_BASE_URL)
    • DATA_INGESTION_API_TOKEN or TRELENT_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, prefix
  • UrlConnector (type="url"): urls: list[str]

Outputs

  • S3SignedUrlOutput: type="s3-signed-url", expires_minutes
  • BucketOutput: type="bucket", bucket_name, prefix

API Methods

  • client.healthz() -> HealthzResponse
  • client.submit_job(JobInput) -> ProcessResponse
  • client.get_job_status(job_id, include_markdown=False) -> JobStatusResponse

Delivery payloads

  • When status is Completed, JobStatusResponse.delivery maps 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: ValueError if missing base_url or token
  • HTTP errors: requests.HTTPError on non-2xx responses
  • Parsing: pydantic.ValidationError on 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 uv and uploads artifacts.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

data_ingestion_sdk-0.4.15.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

data_ingestion_sdk-0.4.15-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file data_ingestion_sdk-0.4.15.tar.gz.

File metadata

  • Download URL: data_ingestion_sdk-0.4.15.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","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

Hashes for data_ingestion_sdk-0.4.15.tar.gz
Algorithm Hash digest
SHA256 34af74a34a01f972c1df2210232101cda16a4a0747d8c1e508a06e11a0e72337
MD5 34b696ff6751983ae2b284ed3a4810e2
BLAKE2b-256 bec76bbfda587df10ca320a05a0c70015c7bedf4bf17a6087428da38d7b26942

See more details on using hashes here.

File details

Details for the file data_ingestion_sdk-0.4.15-py3-none-any.whl.

File metadata

  • Download URL: data_ingestion_sdk-0.4.15-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","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

Hashes for data_ingestion_sdk-0.4.15-py3-none-any.whl
Algorithm Hash digest
SHA256 08a9583df1a3fb757e2d6853a1a6735d0aa441aa25464a580ebfa03721e759c0
MD5 f10687ab3d578116a1b25b1b6b652bfd
BLAKE2b-256 c3e62c7fed9f5c76e75e5c3241324ab4b66472a30895ff3cc4cd18bdd7dd1c9b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page