Skip to main content

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

# Standard REST client
pip install dataflare-sdk

# Include gRPC support
pip install "dataflare-sdk[grpc]"

Authentication

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

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 category: {doc.category} | Title: {doc.title} | Summary: {doc.summary} | Decision: {doc.decision}")
            
            # Helper to download the raw File 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.")

High-Performance gRPC Client

For environments requiring persistent connections and reduced latency, the SDK provides a dynamic gRPC client that works right out of the box using Server Reflection.

from df import DFGRPCClient, AuthenticationError

# Requires installing extra dependencies: pip install dataflare-sdk[grpc]
try:
    with DFGRPCClient() as client:
        # Perform unary RPC instead of REST natively
        results, next_cursor = client.datasets.query(
            dataset="legal", 
            limit=10,
        )
        
        for doc in results:
            print(f"Title: {getattr(doc, 'title', None)} | Summary: {getattr(doc, 'summary', None)}")

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

🛡️ License

MIT — see the root LICENSE file for full terms.

Note: The SDK is free and open source. Dataflare API access requires a paid subscription. See dataflare.com/developers.

Metadata

Release files for dataflare-sdk 0.1.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dataflare-sdk 0.1.10
File Size Uploaded Provenance Actions
dataflare_sdk-0.1.10.tar.gz 9.8 kB Without provenance Details for dataflare_sdk-0.1.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dataflare-sdk 0.1.10
File Interpreter ABI Platform Actions
dataflare_sdk-0.1.10-py3-none-any.whl Python 3 none any Details for dataflare_sdk-0.1.10-py3-none-any.whl

Total release size: 22.8 kB

Release files / dataflare_sdk-0.1.10.tar.gz

Download URL dataflare_sdk-0.1.10.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
444e1dd2ae48164ac5b5c5bb587aec784ae6cbe6a9c83d4ab9f6e522469fc117
BLAKE2b-256 checksum
How to use checksums
4047ed8d6d62c35b30e3a3a5709bd54e9cfb0791dc46dd8cfde6d27ae10df91c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / dataflare_sdk-0.1.10-py3-none-any.whl

Download URL dataflare_sdk-0.1.10-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
36de786addbcecc2ead60a1b2e785b2e27aca746e4c5d5d2dc72cf888065583c
BLAKE2b-256 checksum
How to use checksums
fa72634e5784441319bad6171423f29cbe09cc00abdc1a5b8a6a2f85dd8823cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for dataflare-sdk 0.1.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page