Skip to main content

Official Python SDK for the DataFlare API

Project description

DF API Python SDK <a href="https://pypi.org/project/dataflare-sdk/"><img alt="PyPI" src="https://img.shields.io/pypi/v/dataflare-sdk?color=blue"></a>

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

Quick Start

You will need a DataFlare API Key. The easiest way is setting an environment variable:

export DF_API_KEY="dfk_abc123"
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.0.tar.gz (5.4 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.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dataflare_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for dataflare_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e33b662cb3e8f8a5e8736825b50b86b141635d44e9de6a73993b93edc1794685
MD5 87ff4bb98059233b498e999bd2344c17
BLAKE2b-256 d2b681dcc02e8f297d609957e715d95d51fa7800c156017bee424a3219521f82

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dataflare_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for dataflare_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c43d4e2e2cb4758dea5d7ab2092c1004a3ca2ec1d3372f22fa63266d1e7d69e6
MD5 089d242d6b1ac42d91ee3abb27a06571
BLAKE2b-256 dee9b9740f199a4181b56acf889ca662a51f0f4429f38fc93867797b1ffd142b

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