Skip to main content

Official Python SDK for the DataFlare API

Project description

DF API Python SDK PyPI

The official Python SDK for the DataFlare API.

Features

  • Typed Models: Full Pydantic schemas mapping the Datasets API for rigid IDE autocompletion.
  • Connection Pools: Subclass optimized httpx logic reusing TCP connections seamlessly.
  • Resilient Requests: Automated retries (tenacity) wrapping Rate Limit and transient network faults over exponential backoffs.
  • Idiomatic Paginators: client.datasets.stream(...) automatically handles cursor injection iteratively returning stream chunks cleanly.
  • Memory-safe Source Retrieval: For pipelines feeding Large Language Models directly from data archives, effortlessly invoke download_file(...) natively chunking raw bytes down to the file system avoiding memory leaks.

Installation

pip install dataflare-sdk

Authentication

You will need a DataFlare API Key. The SDK provides two ways to configure it securely:

1. Auto-discover from Environment (Recommended)

Set the DF_API_KEY system environment variable (or load it from a local .env using python-dotenv):

export DF_API_KEY="dfk_abc123"

2. Direct Explicit Injection

If you pull secrets from an external vault, pass it directly into the constructor:

from df import DFClient
client = DFClient(api_key="dfk_your_secret_key...")

Quick Start

from df import DFClient, AuthenticationError

# Automatically discovers DF_API_KEY from the environment
try:
    with DFClient() as client:
        
        # Generator handles pagination constraints completely
        for doc in client.datasets.stream("legal", search_term="التأمين", limit=100):
            print(f"Doc ID: {doc.id} | Metadata: {doc.metadata}")
            
            # Helper to download the raw PDF to disk natively
            if doc.source_url:
                client.datasets.download_file(
                    doc.source_url, 
                    destination=f"./archives/{doc.id}.pdf"
                )

except AuthenticationError:
    print("Invalid API Key.")

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

dataflare_sdk-0.1.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

dataflare_sdk-0.1.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file dataflare_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: dataflare_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dataflare_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2be26e92b9c83ae6369c5f401a95f5ee9ea8b03651294a88d88fe4bc13b0e109
MD5 a0318cab564d4aafd74ac3dcfeab4c2f
BLAKE2b-256 1fc37ff4c3e358dcc6ec3652575b710321ff4e6fa9d630dd9ae0fa5d3cc7ddf9

See more details on using hashes here.

File details

Details for the file dataflare_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: dataflare_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dataflare_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ff4e6b6f90e3b201372375efa3a406441cea945d85dc1d6cb6bf35a6a055659f
MD5 39707a039a59ac12edcf2862f847dd4b
BLAKE2b-256 72465c50af9ddb9e44c0980e4a7524e09f73704950238e722d21350ee430e781

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