A package to convert API responses to pandas dataframe
Project description
API to DataFrame
Fetch JSON from any HTTP API and turn it into a pandas DataFrame in two calls — with optional retry strategies.
Install
pip install api-to-dataframe
# or
poetry add api-to-dataframe
Requires Python 3.10+.
Quick start
from api_to_dataframe import ClientBuilder, RetryStrategies
client = ClientBuilder(endpoint="https://api.example.com/items")
data = client.get_api_data()
df = client.api_to_dataframe(data)
api_to_dataframe expects the response to be a list of dicts. An empty result raises ValueError.
Configuration
client = ClientBuilder(
endpoint="https://api.example.com/items",
headers={"Authorization": "Bearer ..."},
retry_strategy=RetryStrategies.EXPONENTIAL_RETRY_STRATEGY,
retries=5,
initial_delay=2,
connection_timeout=10,
)
| Parameter | Default | Description |
|---|---|---|
endpoint |
— (required) | Target URL. |
headers |
None |
Request headers. |
retry_strategy |
NO_RETRY_STRATEGY |
See strategies below. |
retries |
3 |
Max attempts. Hard-capped at 5. |
initial_delay |
1 |
Base delay in seconds between retries. |
connection_timeout |
10 |
Per-request timeout in seconds. |
Retry strategies
NO_RETRY_STRATEGY— fail fast on the first error.LINEAR_RETRY_STRATEGY— waitinitial_delayseconds before each retry.EXPONENTIAL_RETRY_STRATEGY— waitinitial_delay * retry_numberseconds before each retry.
Retries are capped at 5 regardless of the retries value.
Links
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 api_to_dataframe-2.2.0.tar.gz.
File metadata
- Download URL: api_to_dataframe-2.2.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.20 Linux/6.17.0-1010-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
424946c43fa0a7cc5fbb3a8a46526ea56f582bcf8feba6037729b313a3fea32e
|
|
| MD5 |
5a173bdfd7ac821412c21a8d437b208f
|
|
| BLAKE2b-256 |
676b6b6a8437d8286a13956f538a78a78dbfd3297887a60ab5089219aaaec1a3
|
File details
Details for the file api_to_dataframe-2.2.0-py3-none-any.whl.
File metadata
- Download URL: api_to_dataframe-2.2.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.20 Linux/6.17.0-1010-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94691816912d0b6a1d1ef8712b807337ac1daceeb18c2e1a89755179b0521d91
|
|
| MD5 |
1be3f1f64e8e4a172b6cf29b5b53c75a
|
|
| BLAKE2b-256 |
8eff67a7e718fb69e83a6478a9bb4dbe45e0f0a0c086f1fba6b12e4ae1220528
|