bigdata-corp-api 0.16__tar.gz → 0.18.9__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,188 @@
1
+ Metadata-Version: 2.4
2
+ Name: bigdata-corp-api
3
+ Version: 0.18.9
4
+ Summary: Python API to facilitate interaction with BigDataCorp end-points
5
+ License: BSD-3-Clause License
6
+ License-File: LICENSE
7
+ Author: Murabei Data Science
8
+ Author-email: a.baceti@murabei.com
9
+ Requires-Python: >=3.6
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Dist: loguru
13
+ Requires-Dist: requests (>=2.32.5,<3.0.0)
14
+ Requires-Dist: tenacity (>=9.1.4,<10.0.0)
15
+ Project-URL: Homepage, https://github.com/Murabei-OpenSource-Codes/bigdata-corp-api
16
+ Description-Content-Type: text/markdown
17
+
18
+ # bigdata-corp-api
19
+
20
+ Python client library for BigDataCorp API endpoints used in Murabei data
21
+ enrichment and due-diligence workflows.
22
+
23
+ ## Objective and motivation
24
+
25
+ This package wraps BigDataCorp REST endpoints behind a typed Python API with
26
+ domain-specific exceptions and dataset discovery helpers.
27
+
28
+ ### Why this exists
29
+
30
+ Murabei services query BigDataCorp for CPF, CNPJ, and process data during
31
+ enrichment pipelines. A shared client avoids duplicating authentication,
32
+ retry logic, and error mapping across workers and applications.
33
+
34
+ ### How it is used
35
+
36
+ Install the package in workers or apps that call BigDataCorp during batch or
37
+ on-demand enrichment. Instantiate `BigDataCorpAPI` with an auth token, then
38
+ call dataset list or fetch methods.
39
+
40
+ ### Scope
41
+
42
+ Owns HTTP communication, dataset constants, exception types, retry and
43
+ pagination, parallel batch fetches, usage reporting, local CPF, CNPJ,
44
+ and CNJ checks, and certificate file downloads from on-demand
45
+ responses. Credential storage, orchestration, and downstream
46
+ persistence live in consuming services.
47
+
48
+ ## Install
49
+
50
+ From PyPI (when published):
51
+
52
+ ```bash
53
+ pip install bigdata-corp-api
54
+ ```
55
+
56
+ From a built wheel or sdist:
57
+
58
+ ```bash
59
+ pip install dist/bigdata_corp_api-*.whl
60
+ ```
61
+
62
+ From source (requires Poetry):
63
+
64
+ ```bash
65
+ pip install poetry
66
+ export VERSION=$(grep -E '^VERSION=' VERSION | cut -d'=' -f2-)
67
+ sed -e 's#{VERSION}#'"${VERSION}"'#g' pyproject_template.toml > pyproject.toml
68
+ poetry build
69
+ pip install dist/bigdata_corp_api-*.whl
70
+ ```
71
+
72
+ ## Quick start
73
+
74
+ ```python
75
+ from bigdatacorp_api.data import BigDataCorpAPI
76
+
77
+ api = BigDataCorpAPI(bigdata_auth_token="YOUR_TOKEN")
78
+
79
+ # List available CPF datasets
80
+ datasets = api.list_cpf_dataset()
81
+
82
+ # Fetch one dataset
83
+ result = api.get_cpf_dataset(
84
+ cpf="52998224725",
85
+ dataset="basic_data",
86
+ )
87
+
88
+ # Append dataset_params to the Datasets field
89
+ result = api.get_cnpj_dataset(
90
+ cnpj="00000000000191",
91
+ dataset="processes",
92
+ dataset_params="{NextPageId}.limit(500)",
93
+ )
94
+
95
+ # Fetch multiple datasets in parallel
96
+ batch = api.get_cpf_datasets(
97
+ cpf="52998224725",
98
+ datasets=["basic_data", "occupation_data"],
99
+ )
100
+
101
+ # Soft-fail non-critical errors; per-dataset q and Datasets suffixes
102
+ batch = api.get_cpf_datasets(
103
+ cpf="52998224725",
104
+ datasets=["basic_data", "processes"],
105
+ skip_errors=True,
106
+ query_params={"processes": ", returnupdates{false}"},
107
+ dataset_params={"processes": "{NextPageId}.limit(500)"},
108
+ )
109
+ # Soft failures are under batch["__errors__"]
110
+ ```
111
+
112
+ CNPJ and process queries follow the same pattern via `list_cnpj_dataset`,
113
+ `get_cnpj_dataset`, `list_process_dataset`, and `get_process_dataset`.
114
+ Fetch methods check CPF, CNPJ, and CNJ numbers locally and raise
115
+ `BigDataCorpAPIInvalidDocumentException` before the HTTP call.
116
+ Batch helpers accept `skip_errors`, a `query_params` mapping (suffix for
117
+ `q`), and a `dataset_params` mapping (suffix for `Datasets`).
118
+
119
+ Usage reporting for a date range:
120
+
121
+ ```python
122
+ usage = api.get_usage(
123
+ initial_date="2025-01-01",
124
+ final_date="2025-01-31",
125
+ )
126
+ ```
127
+
128
+ Download a certificate file from an on-demand dataset response:
129
+
130
+ ```python
131
+ cert_response = api.get_cpf_dataset(
132
+ cpf="52998224725",
133
+ dataset="ondemand_cert_debt_absence_by_state_person",
134
+ )
135
+ file_data = api.get_result_file(
136
+ dataset="ondemand_cert_debt_absence_by_state_person",
137
+ json_data=cert_response,
138
+ )
139
+ # file_data["file_type"] and file_data["file_content"]
140
+ ```
141
+
142
+ ## Configuration
143
+
144
+ The auth token is passed to `BigDataCorpAPI` at construction time.
145
+ Timeout, batch parallelism, and the pagination page cap are read from
146
+ the environment when set. A blank value keeps the default. Any other
147
+ value must be a positive integer.
148
+
149
+ | Variable | Required | Description |
150
+ |----------|----------|-------------|
151
+ | `BIGDATACORP__REQUEST_TIMEOUT` | No | HTTP timeout in seconds (default `60`) |
152
+ | `BIGDATACORP__N_PARALLEL` | No | Max threads for batch fetches (default `8`) |
153
+ | `BIGDATACORP__MAX_PAGES` | No | Extra pages after the first (default `200`) |
154
+ | `BIGDATA_AUTH_TOKEN` | Tests | Token for integration tests |
155
+ | `TEST_CPF` | Tests | Valid CPF for integration tests |
156
+ | `TEST_CNPJ` | Tests | Valid CNPJ for integration tests |
157
+
158
+ ## Development
159
+
160
+ Build a release (bumps patch in `VERSION`, renders `pyproject.toml`, tags,
161
+ and pushes):
162
+
163
+ ```bash
164
+ ./build.sh
165
+ ```
166
+
167
+ Run tests (integration tests call the live API when env vars are set):
168
+
169
+ ```bash
170
+ export BIGDATA_AUTH_TOKEN="your-token"
171
+ export TEST_CPF="valid-cpf"
172
+ export TEST_CNPJ="valid-cnpj"
173
+ python -m unittest discover -s src/bigdatacorp_api/tests
174
+ ```
175
+
176
+ Lint with Ruff (configuration in `pyproject.toml`):
177
+
178
+ ```bash
179
+ ruff check src/
180
+ ```
181
+
182
+ CI on `main` builds from `VERSION` and `pyproject_template.toml`, then
183
+ publishes to PyPI when `PYPI_API_TOKEN` is configured.
184
+
185
+ ## License
186
+
187
+ BSD-3-Clause — see [LICENSE](LICENSE).
188
+
@@ -0,0 +1,170 @@
1
+ # bigdata-corp-api
2
+
3
+ Python client library for BigDataCorp API endpoints used in Murabei data
4
+ enrichment and due-diligence workflows.
5
+
6
+ ## Objective and motivation
7
+
8
+ This package wraps BigDataCorp REST endpoints behind a typed Python API with
9
+ domain-specific exceptions and dataset discovery helpers.
10
+
11
+ ### Why this exists
12
+
13
+ Murabei services query BigDataCorp for CPF, CNPJ, and process data during
14
+ enrichment pipelines. A shared client avoids duplicating authentication,
15
+ retry logic, and error mapping across workers and applications.
16
+
17
+ ### How it is used
18
+
19
+ Install the package in workers or apps that call BigDataCorp during batch or
20
+ on-demand enrichment. Instantiate `BigDataCorpAPI` with an auth token, then
21
+ call dataset list or fetch methods.
22
+
23
+ ### Scope
24
+
25
+ Owns HTTP communication, dataset constants, exception types, retry and
26
+ pagination, parallel batch fetches, usage reporting, local CPF, CNPJ,
27
+ and CNJ checks, and certificate file downloads from on-demand
28
+ responses. Credential storage, orchestration, and downstream
29
+ persistence live in consuming services.
30
+
31
+ ## Install
32
+
33
+ From PyPI (when published):
34
+
35
+ ```bash
36
+ pip install bigdata-corp-api
37
+ ```
38
+
39
+ From a built wheel or sdist:
40
+
41
+ ```bash
42
+ pip install dist/bigdata_corp_api-*.whl
43
+ ```
44
+
45
+ From source (requires Poetry):
46
+
47
+ ```bash
48
+ pip install poetry
49
+ export VERSION=$(grep -E '^VERSION=' VERSION | cut -d'=' -f2-)
50
+ sed -e 's#{VERSION}#'"${VERSION}"'#g' pyproject_template.toml > pyproject.toml
51
+ poetry build
52
+ pip install dist/bigdata_corp_api-*.whl
53
+ ```
54
+
55
+ ## Quick start
56
+
57
+ ```python
58
+ from bigdatacorp_api.data import BigDataCorpAPI
59
+
60
+ api = BigDataCorpAPI(bigdata_auth_token="YOUR_TOKEN")
61
+
62
+ # List available CPF datasets
63
+ datasets = api.list_cpf_dataset()
64
+
65
+ # Fetch one dataset
66
+ result = api.get_cpf_dataset(
67
+ cpf="52998224725",
68
+ dataset="basic_data",
69
+ )
70
+
71
+ # Append dataset_params to the Datasets field
72
+ result = api.get_cnpj_dataset(
73
+ cnpj="00000000000191",
74
+ dataset="processes",
75
+ dataset_params="{NextPageId}.limit(500)",
76
+ )
77
+
78
+ # Fetch multiple datasets in parallel
79
+ batch = api.get_cpf_datasets(
80
+ cpf="52998224725",
81
+ datasets=["basic_data", "occupation_data"],
82
+ )
83
+
84
+ # Soft-fail non-critical errors; per-dataset q and Datasets suffixes
85
+ batch = api.get_cpf_datasets(
86
+ cpf="52998224725",
87
+ datasets=["basic_data", "processes"],
88
+ skip_errors=True,
89
+ query_params={"processes": ", returnupdates{false}"},
90
+ dataset_params={"processes": "{NextPageId}.limit(500)"},
91
+ )
92
+ # Soft failures are under batch["__errors__"]
93
+ ```
94
+
95
+ CNPJ and process queries follow the same pattern via `list_cnpj_dataset`,
96
+ `get_cnpj_dataset`, `list_process_dataset`, and `get_process_dataset`.
97
+ Fetch methods check CPF, CNPJ, and CNJ numbers locally and raise
98
+ `BigDataCorpAPIInvalidDocumentException` before the HTTP call.
99
+ Batch helpers accept `skip_errors`, a `query_params` mapping (suffix for
100
+ `q`), and a `dataset_params` mapping (suffix for `Datasets`).
101
+
102
+ Usage reporting for a date range:
103
+
104
+ ```python
105
+ usage = api.get_usage(
106
+ initial_date="2025-01-01",
107
+ final_date="2025-01-31",
108
+ )
109
+ ```
110
+
111
+ Download a certificate file from an on-demand dataset response:
112
+
113
+ ```python
114
+ cert_response = api.get_cpf_dataset(
115
+ cpf="52998224725",
116
+ dataset="ondemand_cert_debt_absence_by_state_person",
117
+ )
118
+ file_data = api.get_result_file(
119
+ dataset="ondemand_cert_debt_absence_by_state_person",
120
+ json_data=cert_response,
121
+ )
122
+ # file_data["file_type"] and file_data["file_content"]
123
+ ```
124
+
125
+ ## Configuration
126
+
127
+ The auth token is passed to `BigDataCorpAPI` at construction time.
128
+ Timeout, batch parallelism, and the pagination page cap are read from
129
+ the environment when set. A blank value keeps the default. Any other
130
+ value must be a positive integer.
131
+
132
+ | Variable | Required | Description |
133
+ |----------|----------|-------------|
134
+ | `BIGDATACORP__REQUEST_TIMEOUT` | No | HTTP timeout in seconds (default `60`) |
135
+ | `BIGDATACORP__N_PARALLEL` | No | Max threads for batch fetches (default `8`) |
136
+ | `BIGDATACORP__MAX_PAGES` | No | Extra pages after the first (default `200`) |
137
+ | `BIGDATA_AUTH_TOKEN` | Tests | Token for integration tests |
138
+ | `TEST_CPF` | Tests | Valid CPF for integration tests |
139
+ | `TEST_CNPJ` | Tests | Valid CNPJ for integration tests |
140
+
141
+ ## Development
142
+
143
+ Build a release (bumps patch in `VERSION`, renders `pyproject.toml`, tags,
144
+ and pushes):
145
+
146
+ ```bash
147
+ ./build.sh
148
+ ```
149
+
150
+ Run tests (integration tests call the live API when env vars are set):
151
+
152
+ ```bash
153
+ export BIGDATA_AUTH_TOKEN="your-token"
154
+ export TEST_CPF="valid-cpf"
155
+ export TEST_CNPJ="valid-cnpj"
156
+ python -m unittest discover -s src/bigdatacorp_api/tests
157
+ ```
158
+
159
+ Lint with Ruff (configuration in `pyproject.toml`):
160
+
161
+ ```bash
162
+ ruff check src/
163
+ ```
164
+
165
+ CI on `main` builds from `VERSION` and `pyproject_template.toml`, then
166
+ publishes to PyPI when `PYPI_API_TOKEN` is configured.
167
+
168
+ ## License
169
+
170
+ BSD-3-Clause — see [LICENSE](LICENSE).
@@ -1,19 +1,22 @@
1
1
  [project]
