A package to convert API responses to pandas dataframe
Project description
API to DataFrame
Python library that simplifies obtaining data from API endpoints by converting them directly into Pandas DataFrames. This library offers robust features, including retry strategies for failed requests.
Project Stack
Installation
To install the package using pip, use the following command:
pip install api-to-dataframe
To install the package using poetry, use the following command:
poetry add api-to-dataframe
User Guide
## Importing library
from api_to_dataframe import ClientBuilder, RetryStrategies
# Create a client for simple ingest data from API (timeout 1 second)
client = ClientBuilder(endpoint="https://api.example.com")
# if you can define timeout with LINEAR_RETRY_STRATEGY and set headers:
headers = {
"application_name": "api_to_dataframe"
}
client = ClientBuilder(endpoint="https://api.example.com"
,retry_strategy=RetryStrategies.LINEAR_RETRY_STRATEGY
,connection_timeout=2
,headers=headers)
"""
NOTE: by default the quantity of retries is 3 and the time between retries is 1 second, but you can define manually.
"""
client = ClientBuilder(endpoint="https://api.example.com"
,retry_strategy=RetryStrategies.LINEAR_RETRY_STRATEGY
,connection_timeout=10
,headers=headers
,retries=5
,initial_delay=10)
### timeout, retry_strategy and headers are opcionals parameters
# Get data from the API
data = client.get_api_data()
# Convert the data to a DataFrame
df = client.api_to_dataframe(data)
# Display the DataFrame
print(df)
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
File details
Details for the file api_to_dataframe-1.3.1.tar.gz
.
File metadata
- Download URL: api_to_dataframe-1.3.1.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.9.19 Linux/6.5.0-1022-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d417b4856ba402c7e2eb5ef482e4fd874fcd62f646289a40454c7743fcad045 |
|
MD5 | 5fbed83147fff263edb083e18cadee4b |
|
BLAKE2b-256 | 66d2613f9992b47ed2b97c90183c443bccfb7e1217cdc138e78c8eb8f44f9119 |
File details
Details for the file api_to_dataframe-1.3.1-py3-none-any.whl
.
File metadata
- Download URL: api_to_dataframe-1.3.1-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.9.19 Linux/6.5.0-1022-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10d4598a89e1ac111b1e9fc53a9c39bb1189bf0645754e35f430c00f2d600bbc |
|
MD5 | e2ab4292796eb98e53dbac5ad0737e1c |
|
BLAKE2b-256 | 9fbdac1b9aab0037be1e86657374e42b6946fcea163c340bd8038fb94f90cf50 |