api-to-dataframe 1.0.1__tar.gz → 1.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {api_to_dataframe-1.0.1 → api_to_dataframe-1.0.2}/PKG-INFO +39 -2
- {api_to_dataframe-1.0.1 → api_to_dataframe-1.0.2}/README.md +35 -1
- {api_to_dataframe-1.0.1 → api_to_dataframe-1.0.2}/pyproject.toml +14 -6
- api_to_dataframe-1.0.2/src/api_to_dataframe/__init__.py +4 -0
- api_to_dataframe-1.0.2/src/api_to_dataframe/controller/client_builder.py +53 -0
- api_to_dataframe-1.0.1/src/api_to_dataframe/__init__.py +0 -2
- api_to_dataframe-1.0.1/src/api_to_dataframe/controller/client_builder.py +0 -20
- {api_to_dataframe-1.0.1 → api_to_dataframe-1.0.2}/LICENSE +0 -0
- {api_to_dataframe-1.0.1 → api_to_dataframe-1.0.2}/src/api_to_dataframe/common/__init__.py +0 -0
- {api_to_dataframe-1.0.1 → api_to_dataframe-1.0.2}/src/api_to_dataframe/common/utils/__init__.py +0 -0
- {api_to_dataframe-1.0.1 → api_to_dataframe-1.0.2}/src/api_to_dataframe/common/utils/retry_strategies.py +0 -0
- {api_to_dataframe-1.0.1 → api_to_dataframe-1.0.2}/src/api_to_dataframe/config/config.py +0 -0
- {api_to_dataframe-1.0.1 → api_to_dataframe-1.0.2}/src/api_to_dataframe/controller/__init__.py +0 -0
- {api_to_dataframe-1.0.1 → api_to_dataframe-1.0.2}/src/api_to_dataframe/models/__init__.py +0 -0
- {api_to_dataframe-1.0.1 → api_to_dataframe-1.0.2}/src/api_to_dataframe/models/get_data.py +0 -0
- {api_to_dataframe-1.0.1 → api_to_dataframe-1.0.2}/src/api_to_dataframe/models/retainer.py +0 -0
- {api_to_dataframe-1.0.1 → api_to_dataframe-1.0.2}/src/api_to_dataframe/views/__init__.py +0 -0
- {api_to_dataframe-1.0.1 → api_to_dataframe-1.0.2}/src/api_to_dataframe/views/dataframe_metrics.py +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: api-to-dataframe
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.2
|
|
4
4
|
Summary: A package to convert API responses to pandas dataframe
|
|
5
|
+
Home-page: https://github.com/IvanildoBarauna/api-to-dataframe
|
|
5
6
|
License: MIT
|
|
6
7
|
Author: IvanildoBarauna
|
|
7
8
|
Author-email: ivanildo.jnr@outlook.com
|
|
@@ -17,6 +18,9 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
17
18
|
Classifier: Programming Language :: Python :: 3.8
|
|
18
19
|
Requires-Dist: pandas (>=2.2.2,<3.0.0)
|
|
19
20
|
Requires-Dist: requests (>=2.32.3,<3.0.0)
|
|
21
|
+
Project-URL: Documentation, https://github.com/IvanildoBarauna/api-to-dataframe#readme
|
|
22
|
+
Project-URL: Issues, https://github.com/IvanildoBarauna/api-to-dataframe/issues
|
|
23
|
+
Project-URL: Repository, https://github.com/IvanildoBarauna/api-to-dataframe
|
|
20
24
|
Description-Content-Type: text/markdown
|
|
21
25
|
|
|
22
26
|
# API to DataFrame
|
|
@@ -33,7 +37,7 @@ Your solution to convert API responses to Pandas DataFrames with retry strategie
|
|
|
33
37
|
[](https://github.com/IvanildoBarauna/api-to-dataframe/actions/workflows/CI.yaml)
|
|
34
38
|
[](https://github.com/IvanildoBarauna/api-to-dataframe/actions/workflows/CD.yaml)
|
|
35
39
|
|
|
36
|
-

|
|
40
|
+
[](https://app.codecov.io/gh/IvanildoBarauna/api-to-dataframe)
|
|
37
41
|
|
|
38
42
|
## Project Stack
|
|
39
43
|
|
|
@@ -52,4 +56,37 @@ Your solution to convert API responses to Pandas DataFrames with retry strategie
|
|
|
52
56
|
|
|
53
57
|
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.
|
|
54
58
|
|
|
59
|
+
## Installation
|
|
55
60
|
|
|
61
|
+
To install the package using pip, use the following command:
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
pip install api-to-dataframe
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
To install the package using poetry, use the following command:
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
poetry add api-to-dataframe
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## How to use it
|
|
74
|
+
|
|
75
|
+
``` python
|
|
76
|
+
## Importing library
|
|
77
|
+
from api_to_dataframe import ClientBuilder, RetryStrategies
|
|
78
|
+
|
|
79
|
+
# Create a client for the API without retry strategy
|
|
80
|
+
client = ClientBuilder(endpoint="https://api.example.com", retry_strategy=RetryStrategies.NoRetryStrategy)
|
|
81
|
+
# or with LinearStrategy (In development, actually don't nothing)
|
|
82
|
+
client = ClientBuilder(endpoint="https://api.example.com", retry_strategy=RetryStrategies.LinearStrategy)
|
|
83
|
+
|
|
84
|
+
# Get data from the API
|
|
85
|
+
data = client.get_api_data()
|
|
86
|
+
|
|
87
|
+
# Convert the data to a DataFrame
|
|
88
|
+
df = client.api_to_dataframe(data)
|
|
89
|
+
|
|
90
|
+
# Display the DataFrame
|
|
91
|
+
print(df)
|
|
92
|
+
```
|
|
@@ -12,7 +12,7 @@ Your solution to convert API responses to Pandas DataFrames with retry strategie
|
|
|
12
12
|
[](https://github.com/IvanildoBarauna/api-to-dataframe/actions/workflows/CI.yaml)
|
|
13
13
|
[](https://github.com/IvanildoBarauna/api-to-dataframe/actions/workflows/CD.yaml)
|
|
14
14
|
|
|
15
|
-

|
|
15
|
+
[](https://app.codecov.io/gh/IvanildoBarauna/api-to-dataframe)
|
|
16
16
|
|
|
17
17
|
## Project Stack
|
|
18
18
|
|
|
@@ -31,3 +31,37 @@ Your solution to convert API responses to Pandas DataFrames with retry strategie
|
|
|
31
31
|
|
|
32
32
|
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.
|
|
33
33
|
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
To install the package using pip, use the following command:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
pip install api-to-dataframe
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
To install the package using poetry, use the following command:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
poetry add api-to-dataframe
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## How to use it
|
|
49
|
+
|
|
50
|
+
``` python
|
|
51
|
+
## Importing library
|
|
52
|
+
from api_to_dataframe import ClientBuilder, RetryStrategies
|
|
53
|
+
|
|
54
|
+
# Create a client for the API without retry strategy
|
|
55
|
+
client = ClientBuilder(endpoint="https://api.example.com", retry_strategy=RetryStrategies.NoRetryStrategy)
|
|
56
|
+
# or with LinearStrategy (In development, actually don't nothing)
|
|
57
|
+
client = ClientBuilder(endpoint="https://api.example.com", retry_strategy=RetryStrategies.LinearStrategy)
|
|
58
|
+
|
|
59
|
+
# Get data from the API
|
|
60
|
+
data = client.get_api_data()
|
|
61
|
+
|
|
62
|
+
# Convert the data to a DataFrame
|
|
63
|
+
df = client.api_to_dataframe(data)
|
|
64
|
+
|
|
65
|
+
# Display the DataFrame
|
|
66
|
+
print(df)
|
|
67
|
+
```
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "api-to-dataframe"
|
|
3
|
-
version = "1.0.
|
|
3
|
+
version = "1.0.2"
|
|
4
4
|
description = "A package to convert API responses to pandas dataframe"
|
|
5
5
|
authors = ["IvanildoBarauna <ivanildo.jnr@outlook.com>"]
|
|
6
6
|
readme = "README.md"
|
|
7
7
|
license = "MIT"
|
|
8
|
-
packages = [{ include = "api_to_dataframe", from = "src" }]
|
|
9
8
|
classifiers=[
|
|
10
9
|
"Development Status :: 2 - Pre-Alpha",
|
|
11
10
|
"Intended Audience :: Developers",
|
|
@@ -14,15 +13,24 @@ classifiers=[
|
|
|
14
13
|
"Programming Language :: Python :: 3.8",
|
|
15
14
|
]
|
|
16
15
|
|
|
16
|
+
homepage = "https://github.com/IvanildoBarauna/api-to-dataframe"
|
|
17
|
+
repository = "https://github.com/IvanildoBarauna/api-to-dataframe"
|
|
18
|
+
documentation = "https://github.com/IvanildoBarauna/api-to-dataframe#readme"
|
|
19
|
+
|
|
20
|
+
[tool.poetry.urls]
|
|
21
|
+
Homepage = "https://github.com/IvanildoBarauna/api-to-dataframe"
|
|
22
|
+
Documentation = "https://github.com/IvanildoBarauna/api-to-dataframe#readme"
|
|
23
|
+
Issues = "https://github.com/IvanildoBarauna/api-to-dataframe/issues"
|
|
24
|
+
|
|
25
|
+
[tool.setuptools.packages.find]
|
|
26
|
+
where = ["src"]
|
|
27
|
+
include = ["api_to_dataframe*"]
|
|
28
|
+
|
|
17
29
|
[tool.poetry.group.dev.dependencies]
|
|
18
30
|
poetry-dynamic-versioning = "^1.3.0"
|
|
19
31
|
pytest = "^8.2.2"
|
|
20
32
|
coverage = "^7.5.3"
|
|
21
33
|
|
|
22
|
-
[tool.project.urls]
|
|
23
|
-
url="https://github.com/IvanidoBarauna/api-to-dataframe"
|
|
24
|
-
license="MIT"
|
|
25
|
-
|
|
26
34
|
[tool.poetry.dependencies]
|
|
27
35
|
python = "^3.9"
|
|
28
36
|
pandas = "^2.2.2"
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from api_to_dataframe.common.utils.retry_strategies import RetryStrategies
|
|
2
|
+
from api_to_dataframe.models.get_data import GetData
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ClientBuilder:
|
|
6
|
+
"""
|
|
7
|
+
Builder for creating clients that interact with an API endpoint and return data.
|
|
8
|
+
|
|
9
|
+
Attributes:
|
|
10
|
+
endpoint (str): The API endpoint to be accessed.
|
|
11
|
+
retry_strategy (RetryStrategies): The retry strategy for the request. Default is NoRetryStrategy.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def __init__(self, endpoint: str, retry_strategy: RetryStrategies = RetryStrategies.NoRetryStrategy):
|
|
15
|
+
"""
|
|
16
|
+
Initializes an instance of ClientBuilder.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
endpoint (str): The API endpoint to be accessed.
|
|
20
|
+
retry_strategy (RetryStrategies, optional): The retry strategy for the request. Default is NoRetryStrategy.
|
|
21
|
+
|
|
22
|
+
Raises:
|
|
23
|
+
ValueError: If the endpoint is empty.
|
|
24
|
+
"""
|
|
25
|
+
if endpoint == "":
|
|
26
|
+
raise ValueError("::: endpoint param is mandatory :::")
|
|
27
|
+
else:
|
|
28
|
+
self.endpoint = endpoint
|
|
29
|
+
self.retry_strategy = retry_strategy
|
|
30
|
+
|
|
31
|
+
def get_api_data(self):
|
|
32
|
+
"""
|
|
33
|
+
Retrieves data from the API using the defined endpoint and retry strategy.
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
dict: The response from the API.
|
|
37
|
+
"""
|
|
38
|
+
response = GetData.get_response(self.endpoint, self.retry_strategy)
|
|
39
|
+
return response
|
|
40
|
+
|
|
41
|
+
@staticmethod
|
|
42
|
+
def api_to_dataframe(response: dict):
|
|
43
|
+
"""
|
|
44
|
+
Converts the API response into a DataFrame.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
response (dict): The response from the API.
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
DataFrame: The data converted into a DataFrame.
|
|
51
|
+
"""
|
|
52
|
+
df = GetData.to_dataframe(response)
|
|
53
|
+
return df
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
from api_to_dataframe.common.utils.retry_strategies import RetryStrategies
|
|
2
|
-
from api_to_dataframe.models.get_data import GetData
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class ClientBuilder:
|
|
6
|
-
def __init__(self, endpoint: str, retry_strategy: RetryStrategies = RetryStrategies.NoRetryStrategy):
|
|
7
|
-
if endpoint == "":
|
|
8
|
-
raise ValueError("::: endpoint param is mandatory :::")
|
|
9
|
-
else:
|
|
10
|
-
self.endpoint = endpoint
|
|
11
|
-
self.retry_strategy = retry_strategy
|
|
12
|
-
|
|
13
|
-
def get_api_data(self):
|
|
14
|
-
response = GetData.get_response(self.endpoint, self.retry_strategy)
|
|
15
|
-
return response
|
|
16
|
-
|
|
17
|
-
@staticmethod
|
|
18
|
-
def api_to_dataframe(response: dict):
|
|
19
|
-
df = GetData.to_dataframe(response)
|
|
20
|
-
return df
|
|
File without changes
|
|
File without changes
|
{api_to_dataframe-1.0.1 → api_to_dataframe-1.0.2}/src/api_to_dataframe/common/utils/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{api_to_dataframe-1.0.1 → api_to_dataframe-1.0.2}/src/api_to_dataframe/controller/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{api_to_dataframe-1.0.1 → api_to_dataframe-1.0.2}/src/api_to_dataframe/views/dataframe_metrics.py
RENAMED
|
File without changes
|