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.1
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.1.tar.gz | 4.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| api_to_dataframe-2.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.4 kB
Release files / api_to_dataframe-2.2.1.tar.gz
| Download URL | api_to_dataframe-2.2.1.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1d5fa3d1db29b9b91b5f4227f26fb1062e93d8e509bf61cf06de7fbb0ade8bd9
|
|
BLAKE2b-256 checksum How to use checksums |
34c6ba05c9cffad80ca7700c74b35cc2b37145b51734d6e70111787c358f164e
|
| 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.1-py3-none-any.whl
| Download URL | api_to_dataframe-2.2.1-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eefa96840b8ffc1a3ee037a86bc5582c1ccdb9431d28d768df4c798e1c1391e5
|
|
BLAKE2b-256 checksum How to use checksums |
7dbb4929422d73f26e5c7bd8c71e09ee9d90f7766e5f1d22eda39ff346a39d2f
|
| 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
|