2
2
  name = "bigdata-corp-api"
3
- version = "0.16"
3
+ version = "0.18.9"
4
4
  description = "Python API to facilitate interaction with BigDataCorp end-points"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.6"
7
7
  license = { text = "BSD-3-Clause License" }
8
8
  authors = [
9
- {name = "André Andrade Baceti", email = "a.baceti@murabei.com"}
9
+ {name = "Murabei Data Science", email = "a.baceti@murabei.com"}
10
10
  ]
11
+ urls = { Homepage = "https://github.com/Murabei-OpenSource-Codes/bigdata-corp-api" }
11
12
  classifiers = [
12
13
  "Programming Language :: Python :: 3",
13
14
  "Operating System :: OS Independent",
14
15
  ]
15
16
  dependencies = [
16
- "requests"
17
+ "loguru",
18
+ "requests (>=2.32.5,<3.0.0)",
19
+ "tenacity (>=9.1.4,<10.0.0)"
17
20
  ]
18
21
 
19
22
  [tool.poetry]
@@ -31,8 +34,6 @@ indent-width = 4
31
34
  exclude = [
32
35
  "secrets/",
33
36
  "__init__.py",
34
- "setup_template.py",
35
- "setup.py"
36
37
  ]
37
38
 
38
39
  # Lista de linters que serão aplicados. o ruff da suporte a vários e eles podem ser adicionados aqui.
