Skip to main content

A package to convert API responses to pandas dataframe

Project description

API to DataFrame

Your solution to convert API responses to Pandas DataFrames with retry strategies and detailed reports.

Github

PyPI - Status PyPI - Downloads PyPI - Version

PyPI - Python Version

CI CD

Codecov

Project Stack

Python  Docker  Poetry  GitHub Actions  CodeCov  pypi  pandas  pytest 

Library Description

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 and automatic generation of detailed reports on the received data.

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
                        ,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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

api_to_dataframe-1.2.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

api_to_dataframe-1.2.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file api_to_dataframe-1.2.0.tar.gz.

File metadata

  • Download URL: api_to_dataframe-1.2.0.tar.gz
  • Upload date:
  • Size: 4.4 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

Hashes for api_to_dataframe-1.2.0.tar.gz
Algorithm Hash digest
SHA256 7ea62de845a670f70251b661da64303ec3033d10ce8ae7535c592ad0add46f73
MD5 562b1a85d38529e59861df15906900b9
BLAKE2b-256 1dabbb65827047f8289c279f9e31d255850399b77aaf2b9bb3803d4816663563

See more details on using hashes here.

File details

Details for the file api_to_dataframe-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: api_to_dataframe-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 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

Hashes for api_to_dataframe-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d2fcf5a27f9104538a8f61dd82babc4bf599fe78342c2c31be1b689bc281282
MD5 a7ad0bdc8e3cd4f080708ce764d320c3
BLAKE2b-256 8dc6f6de11b500d527ccf0a3daa24b2b62e8089ff628bef7588a6db92cee209b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page