Official Python SDK for the DataFlare API
Project description
DF API Python SDK 
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
httpxlogic 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:
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 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.
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 dataflare_sdk-0.1.7.tar.gz.
File metadata
- Download URL: dataflare_sdk-0.1.7.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a1c02e56465605247a77bb50ea65fb5117390ad35b01b9b1c68cb497150609c
|
|
| MD5 |
31eebfc01154b2221c80e625767cfdc8
|
|
| BLAKE2b-256 |
d09d5d540fd52b4e525e647561813263a143a97011fff300cdd0eed1a0793d07
|
File details
Details for the file dataflare_sdk-0.1.7-py3-none-any.whl.
File metadata
- Download URL: dataflare_sdk-0.1.7-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23c2b5599330c52e52dbe04db2df1ac61fe64544b791082537d9bc4fcdbed4da
|
|
| MD5 |
aa0ed6e7d64f6f3d5f870a03ee17409f
|
|
| BLAKE2b-256 |
9371a3ea8a2b7a72f21c5855bf208f8c8467696d6017ef1eabd227469af67bb8
|