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
Metadata
Release files for api-to-dataframe 2.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| api_to_dataframe-2.2.2.tar.gz | 4.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| api_to_dataframe-2.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.5 kB
Release files / api_to_dataframe-2.2.2.tar.gz
| Download URL | api_to_dataframe-2.2.2.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5721cd24a7c0e0b160e346666384450605abcf069023a1b51992b19a179bd614
|
|
BLAKE2b-256 checksum How to use checksums |
90e258eb7ee8f1797f3fe7bff464f3865f960b25c0f64fd81cb6a678f9582270
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.10.21 Linux/6.17.0-1022-azure
|
Release files / api_to_dataframe-2.2.2-py3-none-any.whl
| Download URL | api_to_dataframe-2.2.2-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6a95a01df7bf7b42c06d31adce3668023d26f1e07d21e0f9557b3a2a6e34323d
|
|
BLAKE2b-256 checksum How to use checksums |
d577559b9e38a20e663205efb5c21f3f24638d7eff16184a174d1d40b15ef8aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.10.21 Linux/6.17.0-1022-azure
|