@@ -69,4 +70,4 @@ no-sections = true
69
70
  [dependency-groups]
70
71
  docs = [
71
72
  "mkdocs (>=1.6.1,<2.0.0)"
72
- ]
73
+ ]
@@ -0,0 +1,13 @@
1
+ """BigDataCorp API client package.
2
+
3
+ Provides ``BigDataCorpAPI`` for querying CPF, CNPJ, and process datasets,
4
+ plus domain-specific exceptions for API error handling.
5
+
6
+ Example:
7
+ Import the client from the ``data`` submodule::
8
+
9
+ from bigdatacorp_api.data import BigDataCorpAPI
10
+
11
+ api = BigDataCorpAPI(bigdata_auth_token="YOUR_TOKEN")
12
+ result = api.get_cpf_dataset(cpf="12345678901", dataset="basic_data")
13
+ """
@@ -0,0 +1,15 @@
1
+ """Auxiliary modules for BigDataCorp API."""
2
+
3
+ # Local imports
4
+ from bigdatacorp_api.aux.base import BaseBigDataCorpAPIMixin
5
+ from bigdatacorp_api.aux.person import PersonBigDataCorpAPIMixin
6
+ from bigdatacorp_api.aux.company import CompanyBigDataCorpAPIMixin
7
+ from bigdatacorp_api.aux.process import ProcessBigDataCorpAPIMixin
8
+ from bigdatacorp_api.aux.system import SystemBigDataCorpAPIMixin
9
+
10
+ __all__ = [
11
+ "BaseBigDataCorpAPIMixin",
12
+ "PersonBigDataCorpAPIMixin",
13
+ "CompanyBigDataCorpAPIMixin",
14
+ "ProcessBigDataCorpAPIMixin",
15
+ "SystemBigDataCorpAPIMixin"]