escavador-api 0.1.8__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.
- escavador_api-0.1.8/LICENSE +28 -0
- escavador_api-0.1.8/PKG-INFO +302 -0
- escavador_api-0.1.8/README.md +287 -0
- escavador_api-0.1.8/pyproject.toml +73 -0
- escavador_api-0.1.8/src/escavador_api/__init__.py +0 -0
- escavador_api-0.1.8/src/escavador_api/data.py +1288 -0
- escavador_api-0.1.8/src/escavador_api/exceptions.py +51 -0
- escavador_api-0.1.8/src/escavador_api/tests/__init__.py +0 -0
- escavador_api-0.1.8/src/escavador_api/tests/test__process_data.py +230 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023, Murabei Data Science
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: escavador-api
|
|
3
|
+
Version: 0.1.8
|
|
4
|
+
Summary: Python API to interact with Escavador endpoints
|
|
5
|
+
License: BSD-3-Clause License
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Author: André Andrade Baceti
|
|
8
|
+
Author-email: a.baceti@murabei.com
|
|
9
|
+
Requires-Python: >=3.12
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Dist: requests (>=2.32.5,<3.0.0)
|
|
13
|
+
Requires-Dist: tenacity (>=9.1.4,<10.0.0)
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# escavador-api
|
|
17
|
+
|
|
18
|
+
A Python library for interacting with the Escavador API, providing access to Brazilian legal process data, documents, and monitoring services.
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
- **Process Information**: Retrieve detailed information about legal processes using CNJ numbers
|
|
23
|
+
- **Process Movements**: Get chronological movement history of legal processes
|
|
24
|
+
- **Document Access**: Download public and restricted process documents
|
|
25
|
+
- **AI Summaries**: Generate and retrieve AI-powered process summaries
|
|
26
|
+
- **Process Monitoring**: Set up monitoring for new processes or updates to existing processes
|
|
27
|
+
- **Credit Management**: Check API usage credits and limits
|
|
28
|
+
- **Process Updates**: Request fresh data updates from court sources
|
|
29
|
+
- **Retry Logic**: Automatic retry with 5-second delays for network failures (max 5 retries)
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
### From Source
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
git clone https://github.com/Murabei-OpenSource-Codes/escavador-api.git
|
|
37
|
+
cd escavador-api
|
|
38
|
+
pip install .
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Requirements
|
|
42
|
+
|
|
43
|
+
- Python >= 3.12
|
|
44
|
+
- requests >= 2.32.5
|
|
45
|
+
|
|
46
|
+
## Quick Start
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from escavador_api import EscavadorAPI
|
|
50
|
+
|
|
51
|
+
# Initialize with your API token
|
|
52
|
+
api = EscavadorAPI("your_auth_token_here")
|
|
53
|
+
|
|
54
|
+
# Check credit balance
|
|
55
|
+
balance = api.get_credit_balance()
|
|
56
|
+
print(balance)
|
|
57
|
+
|
|
58
|
+
# Get process information
|
|
59
|
+
process_info = api.get_process_info("12345678901234567890")
|
|
60
|
+
print(process_info)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## API Reference
|
|
64
|
+
|
|
65
|
+
### Initialization
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
EscavadorAPI(escavador_auth_token: str)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Parameters:**
|
|
72
|
+
- `escavador_auth_token` (str): Your Escavador API authentication token
|
|
73
|
+
|
|
74
|
+
### Core Methods
|
|
75
|
+
|
|
76
|
+
#### Credit Management
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
get_credit_balance() -> dict
|
|
80
|
+
```
|
|
81
|
+
Returns current credit balance and monthly limits.
|
|
82
|
+
|
|
83
|
+
#### Process Information
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
get_process_info(process_number: str) -> dict
|
|
87
|
+
```
|
|
88
|
+
Retrieve basic process information.
|
|
89
|
+
|
|
90
|
+
**Parameters:**
|
|
91
|
+
- `process_number` (str): CNJ process number (20 digits, punctuation optional)
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
get_process_movements(process_number: str) -> list
|
|
95
|
+
```
|
|
96
|
+
Get all movements for a process.
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
get_process_public_documents(process_number: str) -> list
|
|
100
|
+
```
|
|
101
|
+
Get publicly available documents.
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
get_process_all_documents(process_number: str) -> list
|
|
105
|
+
```
|
|
106
|
+
Get all documents (public and restricted, if authorized).
|
|
107
|
+
|
|
108
|
+
#### Process Updates
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
request_process_update_public(process_number: str) -> dict
|
|
112
|
+
```
|
|
113
|
+
Request update of public process information.
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
request_process_update_full(
|
|
117
|
+
process_number: str,
|
|
118
|
+
auth_username: str = None,
|
|
119
|
+
auth_password: str = None,
|
|
120
|
+
certificate_id: int = None,
|
|
121
|
+
use_certificate: bool = False
|
|
122
|
+
) -> dict
|
|
123
|
+
```
|
|
124
|
+
Request full update including restricted documents.
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
get_process_update_status(process_number: str) -> dict
|
|
128
|
+
```
|
|
129
|
+
Check the status of an update request.
|
|
130
|
+
|
|
131
|
+
#### Document Downloads
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
download_process_file(process_number: str, file_key: str) -> bytes
|
|
135
|
+
```
|
|
136
|
+
Download a specific document as PDF bytes.
|
|
137
|
+
|
|
138
|
+
#### AI Summaries
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
request_ai_summary(process_number: str) -> dict
|
|
142
|
+
```
|
|
143
|
+
Request generation of an AI summary.
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
get_ai_summary_status(process_number: str, summary_id: int) -> dict
|
|
147
|
+
```
|
|
148
|
+
Check AI summary generation status.
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
get_ai_summary(process_number: str) -> dict
|
|
152
|
+
```
|
|
153
|
+
Retrieve the generated AI summary.
|
|
154
|
+
|
|
155
|
+
### Monitoring
|
|
156
|
+
|
|
157
|
+
#### New Process Monitoring
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
create_monitoring_new_process(
|
|
161
|
+
keyword: str,
|
|
162
|
+
keyword_variations: list[str] = None,
|
|
163
|
+
aux_keywords: list[KeywordDict] = None,
|
|
164
|
+
courts: list[str] = None
|
|
165
|
+
) -> dict
|
|
166
|
+
```
|
|
167
|
+
Create monitoring for new processes matching criteria.
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
list_monitoring_new_process() -> list
|
|
171
|
+
```
|
|
172
|
+
List all new process monitorings.
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
get_monitoring_new_process(monitoring_id: int) -> dict
|
|
176
|
+
```
|
|
177
|
+
Get details of a specific monitoring.
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
edit_monitoring_new_process(
|
|
181
|
+
monitoring_id: int,
|
|
182
|
+
keyword_variations: list[str] = None,
|
|
183
|
+
aux_keywords: list[KeywordDict] = None,
|
|
184
|
+
courts: list[str] = None
|
|
185
|
+
) -> dict
|
|
186
|
+
```
|
|
187
|
+
Edit an existing monitoring.
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
delete_monitoring_new_process(monitoring_id: int) -> bool
|
|
191
|
+
```
|
|
192
|
+
Delete a monitoring.
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
get_results_monitoring_new_process(monitoring_id: int) -> list
|
|
196
|
+
```
|
|
197
|
+
Get results from a monitoring.
|
|
198
|
+
|
|
199
|
+
#### Existing Process Monitoring
|
|
200
|
+
|
|
201
|
+
```python
|
|
202
|
+
create_monitoring_existing_process(
|
|
203
|
+
process_number: str,
|
|
204
|
+
court: str = None,
|
|
205
|
+
frequency: str = None
|
|
206
|
+
) -> dict
|
|
207
|
+
```
|
|
208
|
+
Monitor updates to an existing process.
|
|
209
|
+
|
|
210
|
+
```python
|
|
211
|
+
list_monitoring_existing_process() -> list
|
|
212
|
+
```
|
|
213
|
+
List existing process monitorings.
|
|
214
|
+
|
|
215
|
+
```python
|
|
216
|
+
get_monitoring_existing_process(monitoring_id: int) -> dict
|
|
217
|
+
```
|
|
218
|
+
Get monitoring details.
|
|
219
|
+
|
|
220
|
+
```python
|
|
221
|
+
delete_monitoring_existing_process(monitoring_id: int) -> bool
|
|
222
|
+
```
|
|
223
|
+
Delete monitoring.
|
|
224
|
+
|
|
225
|
+
## Error Handling
|
|
226
|
+
|
|
227
|
+
The library provides specific exception types:
|
|
228
|
+
|
|
229
|
+
- `EscavadorAPIInvalidDocumentException`: Invalid process number format
|
|
230
|
+
- `EscavadorAPIProblemAPIException`: API-specific errors (authentication, insufficient credits, etc.)
|
|
231
|
+
- `EscavadorAPIUnmappedErrorException`: Unexpected errors or network issues
|
|
232
|
+
|
|
233
|
+
## Retry Logic
|
|
234
|
+
|
|
235
|
+
All API calls include automatic retry logic:
|
|
236
|
+
- **Maximum retries**: 5 attempts
|
|
237
|
+
- **Retry delay**: 5 seconds between attempts
|
|
238
|
+
- **Retry conditions**: Network errors (connection failures, timeouts, chunked encoding errors)
|
|
239
|
+
- **Non-retryable errors**: Validation errors, HTTP errors (4xx/5xx), and API-specific exceptions
|
|
240
|
+
|
|
241
|
+
## Process Number Format
|
|
242
|
+
|
|
243
|
+
Process numbers must follow the Brazilian CNJ (Conselho Nacional de Justiça) format:
|
|
244
|
+
- 20 digits total
|
|
245
|
+
- Format: NNNNNNN-DD.AAAA.J.TR.OOOO
|
|
246
|
+
|
|
247
|
+
The library automatically validates process numbers and accepts them with or without punctuation.
|
|
248
|
+
|
|
249
|
+
## Authentication
|
|
250
|
+
|
|
251
|
+
To use the Escavador API, you need:
|
|
252
|
+
1. An Escavador account
|
|
253
|
+
2. An API authentication token
|
|
254
|
+
3. Sufficient credits for API calls
|
|
255
|
+
|
|
256
|
+
For restricted documents, additional authentication may be required (username/password or digital certificate).
|
|
257
|
+
|
|
258
|
+
## Development
|
|
259
|
+
|
|
260
|
+
### Setup
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
# Install dependencies
|
|
264
|
+
pip install -e .
|
|
265
|
+
|
|
266
|
+
# Run tests
|
|
267
|
+
pytest
|
|
268
|
+
|
|
269
|
+
# Build package
|
|
270
|
+
./build.sh
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Testing
|
|
274
|
+
|
|
275
|
+
Tests require environment variables:
|
|
276
|
+
- `ESCAVADOR_AUTH_TOKEN`: Your API token
|
|
277
|
+
- `TEST_PROCESS_NUMBER`: A valid CNJ process number for testing
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
export ESCAVADOR_AUTH_TOKEN="your_token"
|
|
281
|
+
export TEST_PROCESS_NUMBER="process_number"
|
|
282
|
+
pytest
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## License
|
|
286
|
+
|
|
287
|
+
BSD 3-Clause License - see [LICENSE](LICENSE) file for details.
|
|
288
|
+
|
|
289
|
+
## Contributing
|
|
290
|
+
|
|
291
|
+
1. Fork the repository
|
|
292
|
+
2. Create a feature branch
|
|
293
|
+
3. Make your changes
|
|
294
|
+
4. Add tests
|
|
295
|
+
5. Submit a pull request
|
|
296
|
+
|
|
297
|
+
## Support
|
|
298
|
+
|
|
299
|
+
For issues and questions:
|
|
300
|
+
- Check the [Escavador API documentation](https://api.escavador.com/)
|
|
301
|
+
- Open an issue on GitHub
|
|
302
|
+
- Contact Murabei Data Science at a.baceti@murabei.com
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
# escavador-api
|
|
2
|
+
|
|
3
|
+
A Python library for interacting with the Escavador API, providing access to Brazilian legal process data, documents, and monitoring services.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Process Information**: Retrieve detailed information about legal processes using CNJ numbers
|
|
8
|
+
- **Process Movements**: Get chronological movement history of legal processes
|
|
9
|
+
- **Document Access**: Download public and restricted process documents
|
|
10
|
+
- **AI Summaries**: Generate and retrieve AI-powered process summaries
|
|
11
|
+
- **Process Monitoring**: Set up monitoring for new processes or updates to existing processes
|
|
12
|
+
- **Credit Management**: Check API usage credits and limits
|
|
13
|
+
- **Process Updates**: Request fresh data updates from court sources
|
|
14
|
+
- **Retry Logic**: Automatic retry with 5-second delays for network failures (max 5 retries)
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
### From Source
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
git clone https://github.com/Murabei-OpenSource-Codes/escavador-api.git
|
|
22
|
+
cd escavador-api
|
|
23
|
+
pip install .
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Requirements
|
|
27
|
+
|
|
28
|
+
- Python >= 3.12
|
|
29
|
+
- requests >= 2.32.5
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from escavador_api import EscavadorAPI
|
|
35
|
+
|
|
36
|
+
# Initialize with your API token
|
|
37
|
+
api = EscavadorAPI("your_auth_token_here")
|
|
38
|
+
|
|
39
|
+
# Check credit balance
|
|
40
|
+
balance = api.get_credit_balance()
|
|
41
|
+
print(balance)
|
|
42
|
+
|
|
43
|
+
# Get process information
|
|
44
|
+
process_info = api.get_process_info("12345678901234567890")
|
|
45
|
+
print(process_info)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## API Reference
|
|
49
|
+
|
|
50
|
+
### Initialization
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
EscavadorAPI(escavador_auth_token: str)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Parameters:**
|
|
57
|
+
- `escavador_auth_token` (str): Your Escavador API authentication token
|
|
58
|
+
|
|
59
|
+
### Core Methods
|
|
60
|
+
|
|
61
|
+
#### Credit Management
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
get_credit_balance() -> dict
|
|
65
|
+
```
|
|
66
|
+
Returns current credit balance and monthly limits.
|
|
67
|
+
|
|
68
|
+
#### Process Information
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
get_process_info(process_number: str) -> dict
|
|
72
|
+
```
|
|
73
|
+
Retrieve basic process information.
|
|
74
|
+
|
|
75
|
+
**Parameters:**
|
|
76
|
+
- `process_number` (str): CNJ process number (20 digits, punctuation optional)
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
get_process_movements(process_number: str) -> list
|
|
80
|
+
```
|
|
81
|
+
Get all movements for a process.
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
get_process_public_documents(process_number: str) -> list
|
|
85
|
+
```
|
|
86
|
+
Get publicly available documents.
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
get_process_all_documents(process_number: str) -> list
|
|
90
|
+
```
|
|
91
|
+
Get all documents (public and restricted, if authorized).
|
|
92
|
+
|
|
93
|
+
#### Process Updates
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
request_process_update_public(process_number: str) -> dict
|
|
97
|
+
```
|
|
98
|
+
Request update of public process information.
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
request_process_update_full(
|
|
102
|
+
process_number: str,
|
|
103
|
+
auth_username: str = None,
|
|
104
|
+
auth_password: str = None,
|
|
105
|
+
certificate_id: int = None,
|
|
106
|
+
use_certificate: bool = False
|
|
107
|
+
) -> dict
|
|
108
|
+
```
|
|
109
|
+
Request full update including restricted documents.
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
get_process_update_status(process_number: str) -> dict
|
|
113
|
+
```
|
|
114
|
+
Check the status of an update request.
|
|
115
|
+
|
|
116
|
+
#### Document Downloads
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
download_process_file(process_number: str, file_key: str) -> bytes
|
|
120
|
+
```
|
|
121
|
+
Download a specific document as PDF bytes.
|
|
122
|
+
|
|
123
|
+
#### AI Summaries
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
request_ai_summary(process_number: str) -> dict
|
|
127
|
+
```
|
|
128
|
+
Request generation of an AI summary.
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
get_ai_summary_status(process_number: str, summary_id: int) -> dict
|
|
132
|
+
```
|
|
133
|
+
Check AI summary generation status.
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
get_ai_summary(process_number: str) -> dict
|
|
137
|
+
```
|
|
138
|
+
Retrieve the generated AI summary.
|
|
139
|
+
|
|
140
|
+
### Monitoring
|
|
141
|
+
|
|
142
|
+
#### New Process Monitoring
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
create_monitoring_new_process(
|
|
146
|
+
keyword: str,
|
|
147
|
+
keyword_variations: list[str] = None,
|
|
148
|
+
aux_keywords: list[KeywordDict] = None,
|
|
149
|
+
courts: list[str] = None
|
|
150
|
+
) -> dict
|
|
151
|
+
```
|
|
152
|
+
Create monitoring for new processes matching criteria.
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
list_monitoring_new_process() -> list
|
|
156
|
+
```
|
|
157
|
+
List all new process monitorings.
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
get_monitoring_new_process(monitoring_id: int) -> dict
|
|
161
|
+
```
|
|
162
|
+
Get details of a specific monitoring.
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
edit_monitoring_new_process(
|
|
166
|
+
monitoring_id: int,
|
|
167
|
+
keyword_variations: list[str] = None,
|
|
168
|
+
aux_keywords: list[KeywordDict] = None,
|
|
169
|
+
courts: list[str] = None
|
|
170
|
+
) -> dict
|
|
171
|
+
```
|
|
172
|
+
Edit an existing monitoring.
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
delete_monitoring_new_process(monitoring_id: int) -> bool
|
|
176
|
+
```
|
|
177
|
+
Delete a monitoring.
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
get_results_monitoring_new_process(monitoring_id: int) -> list
|
|
181
|
+
```
|
|
182
|
+
Get results from a monitoring.
|
|
183
|
+
|
|
184
|
+
#### Existing Process Monitoring
|
|
185
|
+
|
|
186
|
+
```python
|
|
187
|
+
create_monitoring_existing_process(
|
|
188
|
+
process_number: str,
|
|
189
|
+
court: str = None,
|
|
190
|
+
frequency: str = None
|
|
191
|
+
) -> dict
|
|
192
|
+
```
|
|
193
|
+
Monitor updates to an existing process.
|
|
194
|
+
|
|
195
|
+
```python
|
|
196
|
+
list_monitoring_existing_process() -> list
|
|
197
|
+
```
|
|
198
|
+
List existing process monitorings.
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
get_monitoring_existing_process(monitoring_id: int) -> dict
|
|
202
|
+
```
|
|
203
|
+
Get monitoring details.
|
|
204
|
+
|
|
205
|
+
```python
|
|
206
|
+
delete_monitoring_existing_process(monitoring_id: int) -> bool
|
|
207
|
+
```
|
|
208
|
+
Delete monitoring.
|
|
209
|
+
|
|
210
|
+
## Error Handling
|
|
211
|
+
|
|
212
|
+
The library provides specific exception types:
|
|
213
|
+
|
|
214
|
+
- `EscavadorAPIInvalidDocumentException`: Invalid process number format
|
|
215
|
+
- `EscavadorAPIProblemAPIException`: API-specific errors (authentication, insufficient credits, etc.)
|
|
216
|
+
- `EscavadorAPIUnmappedErrorException`: Unexpected errors or network issues
|
|
217
|
+
|
|
218
|
+
## Retry Logic
|
|
219
|
+
|
|
220
|
+
All API calls include automatic retry logic:
|
|
221
|
+
- **Maximum retries**: 5 attempts
|
|
222
|
+
- **Retry delay**: 5 seconds between attempts
|
|
223
|
+
- **Retry conditions**: Network errors (connection failures, timeouts, chunked encoding errors)
|
|
224
|
+
- **Non-retryable errors**: Validation errors, HTTP errors (4xx/5xx), and API-specific exceptions
|
|
225
|
+
|
|
226
|
+
## Process Number Format
|
|
227
|
+
|
|
228
|
+
Process numbers must follow the Brazilian CNJ (Conselho Nacional de Justiça) format:
|
|
229
|
+
- 20 digits total
|
|
230
|
+
- Format: NNNNNNN-DD.AAAA.J.TR.OOOO
|
|
231
|
+
|
|
232
|
+
The library automatically validates process numbers and accepts them with or without punctuation.
|
|
233
|
+
|
|
234
|
+
## Authentication
|
|
235
|
+
|
|
236
|
+
To use the Escavador API, you need:
|
|
237
|
+
1. An Escavador account
|
|
238
|
+
2. An API authentication token
|
|
239
|
+
3. Sufficient credits for API calls
|
|
240
|
+
|
|
241
|
+
For restricted documents, additional authentication may be required (username/password or digital certificate).
|
|
242
|
+
|
|
243
|
+
## Development
|
|
244
|
+
|
|
245
|
+
### Setup
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
# Install dependencies
|
|
249
|
+
pip install -e .
|
|
250
|
+
|
|
251
|
+
# Run tests
|
|
252
|
+
pytest
|
|
253
|
+
|
|
254
|
+
# Build package
|
|
255
|
+
./build.sh
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Testing
|
|
259
|
+
|
|
260
|
+
Tests require environment variables:
|
|
261
|
+
- `ESCAVADOR_AUTH_TOKEN`: Your API token
|
|
262
|
+
- `TEST_PROCESS_NUMBER`: A valid CNJ process number for testing
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
export ESCAVADOR_AUTH_TOKEN="your_token"
|
|
266
|
+
export TEST_PROCESS_NUMBER="process_number"
|
|
267
|
+
pytest
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## License
|
|
271
|
+
|
|
272
|
+
BSD 3-Clause License - see [LICENSE](LICENSE) file for details.
|
|
273
|
+
|
|
274
|
+
## Contributing
|
|
275
|
+
|
|
276
|
+
1. Fork the repository
|
|
277
|
+
2. Create a feature branch
|
|
278
|
+
3. Make your changes
|
|
279
|
+
4. Add tests
|
|
280
|
+
5. Submit a pull request
|
|
281
|
+
|
|
282
|
+
## Support
|
|
283
|
+
|
|
284
|
+
For issues and questions:
|
|
285
|
+
- Check the [Escavador API documentation](https://api.escavador.com/)
|
|
286
|
+
- Open an issue on GitHub
|
|
287
|
+
- Contact Murabei Data Science at a.baceti@murabei.com
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "escavador-api"
|
|
3
|
+
version = "0.1.8"
|
|
4
|
+
description = "Python API to interact with Escavador endpoints"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.12"
|
|
7
|
+
license = { text = "BSD-3-Clause License" }
|
|
8
|
+
authors = [
|
|
9
|
+
{name = "André Andrade Baceti", email = "a.baceti@murabei.com"}
|
|
10
|
+
]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Programming Language :: Python :: 3",
|
|
13
|
+
"Operating System :: OS Independent",
|
|
14
|
+
]
|
|
15
|
+
dependencies = [
|
|
16
|
+
"requests (>=2.32.5,<3.0.0)",
|
|
17
|
+
"tenacity (>=9.1.4,<10.0.0)"
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[tool.poetry]
|
|
21
|
+
packages = [{include = "escavador_api", from = "src"}]
|
|
22
|
+
|
|
23
|
+
[build-system]
|
|
24
|
+
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
|
25
|
+
build-backend = "poetry.core.masonry.api"
|
|
26
|
+
|
|
27
|
+
[tool.ruff]
|
|
28
|
+
line-length = 79 # Quantidade de caracteres que o linter irá considerar na linha
|
|
29
|
+
indent-width = 4
|
|
30
|
+
|
|
31
|
+
# Pastas onde o linter não atuara. Por padrão ele só lê arquivos python e ignora tudo dentro do .gitignore
|
|
32
|
+
exclude = [
|
|
33
|
+
"secrets/",
|
|
34
|
+
"__init__.py",
|
|
35
|
+
"setup_template.py",
|
|
36
|
+
"setup.py"
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
# Lista de linters que serão aplicados. o ruff da suporte a vários e eles podem ser adicionados aqui.
|
|
40
|
+
[tool.ruff.lint]
|
|
41
|
+
select = [
|
|
42
|
+
"F", # Pyflakes - Procura bugs básicos no codigo
|
|
43
|
+
"E", # pycodestyle - Pep8
|
|
44
|
+
"W", # pycodestyle - Pep8
|
|
45
|
+
"D", # pydocstyle - Docstring
|
|
46
|
+
"I", # Isort - Imports
|
|
47
|
+
"PD", # pandas-vet - linter de pandas (não deixa usar inplace nem df como nome de variavel)
|
|
48
|
+
"N", # pep8-naming - nomes seguindo pep8
|
|
49
|
+
"S", # flake8-bandit - linter de vulnerabilidade (nmao deixa usar assert)
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
# Os códigos de erros colocados aqui são ignorados pelo linter. O erro abaixo é em relação ao assert. Está comentado por padrão.
|
|
53
|
+
ignore = [
|
|
54
|
+
# "S101" # Use of `assert` detected
|
|
55
|
+
"E402", "N806", "I001"
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
# ativa um modo plus do ruff
|
|
59
|
+
preview = true
|
|
60
|
+
|
|
61
|
+
[tool.ruff.format]
|
|
62
|
+
indent-style = "space"
|
|
63
|
+
|
|
64
|
+
[tool.ruff.lint.pydocstyle]
|
|
65
|
+
convention = "google" # seleciona as docstrings do google como padrão
|
|
66
|
+
|
|
67
|
+
[tool.ruff.lint.isort]
|
|
68
|
+
no-sections = true
|
|
69
|
+
|
|
70
|
+
[dependency-groups]
|
|
71
|
+
docs = [
|
|
72
|
+
"mkdocs (>=1.6.1,<2.0.0)"
|
|
73
|
+
]
|
|
File without changes
|