Skip to content

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.

License

Notifications You must be signed in to change notification settings

IvanildoBarauna/api-to-dataframe

Repository files navigation

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.

Github

PyPI - Status PyPI - Downloads PyPI - Version

PyPI - Python Version

CI CD

Codecov

Project Stack

Python  Docker  Poetry  GitHub Actions  CodeCov  pypi  pandas  pytest 

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 LinearStrategy and set headers:
headers = {
    "application_name": "api_to_dataframe"
}
client = ClientBuilder(endpoint="https://api.example.com"
                        ,retry_strategy=RetryStrategies.LinearStrategy
                        ,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, like this:
    
"""

client = ClientBuilder(endpoint="https://api.example.com"
                        ,retry_strategy=RetryStrategies.LinearStrategy
                        ,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)

About

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.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published