apiverve-cashflowstatement 1.2.2__py3-none-any.whl
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.
- apiverve_cashflowstatement/__init__.py +3 -0
- apiverve_cashflowstatement/apiClient.py +252 -0
- apiverve_cashflowstatement/exceptions.py +3 -0
- apiverve_cashflowstatement/setup.py +26 -0
- apiverve_cashflowstatement/setup_dep.py +21 -0
- apiverve_cashflowstatement/tests/__init__.py +1 -0
- apiverve_cashflowstatement/tests/test_api.py +19 -0
- apiverve_cashflowstatement-1.2.2.dist-info/METADATA +337 -0
- apiverve_cashflowstatement-1.2.2.dist-info/RECORD +12 -0
- apiverve_cashflowstatement-1.2.2.dist-info/WHEEL +5 -0
- apiverve_cashflowstatement-1.2.2.dist-info/licenses/LICENSE +21 -0
- apiverve_cashflowstatement-1.2.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from typing import Dict, Optional, Any, List
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
import requests
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class CashflowAPIClientError(Exception):
|
|
8
|
+
"""Custom exception for API client errors"""
|
|
9
|
+
def __init__(self, message: str, status_code: Optional[int] = None, response: Optional[Dict] = None):
|
|
10
|
+
self.message = message
|
|
11
|
+
self.status_code = status_code
|
|
12
|
+
self.response = response
|
|
13
|
+
super().__init__(self.message)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ValidationError(CashflowAPIClientError):
|
|
17
|
+
"""Custom exception for parameter validation errors"""
|
|
18
|
+
def __init__(self, errors: List[str]):
|
|
19
|
+
self.errors = errors
|
|
20
|
+
message = f"Validation failed: {' '.join(errors)}"
|
|
21
|
+
super().__init__(message)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class CashflowAPIClient:
|
|
25
|
+
# Validation rules for parameters (generated from schema)
|
|
26
|
+
VALIDATION_RULES = {
|
|
27
|
+
"ticker": {"type": "string", "required": True, "minLength": 1, "maxLength": 6},
|
|
28
|
+
"year": {"type": "integer", "required": False, "min": 2000, "max": 2030},
|
|
29
|
+
"quarter": {"type": "integer", "required": False, "min": 1, "max": 4}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
# Format validation patterns
|
|
33
|
+
FORMAT_PATTERNS = {
|
|
34
|
+
'email': r'^[^\s@]+@[^\s@]+\.[^\s@]+$',
|
|
35
|
+
'url': r'^https?://.+',
|
|
36
|
+
'ip': r'^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$|^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$',
|
|
37
|
+
'date': r'^\d{4}-\d{2}-\d{2}$',
|
|
38
|
+
'hexColor': r'^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
def __init__(self, api_key: str, secure: bool = True, debug: bool = False):
|
|
42
|
+
"""
|
|
43
|
+
Initialize the CashflowAPIClient with the API key and optional settings
|
|
44
|
+
|
|
45
|
+
:param api_key: Your APIVerve API key
|
|
46
|
+
:param secure: Deprecated. Always set to True
|
|
47
|
+
:param debug: Enable debug logging (default: False)
|
|
48
|
+
:raises CashflowAPIClientError: If API key is invalid
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
self._validate_api_key(api_key)
|
|
52
|
+
|
|
53
|
+
self.api_key = api_key
|
|
54
|
+
self.secure = secure
|
|
55
|
+
self.debug = debug
|
|
56
|
+
self.base_url = 'https://api.apiverve.com/v1/cashflow'
|
|
57
|
+
self.headers = {
|
|
58
|
+
'x-api-key': self.api_key,
|
|
59
|
+
'auth-mode': 'pypi-package'
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
# Create a session for connection pooling
|
|
63
|
+
self.session = requests.Session()
|
|
64
|
+
self.session.headers.update(self.headers)
|
|
65
|
+
|
|
66
|
+
def _validate_api_key(self, api_key: str) -> None:
|
|
67
|
+
"""
|
|
68
|
+
Validate the API key format
|
|
69
|
+
|
|
70
|
+
:param api_key: API key to validate
|
|
71
|
+
:raises CashflowAPIClientError: If API key is invalid
|
|
72
|
+
"""
|
|
73
|
+
if not api_key or not api_key.strip():
|
|
74
|
+
raise CashflowAPIClientError(
|
|
75
|
+
"API key is required. Get your API key at: https://apiverve.com"
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
# Check format (GUID, prefixed keys like apv_xxx, or alphanumeric)
|
|
79
|
+
if not re.match(r'^[a-zA-Z0-9_-]+$', api_key):
|
|
80
|
+
raise CashflowAPIClientError(
|
|
81
|
+
"Invalid API key format. API key should only contain letters, numbers, hyphens, and underscores. "
|
|
82
|
+
"Get your API key at: https://apiverve.com"
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
def _log(self, message: str) -> None:
|
|
86
|
+
"""
|
|
87
|
+
Log a debug message if debug mode is enabled
|
|
88
|
+
|
|
89
|
+
:param message: Message to log
|
|
90
|
+
"""
|
|
91
|
+
if self.debug:
|
|
92
|
+
print(f"[CashflowAPIClient DEBUG] {message}")
|
|
93
|
+
|
|
94
|
+
def _validate_params(self, params: Optional[Dict[str, Any]]) -> None:
|
|
95
|
+
"""
|
|
96
|
+
Validate parameters against schema rules
|
|
97
|
+
|
|
98
|
+
:param params: Parameters to validate
|
|
99
|
+
:raises ValidationError: If validation fails
|
|
100
|
+
"""
|
|
101
|
+
if not self.VALIDATION_RULES:
|
|
102
|
+
return
|
|
103
|
+
|
|
104
|
+
errors = []
|
|
105
|
+
params = params or {}
|
|
106
|
+
|
|
107
|
+
for param_name, rules in self.VALIDATION_RULES.items():
|
|
108
|
+
value = params.get(param_name)
|
|
109
|
+
|
|
110
|
+
# Check required
|
|
111
|
+
if rules.get('required') and (value is None or value == ''):
|
|
112
|
+
errors.append(f"Required parameter [{param_name}] is missing.")
|
|
113
|
+
continue
|
|
114
|
+
|
|
115
|
+
# Skip validation if value is not provided and not required
|
|
116
|
+
if value is None:
|
|
117
|
+
continue
|
|
118
|
+
|
|
119
|
+
param_type = rules.get('type', 'string')
|
|
120
|
+
|
|
121
|
+
# Type validation
|
|
122
|
+
if param_type in ('integer', 'number'):
|
|
123
|
+
try:
|
|
124
|
+
num_value = float(value) if param_type == 'number' else int(value)
|
|
125
|
+
|
|
126
|
+
# Min/max validation
|
|
127
|
+
if 'min' in rules and num_value < rules['min']:
|
|
128
|
+
errors.append(f"Parameter [{param_name}] must be at least {rules['min']}.")
|
|
129
|
+
if 'max' in rules and num_value > rules['max']:
|
|
130
|
+
errors.append(f"Parameter [{param_name}] must be at most {rules['max']}.")
|
|
131
|
+
except (ValueError, TypeError):
|
|
132
|
+
errors.append(f"Parameter [{param_name}] must be a valid {param_type}.")
|
|
133
|
+
continue
|
|
134
|
+
|
|
135
|
+
elif param_type == 'string':
|
|
136
|
+
if not isinstance(value, str):
|
|
137
|
+
errors.append(f"Parameter [{param_name}] must be a string.")
|
|
138
|
+
continue
|
|
139
|
+
|
|
140
|
+
# Length validation
|
|
141
|
+
if 'minLength' in rules and len(value) < rules['minLength']:
|
|
142
|
+
errors.append(f"Parameter [{param_name}] must be at least {rules['minLength']} characters.")
|
|
143
|
+
if 'maxLength' in rules and len(value) > rules['maxLength']:
|
|
144
|
+
errors.append(f"Parameter [{param_name}] must be at most {rules['maxLength']} characters.")
|
|
145
|
+
|
|
146
|
+
# Format validation
|
|
147
|
+
if 'format' in rules and rules['format'] in self.FORMAT_PATTERNS:
|
|
148
|
+
pattern = self.FORMAT_PATTERNS[rules['format']]
|
|
149
|
+
if not re.match(pattern, value, re.IGNORECASE):
|
|
150
|
+
errors.append(f"Parameter [{param_name}] must be a valid {rules['format']}.")
|
|
151
|
+
|
|
152
|
+
elif param_type == 'boolean':
|
|
153
|
+
if not isinstance(value, bool) and value not in ('true', 'false', True, False):
|
|
154
|
+
errors.append(f"Parameter [{param_name}] must be a boolean.")
|
|
155
|
+
|
|
156
|
+
elif param_type == 'array':
|
|
157
|
+
if not isinstance(value, list):
|
|
158
|
+
errors.append(f"Parameter [{param_name}] must be an array.")
|
|
159
|
+
|
|
160
|
+
# Enum validation
|
|
161
|
+
if 'enum' in rules and value not in rules['enum']:
|
|
162
|
+
errors.append(f"Parameter [{param_name}] must be one of: {', '.join(map(str, rules['enum']))}.")
|
|
163
|
+
|
|
164
|
+
if errors:
|
|
165
|
+
raise ValidationError(errors)
|
|
166
|
+
|
|
167
|
+
def execute(self, params: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: # Returns CashFlowStatementData in 'data' field
|
|
168
|
+
"""
|
|
169
|
+
Execute the API request
|
|
170
|
+
|
|
171
|
+
:param params: API parameters (optional)
|
|
172
|
+
:return: API response as a dictionary
|
|
173
|
+
:raises CashflowAPIClientError: If the request fails or returns an error
|
|
174
|
+
:raises ValidationError: If parameter validation fails
|
|
175
|
+
"""
|
|
176
|
+
|
|
177
|
+
# Validate parameters against schema rules
|
|
178
|
+
self._validate_params(params)
|
|
179
|
+
|
|
180
|
+
method = "GET"
|
|
181
|
+
|
|
182
|
+
self._log(f"Making {method} request to {self.base_url}")
|
|
183
|
+
if params:
|
|
184
|
+
self._log(f"Parameters: {params}")
|
|
185
|
+
|
|
186
|
+
try:
|
|
187
|
+
if method.upper() == 'POST':
|
|
188
|
+
self._log("Sending POST request with JSON body")
|
|
189
|
+
response = self.session.post(self.base_url, json=params, timeout=30)
|
|
190
|
+
else:
|
|
191
|
+
self._log("Sending GET request with query parameters")
|
|
192
|
+
response = self.session.get(self.base_url, params=params, timeout=30)
|
|
193
|
+
|
|
194
|
+
self._log(f"Response status code: {response.status_code}")
|
|
195
|
+
|
|
196
|
+
# Try to parse JSON response
|
|
197
|
+
try:
|
|
198
|
+
response_data = response.json()
|
|
199
|
+
except ValueError as e:
|
|
200
|
+
raise CashflowAPIClientError(
|
|
201
|
+
f"Invalid JSON response from API: {str(e)}",
|
|
202
|
+
status_code=response.status_code
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
# Check for API-level errors in the response
|
|
206
|
+
if response_data.get('status') == 'error':
|
|
207
|
+
error_message = response_data.get('error', 'Unknown API error')
|
|
208
|
+
self._log(f"API returned error: {error_message}")
|
|
209
|
+
raise CashflowAPIClientError(
|
|
210
|
+
error_message,
|
|
211
|
+
status_code=response.status_code,
|
|
212
|
+
response=response_data
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
# Check HTTP status code
|
|
216
|
+
if not response.ok:
|
|
217
|
+
error_message = response_data.get('error', f"HTTP {response.status_code} error")
|
|
218
|
+
self._log(f"HTTP error: {error_message}")
|
|
219
|
+
raise CashflowAPIClientError(
|
|
220
|
+
error_message,
|
|
221
|
+
status_code=response.status_code,
|
|
222
|
+
response=response_data
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
self._log("Request successful")
|
|
226
|
+
return response_data
|
|
227
|
+
|
|
228
|
+
except requests.exceptions.Timeout as e:
|
|
229
|
+
self._log(f"Request timeout: {str(e)}")
|
|
230
|
+
raise CashflowAPIClientError(f"Request timeout: {str(e)}")
|
|
231
|
+
except requests.exceptions.ConnectionError as e:
|
|
232
|
+
self._log(f"Connection error: {str(e)}")
|
|
233
|
+
raise CashflowAPIClientError(f"Connection error: {str(e)}")
|
|
234
|
+
except requests.exceptions.RequestException as e:
|
|
235
|
+
self._log(f"Request exception: {str(e)}")
|
|
236
|
+
raise CashflowAPIClientError(f"Request failed: {str(e)}")
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def close(self) -> None:
|
|
240
|
+
"""
|
|
241
|
+
Close the session and release resources
|
|
242
|
+
"""
|
|
243
|
+
self._log("Closing session")
|
|
244
|
+
self.session.close()
|
|
245
|
+
|
|
246
|
+
def __enter__(self):
|
|
247
|
+
"""Context manager entry"""
|
|
248
|
+
return self
|
|
249
|
+
|
|
250
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
251
|
+
"""Context manager exit"""
|
|
252
|
+
self.close()
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
lib_folder = os.path.dirname(os.path.realpath(__file__))
|
|
5
|
+
requirements_file = os.path.join(lib_folder, 'requirements.txt')
|
|
6
|
+
install_requires = ["requests >= 2.25.1", "setuptools >= 56.0.0"]
|
|
7
|
+
if os.path.exists(requirements_file):
|
|
8
|
+
with open(requirements_file, 'r') as f:
|
|
9
|
+
install_requires = f.read().splitlines()
|
|
10
|
+
|
|
11
|
+
setup(
|
|
12
|
+
name='apiverve_cashflowstatement',
|
|
13
|
+
version='1.2.2',
|
|
14
|
+
packages=find_packages(),
|
|
15
|
+
include_package_data=True,
|
|
16
|
+
install_requires=install_requires,
|
|
17
|
+
description='Cash Flow Statement returns operating, investing and financing cash flows for a US public company by ticker - straight from SEC filings, with free cash flow, FCF margin and cash-conversion metrics calculated for you.',
|
|
18
|
+
author='APIVerve',
|
|
19
|
+
author_email='hello@apiverve.com',
|
|
20
|
+
url='https://apiverve.com/marketplace/cashflow?utm_source=pypi&utm_medium=referral&utm_content=homepage',
|
|
21
|
+
classifiers=[
|
|
22
|
+
'Programming Language :: Python :: 3',
|
|
23
|
+
'Operating System :: OS Independent',
|
|
24
|
+
],
|
|
25
|
+
python_requires='>=3.6',
|
|
26
|
+
)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name='apiverve_cashflowstatement',
|
|
5
|
+
version='1.2.2',
|
|
6
|
+
packages=find_packages(),
|
|
7
|
+
include_package_data=True,
|
|
8
|
+
install_requires=[
|
|
9
|
+
'requests',
|
|
10
|
+
'setuptools'
|
|
11
|
+
],
|
|
12
|
+
description='Cash Flow Statement returns operating, investing and financing cash flows for a US public company by ticker - straight from SEC filings, with free cash flow, FCF margin and cash-conversion metrics calculated for you.',
|
|
13
|
+
author='APIVerve',
|
|
14
|
+
author_email='hello@apiverve.com',
|
|
15
|
+
url='https://apiverve.com/marketplace/cashflow?utm_source=pypi&utm_medium=referral&utm_content=homepage',
|
|
16
|
+
classifiers=[
|
|
17
|
+
'Programming Language :: Python :: 3',
|
|
18
|
+
'Operating System :: OS Independent',
|
|
19
|
+
],
|
|
20
|
+
python_requires='>=3.6',
|
|
21
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Initialize test module
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
from apiverve_cashflowstatement.apiClient import CashflowAPIClient
|
|
3
|
+
|
|
4
|
+
class TestClient(unittest.TestCase):
|
|
5
|
+
|
|
6
|
+
def setUp(self):
|
|
7
|
+
self.api_key = 'test_api_key'
|
|
8
|
+
self.client = CashflowAPIClient(self.api_key)
|
|
9
|
+
|
|
10
|
+
def test_get(self):
|
|
11
|
+
# Assuming there's an endpoint 'test_endpoint' for testing purposes
|
|
12
|
+
try:
|
|
13
|
+
response = self.client.get('test_endpoint')
|
|
14
|
+
self.assertIsInstance(response, dict)
|
|
15
|
+
except Exception as e:
|
|
16
|
+
self.fail(f"GET request failed with exception {e}")
|
|
17
|
+
|
|
18
|
+
if __name__ == '__main__':
|
|
19
|
+
unittest.main()
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: apiverve-cashflowstatement
|
|
3
|
+
Version: 1.2.2
|
|
4
|
+
Summary: Cash Flow Statement returns operating, investing and financing cash flows for a US public company by ticker - straight from SEC filings, with free cash flow, FCF margin and cash-conversion metrics calculated for you.
|
|
5
|
+
Author-email: APIVerve <hello@apiverve.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://apiverve.com/marketplace/cashflow?utm_source=pypi&utm_medium=referral&utm_content=homepage
|
|
8
|
+
Project-URL: Documentation, https://docs.apiverve.com/ref/cashflow?utm_source=pypi&utm_medium=referral&utm_content=docs
|
|
9
|
+
Project-URL: Repository, https://github.com/apiverve/cashflow-api
|
|
10
|
+
Project-URL: Twitter, https://twitter.com/apivervehq
|
|
11
|
+
Keywords: cash flow api,cash flow statement api,free cash flow api,fcf api,operating cash flow api
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Classifier: Natural Language :: English
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: requests>=2.25.0
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
Cash Flow Statement API
|
|
26
|
+
============
|
|
27
|
+
|
|
28
|
+
Cash Flow Statement returns operating, investing and financing cash flows for a US public company by ticker - straight from SEC filings, with free cash flow, FCF margin and cash-conversion metrics calculated for you.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
[](https://pypi.org/project/apiverve-cashflowstatement/)
|
|
32
|
+
|
|
33
|
+
This is a Python wrapper for the [Cash Flow Statement API](https://apiverve.com/marketplace/cashflow?utm_source=pypi&utm_medium=referral&utm_content=readme)
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
Using `pip`:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install apiverve-cashflowstatement
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Using `pip3`:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip3 install apiverve-cashflowstatement
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
55
|
+
Before using the Cash Flow Statement API client, you have to setup your account and obtain your API Key.
|
|
56
|
+
You can get it by signing up at [https://apiverve.com](https://apiverve.com?utm_source=pypi&utm_medium=referral&utm_content=readme)
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Quick Start
|
|
61
|
+
|
|
62
|
+
Here's a simple example to get you started quickly:
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from apiverve_cashflowstatement.apiClient import CashflowAPIClient
|
|
66
|
+
|
|
67
|
+
# Initialize the client with your APIVerve API key
|
|
68
|
+
api = CashflowAPIClient("[YOUR_API_KEY]")
|
|
69
|
+
|
|
70
|
+
query = {
|
|
71
|
+
"ticker": "AAPL",
|
|
72
|
+
"year": 0,
|
|
73
|
+
"quarter": 0
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
try:
|
|
77
|
+
# Make the API call
|
|
78
|
+
result = api.execute(query)
|
|
79
|
+
|
|
80
|
+
# Print the result
|
|
81
|
+
print(result)
|
|
82
|
+
except Exception as e:
|
|
83
|
+
print(f"Error: {e}")
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Usage
|
|
89
|
+
|
|
90
|
+
The Cash Flow Statement API documentation is found here: [https://docs.apiverve.com/ref/cashflow](https://docs.apiverve.com/ref/cashflow?utm_source=pypi&utm_medium=referral&utm_content=readme).
|
|
91
|
+
You can find parameters, example responses, and status codes documented here.
|
|
92
|
+
|
|
93
|
+
### Setup
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
# Import the client module
|
|
97
|
+
from apiverve_cashflowstatement.apiClient import CashflowAPIClient
|
|
98
|
+
|
|
99
|
+
# Initialize the client with your APIVerve API key
|
|
100
|
+
api = CashflowAPIClient("[YOUR_API_KEY]")
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Perform Request
|
|
106
|
+
|
|
107
|
+
Using the API client, you can perform requests to the API.
|
|
108
|
+
|
|
109
|
+
###### Define Query
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
query = {
|
|
113
|
+
"ticker": "AAPL",
|
|
114
|
+
"year": 0,
|
|
115
|
+
"quarter": 0
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
###### Simple Request
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
# Make a request to the API
|
|
123
|
+
result = api.execute(query)
|
|
124
|
+
|
|
125
|
+
# Print the result
|
|
126
|
+
print(result)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
###### Example Response
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"status": "ok",
|
|
134
|
+
"error": null,
|
|
135
|
+
"data": {
|
|
136
|
+
"ticker": "AAPL",
|
|
137
|
+
"company": "Apple Inc.",
|
|
138
|
+
"cik": "0000320193",
|
|
139
|
+
"fiscalYear": 2025,
|
|
140
|
+
"fiscalQuarter": 4,
|
|
141
|
+
"filingType": "10-K",
|
|
142
|
+
"filingDate": "2025-10-31",
|
|
143
|
+
"periodEnd": "2025-09-27",
|
|
144
|
+
"cashFlow": {
|
|
145
|
+
"operatingCashFlow": 111482000000,
|
|
146
|
+
"capitalExpenditures": 12715000000,
|
|
147
|
+
"investingCashFlow": 15195000000,
|
|
148
|
+
"financingCashFlow": -120686000000,
|
|
149
|
+
"dividendsPaid": 15421000000,
|
|
150
|
+
"shareRepurchases": 90711000000,
|
|
151
|
+
"freeCashFlow": 98767000000
|
|
152
|
+
},
|
|
153
|
+
"metrics": {
|
|
154
|
+
"fcfMargin": 23.73,
|
|
155
|
+
"operatingCashFlowMargin": 26.79,
|
|
156
|
+
"capexToRevenue": 3.06,
|
|
157
|
+
"cashFlowToNetIncome": 1,
|
|
158
|
+
"dividendPayoutRatio": 13.77,
|
|
159
|
+
"fcfPerShare": 6.5824
|
|
160
|
+
},
|
|
161
|
+
"formatted": {
|
|
162
|
+
"operatingCashFlow": "$111.48B",
|
|
163
|
+
"freeCashFlow": "$98.77B",
|
|
164
|
+
"capitalExpenditures": "$12.71B"
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Error Handling
|
|
173
|
+
|
|
174
|
+
The API client provides comprehensive error handling through the `CashflowAPIClientError` exception. Here are some examples:
|
|
175
|
+
|
|
176
|
+
### Basic Error Handling
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
from apiverve_cashflowstatement.apiClient import CashflowAPIClient, CashflowAPIClientError
|
|
180
|
+
|
|
181
|
+
api = CashflowAPIClient("[YOUR_API_KEY]")
|
|
182
|
+
|
|
183
|
+
query = {
|
|
184
|
+
"ticker": "AAPL",
|
|
185
|
+
"year": 0,
|
|
186
|
+
"quarter": 0
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
try:
|
|
190
|
+
result = api.execute(query)
|
|
191
|
+
print("Success!")
|
|
192
|
+
print(result)
|
|
193
|
+
except CashflowAPIClientError as e:
|
|
194
|
+
print(f"API Error: {e.message}")
|
|
195
|
+
if e.status_code:
|
|
196
|
+
print(f"Status Code: {e.status_code}")
|
|
197
|
+
if e.response:
|
|
198
|
+
print(f"Response: {e.response}")
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Handling Specific Error Types
|
|
202
|
+
|
|
203
|
+
```python
|
|
204
|
+
from apiverve_cashflowstatement.apiClient import CashflowAPIClient, CashflowAPIClientError
|
|
205
|
+
|
|
206
|
+
api = CashflowAPIClient("[YOUR_API_KEY]")
|
|
207
|
+
|
|
208
|
+
query = {
|
|
209
|
+
"ticker": "AAPL",
|
|
210
|
+
"year": 0,
|
|
211
|
+
"quarter": 0
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
try:
|
|
215
|
+
result = api.execute(query)
|
|
216
|
+
|
|
217
|
+
# Check for successful response
|
|
218
|
+
if result.get('status') == 'success':
|
|
219
|
+
print("Request successful!")
|
|
220
|
+
print(result.get('data'))
|
|
221
|
+
else:
|
|
222
|
+
print(f"API returned an error: {result.get('error')}")
|
|
223
|
+
|
|
224
|
+
except CashflowAPIClientError as e:
|
|
225
|
+
# Handle API client errors
|
|
226
|
+
if e.status_code == 401:
|
|
227
|
+
print("Unauthorized: Invalid API key")
|
|
228
|
+
elif e.status_code == 429:
|
|
229
|
+
print("Rate limit exceeded")
|
|
230
|
+
elif e.status_code >= 500:
|
|
231
|
+
print("Server error - please try again later")
|
|
232
|
+
else:
|
|
233
|
+
print(f"API error: {e.message}")
|
|
234
|
+
except Exception as e:
|
|
235
|
+
# Handle unexpected errors
|
|
236
|
+
print(f"Unexpected error: {str(e)}")
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Using Context Manager (Recommended)
|
|
240
|
+
|
|
241
|
+
The client supports the context manager protocol for automatic resource cleanup:
|
|
242
|
+
|
|
243
|
+
```python
|
|
244
|
+
from apiverve_cashflowstatement.apiClient import CashflowAPIClient, CashflowAPIClientError
|
|
245
|
+
|
|
246
|
+
query = {
|
|
247
|
+
"ticker": "AAPL",
|
|
248
|
+
"year": 0,
|
|
249
|
+
"quarter": 0
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
# Using context manager ensures proper cleanup
|
|
253
|
+
with CashflowAPIClient("[YOUR_API_KEY]") as api:
|
|
254
|
+
try:
|
|
255
|
+
result = api.execute(query)
|
|
256
|
+
print(result)
|
|
257
|
+
except CashflowAPIClientError as e:
|
|
258
|
+
print(f"Error: {e.message}")
|
|
259
|
+
# Session is automatically closed here
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## Advanced Features
|
|
265
|
+
|
|
266
|
+
### Debug Mode
|
|
267
|
+
|
|
268
|
+
Enable debug logging to see detailed request and response information:
|
|
269
|
+
|
|
270
|
+
```python
|
|
271
|
+
from apiverve_cashflowstatement.apiClient import CashflowAPIClient
|
|
272
|
+
|
|
273
|
+
# Enable debug mode
|
|
274
|
+
api = CashflowAPIClient("[YOUR_API_KEY]", debug=True)
|
|
275
|
+
|
|
276
|
+
query = {
|
|
277
|
+
"ticker": "AAPL",
|
|
278
|
+
"year": 0,
|
|
279
|
+
"quarter": 0
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
# Debug information will be printed to console
|
|
283
|
+
result = api.execute(query)
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Manual Session Management
|
|
287
|
+
|
|
288
|
+
If you need to manually manage the session lifecycle:
|
|
289
|
+
|
|
290
|
+
```python
|
|
291
|
+
from apiverve_cashflowstatement.apiClient import CashflowAPIClient
|
|
292
|
+
|
|
293
|
+
api = CashflowAPIClient("[YOUR_API_KEY]")
|
|
294
|
+
|
|
295
|
+
query = {
|
|
296
|
+
"ticker": "AAPL",
|
|
297
|
+
"year": 0,
|
|
298
|
+
"quarter": 0
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
try:
|
|
302
|
+
result = api.execute(query)
|
|
303
|
+
print(result)
|
|
304
|
+
finally:
|
|
305
|
+
# Manually close the session when done
|
|
306
|
+
api.close()
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## Customer Support
|
|
312
|
+
|
|
313
|
+
Need any assistance? [Get in touch with Customer Support](https://apiverve.com/contact?utm_source=pypi&utm_medium=referral&utm_content=readme).
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
## Updates
|
|
318
|
+
Stay up to date by following [@apiverveHQ](https://twitter.com/apiverveHQ) on Twitter.
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
## Legal
|
|
323
|
+
|
|
324
|
+
All usage of the APIVerve website, API, and services is subject to the [APIVerve Terms of Service](https://apiverve.com/terms?utm_source=pypi&utm_medium=referral&utm_content=readme) and all legal documents and agreements.
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## License
|
|
329
|
+
Licensed under the MIT License (MIT)
|
|
330
|
+
|
|
331
|
+
Copyright (©) 2026 APIVerve, and EvlarSoft LLC
|
|
332
|
+
|
|
333
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
334
|
+
|
|
335
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
336
|
+
|
|
337
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
apiverve_cashflowstatement/__init__.py,sha256=7hd-4nXM6UAozcv4wXQYSM2cuV2oSNANfbQMXV9dy-g,123
|
|
2
|
+
apiverve_cashflowstatement/apiClient.py,sha256=D8LNtEytdgvgGz1XC8MFSdS8n13FswaPYh7_Qp9j26I,9872
|
|
3
|
+
apiverve_cashflowstatement/exceptions.py,sha256=CLGuXcLXS3nbDvrLVdX8UlRsvaCmfbFt7bSKRqFD0pQ,105
|
|
4
|
+
apiverve_cashflowstatement/setup.py,sha256=Lqy_ma3gajNdMzA_6Ipph6gSUJtlXZTtZSCV2iK18mM,1098
|
|
5
|
+
apiverve_cashflowstatement/setup_dep.py,sha256=1al8GE2jwySIRCqHCR3c4LLD5pb8arfq7Go2Rt3369w,801
|
|
6
|
+
apiverve_cashflowstatement/tests/__init__.py,sha256=5_6uOnBkgWAawI5-lr0N2cZ_UVvIGJ7NCh4XT5KF47o,25
|
|
7
|
+
apiverve_cashflowstatement/tests/test_api.py,sha256=E6L9o4PnlR-E0ZEbSbHxdCYph_7masJwriisqLDt5aY,598
|
|
8
|
+
apiverve_cashflowstatement-1.2.2.dist-info/licenses/LICENSE,sha256=V5x7AJRnWqzyPdD_hz1UOO2zYKZGOdRWdXElPTdwxwE,1092
|
|
9
|
+
apiverve_cashflowstatement-1.2.2.dist-info/METADATA,sha256=dMZiurRYBuc1FdPSZ0zVxyt85lwAyPhNGnODQ50R4d0,9177
|
|
10
|
+
apiverve_cashflowstatement-1.2.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
11
|
+
apiverve_cashflowstatement-1.2.2.dist-info/top_level.txt,sha256=97TmHgEiAquUxA1nLodg7Q2uMsLyo2pqvXcjSb1Rs8g,27
|
|
12
|
+
apiverve_cashflowstatement-1.2.2.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 APIVerve and EvlarSoft LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
apiverve_cashflowstatement
|