Skip to main content

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.

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


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.3.3.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

api_to_dataframe-1.3.3-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: api_to_dataframe-1.3.3.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-1023-azure

File hashes

Hashes for api_to_dataframe-1.3.3.tar.gz
Algorithm Hash digest
SHA256 f866a5df215142a34fe7a2f1addb143998def7f3d283df6099c2fb89f8877b2b
MD5 674dc9dc35f6a9273e8e29c248423fc4
BLAKE2b-256 ef968e1b05459f2d133ae842de28dce23be1d033794dcb755ad5bd1871185bab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: api_to_dataframe-1.3.3-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-1023-azure

File hashes

Hashes for api_to_dataframe-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4363a0990ff4baea1ff34e7e021600b020443b2ff6cd238f0367ea45526f6401
MD5 07a088ec4563743db5dcd96a017ad1b1
BLAKE2b-256 732b440bb5a6d3452ddf618392f3622ee1f60f9c3d62ec57f59d8523562571bc

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