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.4.tar.gz
.
File metadata
- Download URL: api_to_dataframe-1.3.4.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-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01021eddf9d830f62386e23407463b07de7575061916f09e8c999a323745ee71 |
|
MD5 | 163973e25088d3fab41296848c5754b7 |
|
BLAKE2b-256 | 760cdad84f609e4929da13e31d083a1279aca2c32821be50f08d46d47f1c988f |
File details
Details for the file api_to_dataframe-1.3.4-py3-none-any.whl
.
File metadata
- Download URL: api_to_dataframe-1.3.4-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-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3d08f769e044f5a36582aef7f9c6f21c517de5df2a3fdddb587c66224aa2c79 |
|
MD5 | 0eaf67ab7626bcfe2fa3029e07252bec |
|
BLAKE2b-256 | 656a6a9386c26aea8a4916efcf46439afca37b6081fadb8a1c0d94da14576541 |