api-to-dataframe 2.1.0__tar.gz → 2.2.0__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.
@@ -0,0 +1,93 @@
1
+ Metadata-Version: 2.1
2
+ Name: api-to-dataframe
3
+ Version: 2.2.0
4
+ Summary: A package to convert API responses to pandas dataframe
5
+ License: MIT
6
+ Author: IvanildoBarauna
7
+ Author-email: ivanildo.jnr@outlook.com
8
+ Requires-Python: >=3.10,<4.0
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Requires-Dist: pandas (>=2.2.3,<3.0.0)
17
+ Requires-Dist: requests (>=2.33.0,<3.0.0)
18
+ Project-URL: Documentation, https://github.com/IvanildoBarauna/api-to-dataframe/blob/main/README.md
19
+ Project-URL: Homepage, https://pypi.org/project/api-to-dataframe
20
+ Project-URL: ImplementationCase, https://github.com/IvanildoBarauna/ETL-awesome-api
21
+ Project-URL: Issues, https://github.com/IvanildoBarauna/api-to-dataframe/issues
22
+ Project-URL: Notebook, https://github.com/IvanildoBarauna/api-to-dataframe/blob/main/notebooks/example.ipynb
23
+ Project-URL: Repository, https://github.com/IvanildoBarauna/api-to-dataframe
24
+ Description-Content-Type: text/markdown
25
+
26
+ # API to DataFrame
27
+
28
+ Fetch JSON from any HTTP API and turn it into a pandas DataFrame in two calls — with optional retry strategies.
29
+
30
+ [![PyPI - Version](https://img.shields.io/pypi/v/api-to-dataframe?style=for-the-badge&logo=pypi)](https://pypi.org/project/api-to-dataframe/#history)
31
+ [![PyPI - Downloads](https://img.shields.io/pypi/dm/api-to-dataframe?style=for-the-badge&logo=pypi)](https://pypi.org/project/api-to-dataframe/)
32
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/api-to-dataframe?style=for-the-badge&logo=python)](https://pypi.org/project/api-to-dataframe/)
33
+ [![CI](https://img.shields.io/github/actions/workflow/status/ivanildobarauna-dev/api-to-dataframe/CI.yaml?style=for-the-badge&logo=githubactions&label=CI)](https://github.com/ivanildobarauna-dev/api-to-dataframe/actions/workflows/CI.yaml)
34
+ [![Codecov](https://img.shields.io/codecov/c/github/ivanildobarauna-dev/api-to-dataframe?style=for-the-badge&logo=codecov)](https://app.codecov.io/gh/ivanildobarauna-dev/api-to-dataframe)
35
+
36
+ ## Install
37
+
38
+ ```sh
39
+ pip install api-to-dataframe
40
+ # or
41
+ poetry add api-to-dataframe
42
+ ```
43
+
44
+ Requires Python 3.10+.
45
+
46
+ ## Quick start
47
+
48
+ ```python
49
+ from api_to_dataframe import ClientBuilder, RetryStrategies
50
+
51
+ client = ClientBuilder(endpoint="https://api.example.com/items")
52
+ data = client.get_api_data()
53
+ df = client.api_to_dataframe(data)
54
+ ```
55
+
56
+ `api_to_dataframe` expects the response to be a list of dicts. An empty result raises `ValueError`.
57
+
58
+ ## Configuration
59
+
60
+ ```python
61
+ client = ClientBuilder(
62
+ endpoint="https://api.example.com/items",
63
+ headers={"Authorization": "Bearer ..."},
64
+ retry_strategy=RetryStrategies.EXPONENTIAL_RETRY_STRATEGY,
65
+ retries=5,
66
+ initial_delay=2,
67
+ connection_timeout=10,
68
+ )
69
+ ```
70
+
71
+ | Parameter | Default | Description |
72
+ | -------------------- | -------------------- | --------------------------------------------------- |
73
+ | `endpoint` | — (required) | Target URL. |
74
+ | `headers` | `None` | Request headers. |
75
+ | `retry_strategy` | `NO_RETRY_STRATEGY` | See strategies below. |
76
+ | `retries` | `3` | Max attempts. Hard-capped at 5. |
77
+ | `initial_delay` | `1` | Base delay in seconds between retries. |
78
+ | `connection_timeout` | `10` | Per-request timeout in seconds. |
79
+
80
+ ## Retry strategies
81
+
82
+ - `NO_RETRY_STRATEGY` — fail fast on the first error.
83
+ - `LINEAR_RETRY_STRATEGY` — wait `initial_delay` seconds before each retry.
84
+ - `EXPONENTIAL_RETRY_STRATEGY` — wait `initial_delay * retry_number` seconds before each retry.
85
+
86
+ Retries are capped at 5 regardless of the `retries` value.
87
+
88
+ ## Links
89
+
90
+ - [PyPI](https://pypi.org/project/api-to-dataframe/)
91
+ - [Example notebook](https://github.com/IvanildoBarauna/api-to-dataframe/blob/main/notebooks/example.ipynb)
92
+ - [Issues](https://github.com/IvanildoBarauna/api-to-dataframe/issues)
93
+
@@ -0,0 +1,67 @@
1
+ # API to DataFrame
2
+
3
+ Fetch JSON from any HTTP API and turn it into a pandas DataFrame in two calls — with optional retry strategies.
4
+
5
+ [![PyPI - Version](https://img.shields.io/pypi/v/api-to-dataframe?style=for-the-badge&logo=pypi)](https://pypi.org/project/api-to-dataframe/#history)
6
+ [![PyPI - Downloads](https://img.shields.io/pypi/dm/api-to-dataframe?style=for-the-badge&logo=pypi)](https://pypi.org/project/api-to-dataframe/)
7
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/api-to-dataframe?style=for-the-badge&logo=python)](https://pypi.org/project/api-to-dataframe/)
8
+ [![CI](https://img.shields.io/github/actions/workflow/status/ivanildobarauna-dev/api-to-dataframe/CI.yaml?style=for-the-badge&logo=githubactions&label=CI)](https://github.com/ivanildobarauna-dev/api-to-dataframe/actions/workflows/CI.yaml)
9
+ [![Codecov](https://img.shields.io/codecov/c/github/ivanildobarauna-dev/api-to-dataframe?style=for-the-badge&logo=codecov)](https://app.codecov.io/gh/ivanildobarauna-dev/api-to-dataframe)
10
+
11
+ ## Install
12
+
13
+ ```sh
14
+ pip install api-to-dataframe
15
+ # or
16
+ poetry add api-to-dataframe
17
+ ```
18
+
19
+ Requires Python 3.10+.
20
+
21
+ ## Quick start
22
+
23
+ ```python
24
+ from api_to_dataframe import ClientBuilder, RetryStrategies
25
+
26
+ client = ClientBuilder(endpoint="https://api.example.com/items")
27
+ data = client.get_api_data()
28
+ df = client.api_to_dataframe(data)
29
+ ```
30
+
31
+ `api_to_dataframe` expects the response to be a list of dicts. An empty result raises `ValueError`.
32
+
33
+ ## Configuration
34
+
35
+ ```python
36
+ client = ClientBuilder(
37
+ endpoint="https://api.example.com/items",
38
+ headers={"Authorization": "Bearer ..."},
39
+ retry_strategy=RetryStrategies.EXPONENTIAL_RETRY_STRATEGY,
40
+ retries=5,
41
+ initial_delay=2,
42
+ connection_timeout=10,
43
+ )
44
+ ```
45
+
46
+ | Parameter | Default | Description |
47
+ | -------------------- | -------------------- | --------------------------------------------------- |
48
+ | `endpoint` | — (required) | Target URL. |
49
+ | `headers` | `None` | Request headers. |
50
+ | `retry_strategy` | `NO_RETRY_STRATEGY` | See strategies below. |
51
+ | `retries` | `3` | Max attempts. Hard-capped at 5. |
52
+ | `initial_delay` | `1` | Base delay in seconds between retries. |
53
+ | `connection_timeout` | `10` | Per-request timeout in seconds. |
54
+
55
+ ## Retry strategies
56
+
57
+ - `NO_RETRY_STRATEGY` — fail fast on the first error.
58
+ - `LINEAR_RETRY_STRATEGY` — wait `initial_delay` seconds before each retry.
59
+ - `EXPONENTIAL_RETRY_STRATEGY` — wait `initial_delay * retry_number` seconds before each retry.
60
+
61
+ Retries are capped at 5 regardless of the `retries` value.
62
+
63
+ ## Links
64
+
65
+ - [PyPI](https://pypi.org/project/api-to-dataframe/)
66
+ - [Example notebook](https://github.com/IvanildoBarauna/api-to-dataframe/blob/main/notebooks/example.ipynb)
67
+ - [Issues](https://github.com/IvanildoBarauna/api-to-dataframe/issues)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "api-to-dataframe"
3
- version = "2.1.0"
3
+ version = "2.2.0"
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"
@@ -32,7 +32,7 @@ poetry-dynamic-versioning = "^1.3.0"
32
32
  pytest = "^9.0.3"
33
33
  coverage = "^7.5.3"
34
34
  responses = ">=0.25.3,<0.27.0"
35
- pylint = "^3.2.5"
35
+ pylint = ">=3.2.5,<5.0.0"
36
36
  black = "^26.3.1"
37
37
  pytest-cov = "^7.0.0"
38
38
 
@@ -1,129 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: api-to-dataframe
3
- Version: 2.1.0
4
- Summary: A package to convert API responses to pandas dataframe
5
- License: MIT
6
- Author: IvanildoBarauna
7
- Author-email: ivanildo.jnr@outlook.com
8
- Requires-Python: >=3.10,<4.0
9
- Classifier: Development Status :: 5 - Production/Stable
10
- Classifier: Intended Audience :: Developers
11
- Classifier: License :: OSI Approved :: MIT License
12
- Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.10
14
- Classifier: Programming Language :: Python :: 3.11
15
- Classifier: Programming Language :: Python :: 3.8
16
- Requires-Dist: pandas (>=2.2.3,<3.0.0)
17
- Requires-Dist: requests (>=2.33.0,<3.0.0)
18
- Project-URL: Documentation, https://github.com/IvanildoBarauna/api-to-dataframe/blob/main/README.md
19
- Project-URL: Homepage, https://pypi.org/project/api-to-dataframe
20
- Project-URL: ImplementationCase, https://github.com/IvanildoBarauna/ETL-awesome-api
21
- Project-URL: Issues, https://github.com/IvanildoBarauna/api-to-dataframe/issues
22
- Project-URL: Notebook, https://github.com/IvanildoBarauna/api-to-dataframe/blob/main/notebooks/example.ipynb
23
- Project-URL: Repository, https://github.com/IvanildoBarauna/api-to-dataframe
24
- Description-Content-Type: text/markdown
25
-
26
- # API to DataFrame
27
- 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.
28
-
29
- [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/ivanildobarauna-dev/api-to-dataframe)
30
-
31
-
32
- [![PyPI - Status](https://img.shields.io/pypi/status/api-to-dataframe?style=for-the-badge&logo=pypi)](https://pypi.org/project/api-to-dataframe/)
33
- [![PyPI - Downloads](https://img.shields.io/pypi/dm/api-to-dataframe?style=for-the-badge&logo=pypi)](https://pypi.org/project/api-to-dataframe/)
34
- [![PyPI - Version](https://img.shields.io/pypi/v/api-to-dataframe?style=for-the-badge&logo=pypi)](https://pypi.org/project/api-to-dataframe/#history)
35
-
36
- ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/api-to-dataframe?style=for-the-badge&logo=python)
37
-
38
- [![CI](https://img.shields.io/github/actions/workflow/status/ivanildobarauna-dev/api-to-dataframe/CI.yaml?&style=for-the-badge&logo=githubactions&cacheSeconds=60&label=Tests+and+pre+build)](https://github.com/ivanildobarauna-dev/api-to-dataframe/actions/workflows/CI.yaml)
39
- [![CD](https://img.shields.io/github/actions/workflow/status/ivanildobarauna-dev/api-to-dataframe/CD.yaml?&style=for-the-badge&logo=githubactions&cacheSeconds=60&event=release&label=Package_publication)](https://github.com/ivanildobarauna-dev/api-to-dataframe/actions/workflows/CD.yaml)
40
-
41
- [![Codecov](https://img.shields.io/codecov/c/github/ivanildobarauna-dev/api-to-dataframe?style=for-the-badge&logo=codecov)](https://app.codecov.io/gh/ivanildobarauna-dev/api-to-dataframe)
42
-
43
- ## Project Stack
44
-
45
- ![Python](https://img.shields.io/badge/-Python-05122A?style=flat&logo=python)&nbsp;
46
- ![Docker](https://img.shields.io/badge/-Docker-05122A?style=flat&logo=docker)&nbsp;
47
- ![Poetry](https://img.shields.io/badge/-Poetry-05122A?style=flat&logo=poetry)&nbsp;
48
- ![GitHub Actions](https://img.shields.io/badge/-GitHub_Actions-05122A?style=flat&logo=githubactions)&nbsp;
49
- ![CodeCov](https://img.shields.io/badge/-CodeCov-05122A?style=flat&logo=codecov)&nbsp;
50
- ![pypi](https://img.shields.io/badge/-pypi-05122A?style=flat&logo=pypi)&nbsp;
51
- ![pandas](https://img.shields.io/badge/-pandas-05122A?style=flat&logo=pandas)&nbsp;
52
- ![pytest](https://img.shields.io/badge/-pytest-05122A?style=flat&logo=pytest)&nbsp;
53
-
54
-
55
- ## Installation
56
-
57
- To install the package using pip, use the following command:
58
-
59
- ```sh
60
- pip install api-to-dataframe
61
- ```
62
-
63
- To install the package using poetry, use the following command:
64
-
65
- ```sh
66
- poetry add api-to-dataframe
67
- ```
68
-
69
- ## User Guide
70
-
71
- ``` python
72
- ## Importing library
73
- from api_to_dataframe import ClientBuilder, RetryStrategies
74
-
75
- # Create a client for simple ingest data from API (timeout 1 second)
76
- client = ClientBuilder(endpoint="https://api.example.com")
77
-
78
- # if you can define timeout with LINEAR_RETRY_STRATEGY and set headers:
79
- headers = {
80
- "application_name": "api_to_dataframe"
81
- }
82
- client = ClientBuilder(endpoint="https://api.example.com"
83
- ,retry_strategy=RetryStrategies.LINEAR_RETRY_STRATEGY
84
- ,connection_timeout=2
85
- ,headers=headers)
86
-
87
- # if you can define timeout with EXPONENTIAL_RETRY_STRATEGY and set headers:
88
- client = ClientBuilder(endpoint="https://api.example.com"
89
- ,retry_strategy=RetryStrategies.EXPONENTIAL_RETRY_STRATEGY
90
- ,connection_timeout=10
91
- ,headers=headers
92
- ,retries=5
93
- ,initial_delay=10)
94
-
95
-
96
- # Get data from the API
97
- data = client.get_api_data()
98
-
99
- # Convert the data to a DataFrame
100
- df = client.api_to_dataframe(data)
101
-
102
- # Display the DataFrame
103
- print(df)
104
- ```
105
-
106
- ## Important notes:
107
- * **Opcionals Parameters:** The params timeout, retry_strategy and headers are opcionals.
108
- * **Default Params Value:** By default the quantity of retries is 3 and the time between retries is 1 second, but you can define manually.
109
- * **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.
110
- * **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
111
-
112
- RetryNumber | WaitingTime
113
- ------------ | -----------
114
- 2 | 2s
115
- 2 | 4s
116
- 3 | 6s
117
- 4 | 8s
118
- 5 | 10s
119
- * **Linear Retry Strategy:** The increment of time between retries is time passed in **initial_delay**
120
- e.g with initial_delay=2
121
-
122
- RetryNumber | WaitingTime
123
- ------------ | -----------
124
- 1 | 2s
125
- 2 | 2s
126
- 3 | 2s
127
- 4 | 2s
128
- 5 | 2s
129
-
@@ -1,103 +0,0 @@
1
- # API to DataFrame
2
- 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.
3
-
4
- [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/ivanildobarauna-dev/api-to-dataframe)
5
-
6
-
7
- [![PyPI - Status](https://img.shields.io/pypi/status/api-to-dataframe?style=for-the-badge&logo=pypi)](https://pypi.org/project/api-to-dataframe/)
8
- [![PyPI - Downloads](https://img.shields.io/pypi/dm/api-to-dataframe?style=for-the-badge&logo=pypi)](https://pypi.org/project/api-to-dataframe/)
9
- [![PyPI - Version](https://img.shields.io/pypi/v/api-to-dataframe?style=for-the-badge&logo=pypi)](https://pypi.org/project/api-to-dataframe/#history)
10
-
11
- ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/api-to-dataframe?style=for-the-badge&logo=python)
12
-
13
- [![CI](https://img.shields.io/github/actions/workflow/status/ivanildobarauna-dev/api-to-dataframe/CI.yaml?&style=for-the-badge&logo=githubactions&cacheSeconds=60&label=Tests+and+pre+build)](https://github.com/ivanildobarauna-dev/api-to-dataframe/actions/workflows/CI.yaml)
14
- [![CD](https://img.shields.io/github/actions/workflow/status/ivanildobarauna-dev/api-to-dataframe/CD.yaml?&style=for-the-badge&logo=githubactions&cacheSeconds=60&event=release&label=Package_publication)](https://github.com/ivanildobarauna-dev/api-to-dataframe/actions/workflows/CD.yaml)
15
-
16
- [![Codecov](https://img.shields.io/codecov/c/github/ivanildobarauna-dev/api-to-dataframe?style=for-the-badge&logo=codecov)](https://app.codecov.io/gh/ivanildobarauna-dev/api-to-dataframe)
17
-
18
- ## Project Stack
19
-
20
- ![Python](https://img.shields.io/badge/-Python-05122A?style=flat&logo=python)&nbsp;
21
- ![Docker](https://img.shields.io/badge/-Docker-05122A?style=flat&logo=docker)&nbsp;
22
- ![Poetry](https://img.shields.io/badge/-Poetry-05122A?style=flat&logo=poetry)&nbsp;
23
- ![GitHub Actions](https://img.shields.io/badge/-GitHub_Actions-05122A?style=flat&logo=githubactions)&nbsp;
24
- ![CodeCov](https://img.shields.io/badge/-CodeCov-05122A?style=flat&logo=codecov)&nbsp;
25
- ![pypi](https://img.shields.io/badge/-pypi-05122A?style=flat&logo=pypi)&nbsp;
26
- ![pandas](https://img.shields.io/badge/-pandas-05122A?style=flat&logo=pandas)&nbsp;
27
- ![pytest](https://img.shields.io/badge/-pytest-05122A?style=flat&logo=pytest)&nbsp;
28
-
29
-
30
- ## Installation
31
-
32
- To install the package using pip, use the following command:
33
-
34
- ```sh
35
- pip install api-to-dataframe
36
- ```
37
-
38
- To install the package using poetry, use the following command:
39
-
40
- ```sh
41
- poetry add api-to-dataframe
42
- ```
43
-
44
- ## User Guide
45
-
46
- ``` python
47
- ## Importing library
48
- from api_to_dataframe import ClientBuilder, RetryStrategies
49
-
50
- # Create a client for simple ingest data from API (timeout 1 second)
51
- client = ClientBuilder(endpoint="https://api.example.com")
52
-
53
- # if you can define timeout with LINEAR_RETRY_STRATEGY and set headers:
54
- headers = {
55
- "application_name": "api_to_dataframe"
56
- }
57
- client = ClientBuilder(endpoint="https://api.example.com"
58
- ,retry_strategy=RetryStrategies.LINEAR_RETRY_STRATEGY
59
- ,connection_timeout=2
60
- ,headers=headers)
61
-
62
- # if you can define timeout with EXPONENTIAL_RETRY_STRATEGY and set headers:
63
- client = ClientBuilder(endpoint="https://api.example.com"
64
- ,retry_strategy=RetryStrategies.EXPONENTIAL_RETRY_STRATEGY
65
- ,connection_timeout=10
66
- ,headers=headers
67
- ,retries=5
68
- ,initial_delay=10)
69
-
70
-
71
- # Get data from the API
72
- data = client.get_api_data()
73
-
74
- # Convert the data to a DataFrame
75
- df = client.api_to_dataframe(data)
76
-
77
- # Display the DataFrame
78
- print(df)
79
- ```
80
-
81
- ## Important notes:
82
- * **Opcionals Parameters:** The params timeout, retry_strategy and headers are opcionals.
83
- * **Default Params Value:** By default the quantity of retries is 3 and the time between retries is 1 second, but you can define manually.
84
- * **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.
85
- * **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
86
-
87
- RetryNumber | WaitingTime
88
- ------------ | -----------
89
- 2 | 2s
90
- 2 | 4s
91
- 3 | 6s
92
- 4 | 8s
93
- 5 | 10s
94
- * **Linear Retry Strategy:** The increment of time between retries is time passed in **initial_delay**
95
- e.g with initial_delay=2
96
-
97
- RetryNumber | WaitingTime
98
- ------------ | -----------
99
- 1 | 2s
100
- 2 | 2s
101
- 3 | 2s
102
- 4 | 2s
103
- 5 | 2s