Skip to main content

A package to convert API responses to pandas dataframe

Reason this release was yanked:

Deprecated. Please upgrade to version 2.1.0 or later

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.

Ask DeepWiki

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

# if you can define timeout with EXPONENTIAL_RETRY_STRATEGY and set headers:
client = ClientBuilder(endpoint="https://api.example.com"
                        ,retry_strategy=RetryStrategies.EXPONENTIAL_RETRY_STRATEGY
                        ,connection_timeout=10
                        ,headers=headers
                        ,retries=5
                        ,initial_delay=10)


# 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)

Important notes:

  • Opcionals Parameters: The params timeout, retry_strategy and headers are opcionals.

  • Default Params Value: By default the quantity of retries is 3 and the time between retries is 1 second, but you can define manually.

  • Max Of Retries: For security of API Server there is a limit for quantity of retries, actually this value is 5, this value is defined in lib constant. You can inform any value in RETRIES param, but the lib only will try 5x.

  • Exponential Retry Strategy: The increment of time between retries is time passed in initial_delay param * 2 * the retry_number, e.g with initial_delay=2

    RetryNumber WaitingTime
    2 2s
    2 4s
    3 6s
    4 8s
    5 10s
  • Linear Retry Strategy: The increment of time between retries is time passed in initial_delay e.g with initial_delay=2

    RetryNumber WaitingTime
    1 2s
    2 2s
    3 2s
    4 2s
    5 2s

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

api_to_dataframe-2.0.6.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

api_to_dataframe-2.0.6-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: api_to_dataframe-2.0.6.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.9.25 Linux/6.17.0-1010-azure

File hashes

Hashes for api_to_dataframe-2.0.6.tar.gz
Algorithm Hash digest
SHA256 940471e099744aa5cdcfdb62145b9a50ecf7f2c3ee213673146a118c0c145f69
MD5 cf58530788ac4a4db3497ece1bb32bc3
BLAKE2b-256 9ba85af96e8918be99f8e76492d5c425163dda46db408ef6e987784a3fbaddeb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: api_to_dataframe-2.0.6-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.9.25 Linux/6.17.0-1010-azure

File hashes

Hashes for api_to_dataframe-2.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e1992af465f8c5af96b0372120a09225ce64e16f5e8da14893d36b225b1f811d
MD5 f521417f71dd628573d19cb70a6c8907
BLAKE2b-256 e0337fe15f0ca79b8fae176ae53acc09620ba90948cbb430bc314e9273baf9d2

See more details on using hashes here.

Supported by

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