edgarparser-sdk 0.1.0__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.
- edgarparser/__init__.py +30 -0
- edgarparser/_manifest.py +175 -0
- edgarparser/client.py +663 -0
- edgarparser/errors.py +77 -0
- edgarparser/py.typed +1 -0
- edgarparser_sdk-0.1.0.dist-info/METADATA +114 -0
- edgarparser_sdk-0.1.0.dist-info/RECORD +9 -0
- edgarparser_sdk-0.1.0.dist-info/WHEEL +4 -0
- edgarparser_sdk-0.1.0.dist-info/licenses/LICENSE +21 -0
edgarparser/__init__.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Python SDK for the hosted EdgarParser API."""
|
|
2
|
+
|
|
3
|
+
from .client import DEFAULT_BASE_URL, DEFAULT_TIMEOUT, EdgarClient
|
|
4
|
+
from .errors import (
|
|
5
|
+
EdgarAPIError,
|
|
6
|
+
EdgarAuthError,
|
|
7
|
+
EdgarError,
|
|
8
|
+
EdgarNotFoundError,
|
|
9
|
+
EdgarRateLimitError,
|
|
10
|
+
EdgarTimeoutError,
|
|
11
|
+
EdgarTransportError,
|
|
12
|
+
EdgarValidationError,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"DEFAULT_BASE_URL",
|
|
17
|
+
"DEFAULT_TIMEOUT",
|
|
18
|
+
"EdgarAPIError",
|
|
19
|
+
"EdgarAuthError",
|
|
20
|
+
"EdgarClient",
|
|
21
|
+
"EdgarError",
|
|
22
|
+
"EdgarNotFoundError",
|
|
23
|
+
"EdgarRateLimitError",
|
|
24
|
+
"EdgarTimeoutError",
|
|
25
|
+
"EdgarTransportError",
|
|
26
|
+
"EdgarValidationError",
|
|
27
|
+
"__version__",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
__version__ = "0.1.0"
|
edgarparser/_manifest.py
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"""Pinned API contract metadata for SDK-covered EdgarParser endpoints."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass(frozen=True)
|
|
9
|
+
class SDKMethodSpec:
|
|
10
|
+
sdk_method: str
|
|
11
|
+
tool_name: str
|
|
12
|
+
api_method: str
|
|
13
|
+
api_path: str
|
|
14
|
+
contract_version: str
|
|
15
|
+
schema_fingerprint: str
|
|
16
|
+
required_params: tuple[str, ...] = ()
|
|
17
|
+
optional_params: tuple[str, ...] = ()
|
|
18
|
+
path_params: tuple[str, ...] = ()
|
|
19
|
+
body_params: tuple[str, ...] = ()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
SDK_METHODS: tuple[SDKMethodSpec, ...] = (
|
|
23
|
+
SDKMethodSpec(
|
|
24
|
+
sdk_method="get_financials",
|
|
25
|
+
tool_name="get_financials",
|
|
26
|
+
api_method="GET",
|
|
27
|
+
api_path="/api/financials",
|
|
28
|
+
contract_version="1.0.0",
|
|
29
|
+
schema_fingerprint="sha256:8c2b5486165eb2628dfb324c558c1148a48a46453f4102f0491e16503316b1c5",
|
|
30
|
+
required_params=("ticker", "year", "quarter"),
|
|
31
|
+
optional_params=("full_year_mode", "source"),
|
|
32
|
+
),
|
|
33
|
+
SDKMethodSpec(
|
|
34
|
+
sdk_method="get_metric",
|
|
35
|
+
tool_name="get_metric",
|
|
36
|
+
api_method="GET",
|
|
37
|
+
api_path="/api/metric",
|
|
38
|
+
contract_version="1.0.0",
|
|
39
|
+
schema_fingerprint="sha256:0350ec893a5d3a2a2510dc059711a93f6ec9665a0e068b32d8c4b2d8cb8accd8",
|
|
40
|
+
required_params=("ticker", "year", "quarter", "metric_name"),
|
|
41
|
+
optional_params=("full_year_mode", "source", "date_type", "role"),
|
|
42
|
+
),
|
|
43
|
+
SDKMethodSpec(
|
|
44
|
+
sdk_method="get_metric_series",
|
|
45
|
+
tool_name="get_metric_series",
|
|
46
|
+
api_method="GET",
|
|
47
|
+
api_path="/api/metric/series",
|
|
48
|
+
contract_version="1.1.0",
|
|
49
|
+
schema_fingerprint="sha256:dff62ae8bf4eb8c648776ac91e02e324c83a1cccbf3beeefcb7855272970a906",
|
|
50
|
+
required_params=("ticker", "metric_name", "end_year", "end_quarter"),
|
|
51
|
+
optional_params=(
|
|
52
|
+
"periods",
|
|
53
|
+
"full_year_mode",
|
|
54
|
+
"source",
|
|
55
|
+
"date_type",
|
|
56
|
+
"include_equivalents",
|
|
57
|
+
"cached_only",
|
|
58
|
+
"role",
|
|
59
|
+
"axis_key",
|
|
60
|
+
),
|
|
61
|
+
),
|
|
62
|
+
SDKMethodSpec(
|
|
63
|
+
sdk_method="list_metrics",
|
|
64
|
+
tool_name="list_metrics",
|
|
65
|
+
api_method="GET",
|
|
66
|
+
api_path="/api/financials/list_metrics",
|
|
67
|
+
contract_version="1.0.0",
|
|
68
|
+
schema_fingerprint="sha256:07341bd265a257b8c90ee99b42ecef054e6eaa16c2f341f91ffae287bfe907d8",
|
|
69
|
+
required_params=("ticker", "year", "quarter"),
|
|
70
|
+
optional_params=(
|
|
71
|
+
"full_year_mode",
|
|
72
|
+
"source",
|
|
73
|
+
"date_type",
|
|
74
|
+
"limit",
|
|
75
|
+
"include_values",
|
|
76
|
+
),
|
|
77
|
+
),
|
|
78
|
+
SDKMethodSpec(
|
|
79
|
+
sdk_method="search_metrics",
|
|
80
|
+
tool_name="search_metrics",
|
|
81
|
+
api_method="GET",
|
|
82
|
+
api_path="/api/financials/search_metrics",
|
|
83
|
+
contract_version="1.0.0",
|
|
84
|
+
schema_fingerprint="sha256:381c0bf743038780d55c447b0c7103da0e22d13c33b866c73130b7265071853c",
|
|
85
|
+
required_params=("ticker", "year", "quarter", "query"),
|
|
86
|
+
optional_params=(
|
|
87
|
+
"full_year_mode",
|
|
88
|
+
"source",
|
|
89
|
+
"date_type",
|
|
90
|
+
"role",
|
|
91
|
+
"limit",
|
|
92
|
+
"include_values",
|
|
93
|
+
),
|
|
94
|
+
),
|
|
95
|
+
SDKMethodSpec(
|
|
96
|
+
sdk_method="get_statement",
|
|
97
|
+
tool_name="get_statement",
|
|
98
|
+
api_method="GET",
|
|
99
|
+
api_path="/api/statement",
|
|
100
|
+
contract_version="1.0.0",
|
|
101
|
+
schema_fingerprint="sha256:6da91e176e78fe536130ed3ea11cf9b8dfccf923cbbfc47483d7cb2108383986",
|
|
102
|
+
required_params=("ticker", "statement"),
|
|
103
|
+
optional_params=(
|
|
104
|
+
"year",
|
|
105
|
+
"quarter",
|
|
106
|
+
"full_year_mode",
|
|
107
|
+
"period_from",
|
|
108
|
+
"period_to",
|
|
109
|
+
"source",
|
|
110
|
+
"date_type",
|
|
111
|
+
),
|
|
112
|
+
),
|
|
113
|
+
SDKMethodSpec(
|
|
114
|
+
sdk_method="get_filings",
|
|
115
|
+
tool_name="get_filings",
|
|
116
|
+
api_method="GET",
|
|
117
|
+
api_path="/api/filings",
|
|
118
|
+
contract_version="1.0.0",
|
|
119
|
+
schema_fingerprint="sha256:ffa7e669b836cbbc181bc337cb55219e55bf9a5c75ce3d27040a8aad25f8c993",
|
|
120
|
+
required_params=("ticker", "year", "quarter"),
|
|
121
|
+
optional_params=("source",),
|
|
122
|
+
),
|
|
123
|
+
SDKMethodSpec(
|
|
124
|
+
sdk_method="get_filing_document",
|
|
125
|
+
tool_name="get_filing_document",
|
|
126
|
+
api_method="GET",
|
|
127
|
+
api_path="/api/filing/document",
|
|
128
|
+
contract_version="1.0.0",
|
|
129
|
+
schema_fingerprint="sha256:4d559aded5c9760ccb498944a984a128254a76349348de297da30ee338ff123a",
|
|
130
|
+
optional_params=(
|
|
131
|
+
"ticker",
|
|
132
|
+
"year",
|
|
133
|
+
"quarter",
|
|
134
|
+
"source",
|
|
135
|
+
"accession",
|
|
136
|
+
"cik",
|
|
137
|
+
"form_type",
|
|
138
|
+
"primary_document",
|
|
139
|
+
"sections",
|
|
140
|
+
"char_start",
|
|
141
|
+
"char_end",
|
|
142
|
+
"max_chars",
|
|
143
|
+
),
|
|
144
|
+
),
|
|
145
|
+
SDKMethodSpec(
|
|
146
|
+
sdk_method="search_filing_text",
|
|
147
|
+
tool_name="search_filing_text",
|
|
148
|
+
api_method="GET",
|
|
149
|
+
api_path="/api/filing/text/search",
|
|
150
|
+
contract_version="1.0.0",
|
|
151
|
+
schema_fingerprint="sha256:be08198a156e55118e9b32a0fb41ead07906469059fb27d3010f1a1f5a9c0c8c",
|
|
152
|
+
required_params=("ticker", "year", "quarter", "query"),
|
|
153
|
+
optional_params=("source",),
|
|
154
|
+
),
|
|
155
|
+
SDKMethodSpec(
|
|
156
|
+
sdk_method="warm_metric_cache",
|
|
157
|
+
tool_name="warm_metric_cache",
|
|
158
|
+
api_method="POST",
|
|
159
|
+
api_path="/api/warm",
|
|
160
|
+
contract_version="1.0.0",
|
|
161
|
+
schema_fingerprint="sha256:1636aba36d166ecf2901e72078fc8a6182f7174e541d9183561392781e8f8cbd",
|
|
162
|
+
body_params=("items",),
|
|
163
|
+
),
|
|
164
|
+
SDKMethodSpec(
|
|
165
|
+
sdk_method="warm_metric_cache_status",
|
|
166
|
+
tool_name="warm_metric_cache_status",
|
|
167
|
+
api_method="GET",
|
|
168
|
+
api_path="/api/warm/{job_id}",
|
|
169
|
+
contract_version="1.0.0",
|
|
170
|
+
schema_fingerprint="sha256:f48e0b9a707e404c640822af06d51f3523f54538fed625a24ee06dc220cb3245",
|
|
171
|
+
path_params=("job_id",),
|
|
172
|
+
),
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
SDK_METHODS_BY_NAME = {spec.sdk_method: spec for spec in SDK_METHODS}
|
edgarparser/client.py
ADDED
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
"""Client scaffold for the hosted EdgarParser API."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
from collections.abc import Mapping, Sequence
|
|
7
|
+
from types import TracebackType
|
|
8
|
+
from typing import Any
|
|
9
|
+
from urllib.parse import quote
|
|
10
|
+
|
|
11
|
+
import requests
|
|
12
|
+
|
|
13
|
+
from .errors import (
|
|
14
|
+
EdgarAPIError,
|
|
15
|
+
EdgarAuthError,
|
|
16
|
+
EdgarError,
|
|
17
|
+
EdgarNotFoundError,
|
|
18
|
+
EdgarRateLimitError,
|
|
19
|
+
EdgarTimeoutError,
|
|
20
|
+
EdgarTransportError,
|
|
21
|
+
EdgarValidationError,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
DEFAULT_BASE_URL = "https://www.edgarparser.com"
|
|
25
|
+
DEFAULT_TIMEOUT = 30.0
|
|
26
|
+
_REDACTED = "<redacted>"
|
|
27
|
+
_SECRET_FIELD_MARKERS = (
|
|
28
|
+
"authorization",
|
|
29
|
+
"api_key",
|
|
30
|
+
"apikey",
|
|
31
|
+
"cookie",
|
|
32
|
+
"password",
|
|
33
|
+
"token",
|
|
34
|
+
"secret",
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class EdgarClient:
|
|
39
|
+
"""Thin HTTP client for the hosted EdgarParser API."""
|
|
40
|
+
|
|
41
|
+
def __init__(
|
|
42
|
+
self,
|
|
43
|
+
api_key: str | None = None,
|
|
44
|
+
*,
|
|
45
|
+
base_url: str = DEFAULT_BASE_URL,
|
|
46
|
+
timeout: float = DEFAULT_TIMEOUT,
|
|
47
|
+
session: requests.Session | None = None,
|
|
48
|
+
) -> None:
|
|
49
|
+
if not base_url or not base_url.strip():
|
|
50
|
+
raise ValueError("base_url must be a non-empty URL")
|
|
51
|
+
if timeout <= 0:
|
|
52
|
+
raise ValueError("timeout must be positive")
|
|
53
|
+
|
|
54
|
+
self.api_key = api_key if api_key is not None else os.getenv("EDGAR_API_KEY")
|
|
55
|
+
self.base_url = base_url.rstrip("/")
|
|
56
|
+
self.timeout = timeout
|
|
57
|
+
self._session = session if session is not None else requests.Session()
|
|
58
|
+
self._owns_session = session is None
|
|
59
|
+
self._closed = False
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def user_agent(self) -> str:
|
|
63
|
+
from . import __version__
|
|
64
|
+
|
|
65
|
+
return f"edgarparser-sdk/{__version__}"
|
|
66
|
+
|
|
67
|
+
def headers(self) -> dict[str, str]:
|
|
68
|
+
headers = {"User-Agent": self.user_agent}
|
|
69
|
+
if self.api_key:
|
|
70
|
+
headers["Authorization"] = f"Bearer {self.api_key}"
|
|
71
|
+
return headers
|
|
72
|
+
|
|
73
|
+
def get_financials(
|
|
74
|
+
self,
|
|
75
|
+
ticker: str,
|
|
76
|
+
*,
|
|
77
|
+
year: int,
|
|
78
|
+
quarter: int,
|
|
79
|
+
full_year_mode: bool = False,
|
|
80
|
+
source: str = "auto",
|
|
81
|
+
timeout: float | None = None,
|
|
82
|
+
) -> dict[str, Any]:
|
|
83
|
+
return self._request(
|
|
84
|
+
"GET",
|
|
85
|
+
"/api/financials",
|
|
86
|
+
params={
|
|
87
|
+
"ticker": ticker,
|
|
88
|
+
"year": year,
|
|
89
|
+
"quarter": quarter,
|
|
90
|
+
"full_year_mode": full_year_mode,
|
|
91
|
+
"source": source,
|
|
92
|
+
},
|
|
93
|
+
timeout=timeout,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
def get_metric(
|
|
97
|
+
self,
|
|
98
|
+
ticker: str,
|
|
99
|
+
metric_name: str,
|
|
100
|
+
*,
|
|
101
|
+
year: int,
|
|
102
|
+
quarter: int,
|
|
103
|
+
full_year_mode: bool = False,
|
|
104
|
+
source: str = "auto",
|
|
105
|
+
date_type: str | None = None,
|
|
106
|
+
role: str | None = None,
|
|
107
|
+
timeout: float | None = None,
|
|
108
|
+
) -> dict[str, Any]:
|
|
109
|
+
return self._request(
|
|
110
|
+
"GET",
|
|
111
|
+
"/api/metric",
|
|
112
|
+
params=self._clean_params(
|
|
113
|
+
{
|
|
114
|
+
"ticker": ticker,
|
|
115
|
+
"year": year,
|
|
116
|
+
"quarter": quarter,
|
|
117
|
+
"metric_name": metric_name,
|
|
118
|
+
"full_year_mode": full_year_mode,
|
|
119
|
+
"source": source,
|
|
120
|
+
"date_type": date_type,
|
|
121
|
+
"role": role,
|
|
122
|
+
}
|
|
123
|
+
),
|
|
124
|
+
timeout=timeout,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
def get_metric_series(
|
|
128
|
+
self,
|
|
129
|
+
ticker: str,
|
|
130
|
+
metric_name: str,
|
|
131
|
+
*,
|
|
132
|
+
end_year: int,
|
|
133
|
+
end_quarter: int,
|
|
134
|
+
periods: int = 8,
|
|
135
|
+
full_year_mode: bool = False,
|
|
136
|
+
source: str = "auto",
|
|
137
|
+
date_type: str | None = None,
|
|
138
|
+
include_equivalents: bool = False,
|
|
139
|
+
cached_only: bool = False,
|
|
140
|
+
role: str | None = None,
|
|
141
|
+
axis_key: str | None = None,
|
|
142
|
+
timeout: float | None = None,
|
|
143
|
+
) -> dict[str, Any]:
|
|
144
|
+
return self._request(
|
|
145
|
+
"GET",
|
|
146
|
+
"/api/metric/series",
|
|
147
|
+
params=self._clean_params(
|
|
148
|
+
{
|
|
149
|
+
"ticker": ticker,
|
|
150
|
+
"metric_name": metric_name,
|
|
151
|
+
"end_year": end_year,
|
|
152
|
+
"end_quarter": end_quarter,
|
|
153
|
+
"periods": periods,
|
|
154
|
+
"full_year_mode": full_year_mode,
|
|
155
|
+
"source": source,
|
|
156
|
+
"date_type": date_type,
|
|
157
|
+
"include_equivalents": include_equivalents,
|
|
158
|
+
"cached_only": cached_only,
|
|
159
|
+
"role": role,
|
|
160
|
+
"axis_key": axis_key,
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
timeout=timeout,
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
def list_metrics(
|
|
167
|
+
self,
|
|
168
|
+
ticker: str,
|
|
169
|
+
*,
|
|
170
|
+
year: int,
|
|
171
|
+
quarter: int,
|
|
172
|
+
full_year_mode: bool = False,
|
|
173
|
+
source: str = "auto",
|
|
174
|
+
date_type: str | None = None,
|
|
175
|
+
limit: int = 200,
|
|
176
|
+
include_values: bool = True,
|
|
177
|
+
timeout: float | None = None,
|
|
178
|
+
) -> dict[str, Any]:
|
|
179
|
+
return self._request(
|
|
180
|
+
"GET",
|
|
181
|
+
"/api/financials/list_metrics",
|
|
182
|
+
params=self._clean_params(
|
|
183
|
+
{
|
|
184
|
+
"ticker": ticker,
|
|
185
|
+
"year": year,
|
|
186
|
+
"quarter": quarter,
|
|
187
|
+
"full_year_mode": full_year_mode,
|
|
188
|
+
"source": source,
|
|
189
|
+
"date_type": date_type,
|
|
190
|
+
"limit": limit,
|
|
191
|
+
"include_values": include_values,
|
|
192
|
+
}
|
|
193
|
+
),
|
|
194
|
+
timeout=timeout,
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
def search_metrics(
|
|
198
|
+
self,
|
|
199
|
+
ticker: str,
|
|
200
|
+
query: str,
|
|
201
|
+
*,
|
|
202
|
+
year: int,
|
|
203
|
+
quarter: int,
|
|
204
|
+
full_year_mode: bool = False,
|
|
205
|
+
source: str = "auto",
|
|
206
|
+
date_type: str | None = None,
|
|
207
|
+
role: str | Sequence[str] | None = None,
|
|
208
|
+
limit: int = 20,
|
|
209
|
+
include_values: bool = True,
|
|
210
|
+
timeout: float | None = None,
|
|
211
|
+
) -> dict[str, Any]:
|
|
212
|
+
return self._request(
|
|
213
|
+
"GET",
|
|
214
|
+
"/api/financials/search_metrics",
|
|
215
|
+
params=self._clean_params(
|
|
216
|
+
{
|
|
217
|
+
"ticker": ticker,
|
|
218
|
+
"year": year,
|
|
219
|
+
"quarter": quarter,
|
|
220
|
+
"query": query,
|
|
221
|
+
"full_year_mode": full_year_mode,
|
|
222
|
+
"source": source,
|
|
223
|
+
"date_type": date_type,
|
|
224
|
+
"role": self._role_values(role),
|
|
225
|
+
"limit": limit,
|
|
226
|
+
"include_values": include_values,
|
|
227
|
+
}
|
|
228
|
+
),
|
|
229
|
+
timeout=timeout,
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
def get_statement(
|
|
233
|
+
self,
|
|
234
|
+
ticker: str,
|
|
235
|
+
statement: str,
|
|
236
|
+
*,
|
|
237
|
+
year: int | None = None,
|
|
238
|
+
quarter: int | None = None,
|
|
239
|
+
full_year_mode: bool = False,
|
|
240
|
+
period_from: str | None = None,
|
|
241
|
+
period_to: str | None = None,
|
|
242
|
+
source: str = "auto",
|
|
243
|
+
date_type: str | None = None,
|
|
244
|
+
timeout: float | None = None,
|
|
245
|
+
) -> dict[str, Any]:
|
|
246
|
+
return self._request(
|
|
247
|
+
"GET",
|
|
248
|
+
"/api/statement",
|
|
249
|
+
params=self._clean_params(
|
|
250
|
+
{
|
|
251
|
+
"ticker": ticker,
|
|
252
|
+
"statement": statement,
|
|
253
|
+
"year": year,
|
|
254
|
+
"quarter": quarter,
|
|
255
|
+
"full_year_mode": full_year_mode,
|
|
256
|
+
"period_from": period_from,
|
|
257
|
+
"period_to": period_to,
|
|
258
|
+
"source": source,
|
|
259
|
+
"date_type": date_type,
|
|
260
|
+
}
|
|
261
|
+
),
|
|
262
|
+
timeout=timeout,
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
def get_filings(
|
|
266
|
+
self,
|
|
267
|
+
ticker: str,
|
|
268
|
+
*,
|
|
269
|
+
year: int,
|
|
270
|
+
quarter: int,
|
|
271
|
+
source: str = "auto",
|
|
272
|
+
timeout: float | None = None,
|
|
273
|
+
) -> dict[str, Any]:
|
|
274
|
+
return self._request(
|
|
275
|
+
"GET",
|
|
276
|
+
"/api/filings",
|
|
277
|
+
params={
|
|
278
|
+
"ticker": ticker,
|
|
279
|
+
"year": year,
|
|
280
|
+
"quarter": quarter,
|
|
281
|
+
"source": source,
|
|
282
|
+
},
|
|
283
|
+
timeout=timeout,
|
|
284
|
+
)
|
|
285
|
+
|
|
286
|
+
def get_filing_document(
|
|
287
|
+
self,
|
|
288
|
+
*,
|
|
289
|
+
ticker: str | None = None,
|
|
290
|
+
year: int | None = None,
|
|
291
|
+
quarter: int | None = None,
|
|
292
|
+
source: str = "auto",
|
|
293
|
+
accession: str | None = None,
|
|
294
|
+
cik: str | None = None,
|
|
295
|
+
form_type: str | None = None,
|
|
296
|
+
primary_document: str | None = None,
|
|
297
|
+
sections: str | None = None,
|
|
298
|
+
char_start: int | None = None,
|
|
299
|
+
char_end: int | None = None,
|
|
300
|
+
max_chars: int = 200000,
|
|
301
|
+
timeout: float | None = None,
|
|
302
|
+
) -> dict[str, Any]:
|
|
303
|
+
return self._request(
|
|
304
|
+
"GET",
|
|
305
|
+
"/api/filing/document",
|
|
306
|
+
params=self._clean_params(
|
|
307
|
+
{
|
|
308
|
+
"ticker": ticker,
|
|
309
|
+
"year": year,
|
|
310
|
+
"quarter": quarter,
|
|
311
|
+
"source": source,
|
|
312
|
+
"accession": accession,
|
|
313
|
+
"cik": cik,
|
|
314
|
+
"form_type": form_type,
|
|
315
|
+
"primary_document": primary_document,
|
|
316
|
+
"sections": sections,
|
|
317
|
+
"char_start": char_start,
|
|
318
|
+
"char_end": char_end,
|
|
319
|
+
"max_chars": max_chars,
|
|
320
|
+
}
|
|
321
|
+
),
|
|
322
|
+
timeout=timeout,
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
def search_filing_text(
|
|
326
|
+
self,
|
|
327
|
+
ticker: str,
|
|
328
|
+
query: str,
|
|
329
|
+
*,
|
|
330
|
+
year: int,
|
|
331
|
+
quarter: int,
|
|
332
|
+
source: str = "auto",
|
|
333
|
+
timeout: float | None = None,
|
|
334
|
+
) -> dict[str, Any]:
|
|
335
|
+
return self._request(
|
|
336
|
+
"GET",
|
|
337
|
+
"/api/filing/text/search",
|
|
338
|
+
params={
|
|
339
|
+
"ticker": ticker,
|
|
340
|
+
"year": year,
|
|
341
|
+
"quarter": quarter,
|
|
342
|
+
"source": source,
|
|
343
|
+
"query": query,
|
|
344
|
+
},
|
|
345
|
+
timeout=timeout,
|
|
346
|
+
)
|
|
347
|
+
|
|
348
|
+
def warm_metric_cache(
|
|
349
|
+
self,
|
|
350
|
+
items: Sequence[Mapping[str, Any]] | None = None,
|
|
351
|
+
*,
|
|
352
|
+
ticker: str | None = None,
|
|
353
|
+
year: int | None = None,
|
|
354
|
+
quarter: int | None = None,
|
|
355
|
+
full_year_mode: bool = False,
|
|
356
|
+
timeout: float | None = None,
|
|
357
|
+
) -> dict[str, Any]:
|
|
358
|
+
payload_items = self._warm_items(
|
|
359
|
+
items,
|
|
360
|
+
ticker=ticker,
|
|
361
|
+
year=year,
|
|
362
|
+
quarter=quarter,
|
|
363
|
+
full_year_mode=full_year_mode,
|
|
364
|
+
)
|
|
365
|
+
return self._request(
|
|
366
|
+
"POST",
|
|
367
|
+
"/api/warm",
|
|
368
|
+
json={"items": payload_items},
|
|
369
|
+
timeout=timeout,
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
def warm_metric_cache_status(
|
|
373
|
+
self,
|
|
374
|
+
job_id: str,
|
|
375
|
+
*,
|
|
376
|
+
timeout: float | None = None,
|
|
377
|
+
) -> dict[str, Any]:
|
|
378
|
+
if not job_id or not job_id.strip():
|
|
379
|
+
raise ValueError("job_id must be non-empty")
|
|
380
|
+
encoded_job_id = quote(job_id.strip(), safe="")
|
|
381
|
+
return self._request("GET", f"/api/warm/{encoded_job_id}", timeout=timeout)
|
|
382
|
+
|
|
383
|
+
def _request(
|
|
384
|
+
self,
|
|
385
|
+
method: str,
|
|
386
|
+
path: str,
|
|
387
|
+
*,
|
|
388
|
+
params: Mapping[str, Any] | None = None,
|
|
389
|
+
json: Mapping[str, Any] | None = None,
|
|
390
|
+
timeout: float | None = None,
|
|
391
|
+
) -> Any:
|
|
392
|
+
if self._closed:
|
|
393
|
+
raise EdgarError("client is closed")
|
|
394
|
+
if timeout is not None and timeout <= 0:
|
|
395
|
+
raise ValueError("timeout must be positive")
|
|
396
|
+
|
|
397
|
+
normalized_method = method.upper()
|
|
398
|
+
url = self._url(path)
|
|
399
|
+
request_metadata = self._request_metadata(
|
|
400
|
+
normalized_method,
|
|
401
|
+
url,
|
|
402
|
+
params=params,
|
|
403
|
+
json=json,
|
|
404
|
+
)
|
|
405
|
+
|
|
406
|
+
try:
|
|
407
|
+
response = self._session.request(
|
|
408
|
+
normalized_method,
|
|
409
|
+
url,
|
|
410
|
+
headers=self.headers(),
|
|
411
|
+
params=dict(params or {}),
|
|
412
|
+
json=dict(json or {}) if json is not None else None,
|
|
413
|
+
timeout=timeout or self.timeout,
|
|
414
|
+
)
|
|
415
|
+
except requests.Timeout as exc:
|
|
416
|
+
raise EdgarTimeoutError(request=request_metadata) from exc
|
|
417
|
+
except requests.RequestException as exc:
|
|
418
|
+
message = self._redact_text(str(exc) or "Request failed")
|
|
419
|
+
raise EdgarTransportError(message, request=request_metadata) from exc
|
|
420
|
+
|
|
421
|
+
response_metadata = self._response_metadata(response)
|
|
422
|
+
if response.status_code >= 400:
|
|
423
|
+
raise self._api_error_from_response(
|
|
424
|
+
response,
|
|
425
|
+
request=request_metadata,
|
|
426
|
+
response_metadata=response_metadata,
|
|
427
|
+
)
|
|
428
|
+
|
|
429
|
+
try:
|
|
430
|
+
return response.json()
|
|
431
|
+
except ValueError as exc:
|
|
432
|
+
raise EdgarAPIError(
|
|
433
|
+
response.status_code,
|
|
434
|
+
"Response was not valid JSON",
|
|
435
|
+
error_type="invalid_json",
|
|
436
|
+
details=self._text_details(response.text),
|
|
437
|
+
request_id=response.headers.get("X-Request-ID"),
|
|
438
|
+
request=request_metadata,
|
|
439
|
+
response=response_metadata,
|
|
440
|
+
) from exc
|
|
441
|
+
|
|
442
|
+
def close(self) -> None:
|
|
443
|
+
if self._closed:
|
|
444
|
+
return
|
|
445
|
+
if self._owns_session:
|
|
446
|
+
self._session.close()
|
|
447
|
+
self._closed = True
|
|
448
|
+
|
|
449
|
+
def __enter__(self) -> EdgarClient:
|
|
450
|
+
return self
|
|
451
|
+
|
|
452
|
+
def __exit__(
|
|
453
|
+
self,
|
|
454
|
+
exc_type: type[BaseException] | None,
|
|
455
|
+
exc: BaseException | None,
|
|
456
|
+
traceback: TracebackType | None,
|
|
457
|
+
) -> None:
|
|
458
|
+
del exc_type, exc, traceback
|
|
459
|
+
self.close()
|
|
460
|
+
|
|
461
|
+
def __repr__(self) -> str:
|
|
462
|
+
key_state = "set" if self.api_key else "unset"
|
|
463
|
+
return (
|
|
464
|
+
f"{self.__class__.__name__}("
|
|
465
|
+
f"base_url={self.base_url!r}, "
|
|
466
|
+
f"timeout={self.timeout!r}, "
|
|
467
|
+
f"api_key=<{key_state}>"
|
|
468
|
+
")"
|
|
469
|
+
)
|
|
470
|
+
|
|
471
|
+
def _debug_state(self) -> dict[str, Any]:
|
|
472
|
+
"""Return non-secret state for tests and diagnostics."""
|
|
473
|
+
|
|
474
|
+
return {
|
|
475
|
+
"base_url": self.base_url,
|
|
476
|
+
"timeout": self.timeout,
|
|
477
|
+
"api_key_set": bool(self.api_key),
|
|
478
|
+
"closed": self._closed,
|
|
479
|
+
"user_agent": self.user_agent,
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
def _url(self, path: str) -> str:
|
|
483
|
+
if not path or not path.strip():
|
|
484
|
+
raise ValueError("path must be a non-empty API path")
|
|
485
|
+
return f"{self.base_url}/{path.lstrip('/')}"
|
|
486
|
+
|
|
487
|
+
def _clean_params(self, params: Mapping[str, Any]) -> dict[str, Any]:
|
|
488
|
+
return {key: value for key, value in params.items() if value is not None}
|
|
489
|
+
|
|
490
|
+
def _warm_items(
|
|
491
|
+
self,
|
|
492
|
+
items: Sequence[Mapping[str, Any]] | None,
|
|
493
|
+
*,
|
|
494
|
+
ticker: str | None,
|
|
495
|
+
year: int | None,
|
|
496
|
+
quarter: int | None,
|
|
497
|
+
full_year_mode: bool,
|
|
498
|
+
) -> list[dict[str, Any]]:
|
|
499
|
+
if items is not None:
|
|
500
|
+
if not items:
|
|
501
|
+
raise ValueError("items must contain at least one warm request")
|
|
502
|
+
return [dict(item) for item in items]
|
|
503
|
+
if ticker is None or year is None or quarter is None:
|
|
504
|
+
raise ValueError("provide items or ticker, year, and quarter")
|
|
505
|
+
return [
|
|
506
|
+
{
|
|
507
|
+
"ticker": ticker,
|
|
508
|
+
"year": year,
|
|
509
|
+
"quarter": quarter,
|
|
510
|
+
"full_year_mode": full_year_mode,
|
|
511
|
+
}
|
|
512
|
+
]
|
|
513
|
+
|
|
514
|
+
def _role_values(self, role: str | Sequence[str] | None) -> str | list[str] | None:
|
|
515
|
+
if role is None:
|
|
516
|
+
return None
|
|
517
|
+
if isinstance(role, str):
|
|
518
|
+
return role
|
|
519
|
+
return list(role)
|
|
520
|
+
|
|
521
|
+
def _request_metadata(
|
|
522
|
+
self,
|
|
523
|
+
method: str,
|
|
524
|
+
url: str,
|
|
525
|
+
*,
|
|
526
|
+
params: Mapping[str, Any] | None,
|
|
527
|
+
json: Mapping[str, Any] | None,
|
|
528
|
+
) -> dict[str, Any]:
|
|
529
|
+
return {
|
|
530
|
+
"method": method,
|
|
531
|
+
"url": url,
|
|
532
|
+
"headers": self._redact_mapping(self.headers()),
|
|
533
|
+
"params": self._redact_mapping(params or {}),
|
|
534
|
+
"json": self._redact_mapping(json or {}),
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
def _response_metadata(self, response: requests.Response) -> dict[str, Any]:
|
|
538
|
+
response_url = getattr(response, "url", None)
|
|
539
|
+
return {
|
|
540
|
+
"status_code": response.status_code,
|
|
541
|
+
"url": (
|
|
542
|
+
self._redact_text(response_url)
|
|
543
|
+
if isinstance(response_url, str)
|
|
544
|
+
else response_url
|
|
545
|
+
),
|
|
546
|
+
"headers": self._redact_mapping(dict(response.headers)),
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
def _api_error_from_response(
|
|
550
|
+
self,
|
|
551
|
+
response: requests.Response,
|
|
552
|
+
*,
|
|
553
|
+
request: Mapping[str, Any],
|
|
554
|
+
response_metadata: Mapping[str, Any],
|
|
555
|
+
) -> EdgarAPIError:
|
|
556
|
+
payload = self._response_json(response)
|
|
557
|
+
message = f"HTTP {response.status_code}"
|
|
558
|
+
error_type: str | None = self._default_error_type(response.status_code)
|
|
559
|
+
details: Any | None = None
|
|
560
|
+
|
|
561
|
+
if isinstance(payload, Mapping):
|
|
562
|
+
message = self._redact_text(
|
|
563
|
+
str(payload.get("message") or payload.get("error") or message)
|
|
564
|
+
)
|
|
565
|
+
error_type = (
|
|
566
|
+
str(payload["error_type"])
|
|
567
|
+
if payload.get("error_type") is not None
|
|
568
|
+
else error_type
|
|
569
|
+
)
|
|
570
|
+
details = self._redact_value(self._details_from_payload(payload))
|
|
571
|
+
else:
|
|
572
|
+
error_type = "non_json_error"
|
|
573
|
+
text = self._redact_text(response.text.strip())
|
|
574
|
+
if text:
|
|
575
|
+
message = text[:300]
|
|
576
|
+
details = self._text_details(text)
|
|
577
|
+
|
|
578
|
+
error_cls = self._error_class(response.status_code)
|
|
579
|
+
return error_cls(
|
|
580
|
+
response.status_code,
|
|
581
|
+
message,
|
|
582
|
+
error_type=error_type,
|
|
583
|
+
details=details,
|
|
584
|
+
request_id=response.headers.get("X-Request-ID"),
|
|
585
|
+
request=request,
|
|
586
|
+
response=response_metadata,
|
|
587
|
+
)
|
|
588
|
+
|
|
589
|
+
def _response_json(self, response: requests.Response) -> Any:
|
|
590
|
+
try:
|
|
591
|
+
return response.json()
|
|
592
|
+
except ValueError:
|
|
593
|
+
return None
|
|
594
|
+
|
|
595
|
+
def _details_from_payload(self, payload: Mapping[str, Any]) -> Any | None:
|
|
596
|
+
details = payload.get("details")
|
|
597
|
+
if details is None and "detail" in payload:
|
|
598
|
+
details = {"detail": payload["detail"]}
|
|
599
|
+
if "cta" not in payload:
|
|
600
|
+
return details
|
|
601
|
+
if details is None:
|
|
602
|
+
return {"cta": payload["cta"]}
|
|
603
|
+
if isinstance(details, dict):
|
|
604
|
+
return {**details, "cta": payload["cta"]}
|
|
605
|
+
return {"details": details, "cta": payload["cta"]}
|
|
606
|
+
|
|
607
|
+
def _default_error_type(self, status_code: int) -> str | None:
|
|
608
|
+
if status_code == 429:
|
|
609
|
+
return "rate_limit"
|
|
610
|
+
if status_code in {400, 422}:
|
|
611
|
+
return "validation_error"
|
|
612
|
+
if status_code in {401, 403}:
|
|
613
|
+
return "auth_error"
|
|
614
|
+
if status_code == 404:
|
|
615
|
+
return "not_found"
|
|
616
|
+
return None
|
|
617
|
+
|
|
618
|
+
def _error_class(self, status_code: int) -> type[EdgarAPIError]:
|
|
619
|
+
if status_code in {401, 403}:
|
|
620
|
+
return EdgarAuthError
|
|
621
|
+
if status_code == 429:
|
|
622
|
+
return EdgarRateLimitError
|
|
623
|
+
if status_code == 404:
|
|
624
|
+
return EdgarNotFoundError
|
|
625
|
+
if status_code in {400, 422}:
|
|
626
|
+
return EdgarValidationError
|
|
627
|
+
return EdgarAPIError
|
|
628
|
+
|
|
629
|
+
def _text_details(self, text: str) -> dict[str, str] | None:
|
|
630
|
+
if not text:
|
|
631
|
+
return None
|
|
632
|
+
return {"text": self._redact_text(text)[:500]}
|
|
633
|
+
|
|
634
|
+
def _redact_mapping(self, value: Mapping[str, Any]) -> dict[str, Any]:
|
|
635
|
+
redacted: dict[str, Any] = {}
|
|
636
|
+
for key, item in value.items():
|
|
637
|
+
if self._is_secret_key(key):
|
|
638
|
+
redacted[str(key)] = _REDACTED
|
|
639
|
+
else:
|
|
640
|
+
redacted[str(key)] = self._redact_value(item)
|
|
641
|
+
return redacted
|
|
642
|
+
|
|
643
|
+
def _redact_value(self, value: Any) -> Any:
|
|
644
|
+
if isinstance(value, Mapping):
|
|
645
|
+
return self._redact_mapping(value)
|
|
646
|
+
if isinstance(value, list):
|
|
647
|
+
return [self._redact_value(item) for item in value]
|
|
648
|
+
if isinstance(value, str):
|
|
649
|
+
return self._redact_text(value)
|
|
650
|
+
return value
|
|
651
|
+
|
|
652
|
+
def _is_secret_key(self, key: object) -> bool:
|
|
653
|
+
normalized = str(key).lower().replace("-", "_")
|
|
654
|
+
return (
|
|
655
|
+
normalized == "key"
|
|
656
|
+
or normalized.endswith("_key")
|
|
657
|
+
or any(marker in normalized for marker in _SECRET_FIELD_MARKERS)
|
|
658
|
+
)
|
|
659
|
+
|
|
660
|
+
def _redact_text(self, text: str) -> str:
|
|
661
|
+
if self.api_key and len(self.api_key) >= 4:
|
|
662
|
+
return text.replace(self.api_key, _REDACTED)
|
|
663
|
+
return text
|
edgarparser/errors.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""Typed exceptions for the EdgarParser SDK."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Mapping
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class EdgarError(Exception):
|
|
9
|
+
"""Base exception for all SDK errors."""
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class EdgarTimeoutError(EdgarError):
|
|
13
|
+
"""Raised when an API request times out."""
|
|
14
|
+
|
|
15
|
+
def __init__(
|
|
16
|
+
self,
|
|
17
|
+
message: str = "Request timed out",
|
|
18
|
+
*,
|
|
19
|
+
request: Mapping[str, Any] | None = None,
|
|
20
|
+
) -> None:
|
|
21
|
+
super().__init__(message)
|
|
22
|
+
self.message = message
|
|
23
|
+
self.request = dict(request or {})
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class EdgarTransportError(EdgarError):
|
|
27
|
+
"""Raised when the HTTP transport fails before receiving a response."""
|
|
28
|
+
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
message: str,
|
|
32
|
+
*,
|
|
33
|
+
request: Mapping[str, Any] | None = None,
|
|
34
|
+
) -> None:
|
|
35
|
+
super().__init__(message)
|
|
36
|
+
self.message = message
|
|
37
|
+
self.request = dict(request or {})
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class EdgarAPIError(EdgarError):
|
|
41
|
+
"""Raised for API responses that are errors or cannot be parsed."""
|
|
42
|
+
|
|
43
|
+
def __init__(
|
|
44
|
+
self,
|
|
45
|
+
status_code: int,
|
|
46
|
+
message: str,
|
|
47
|
+
*,
|
|
48
|
+
error_type: str | None = None,
|
|
49
|
+
details: Any | None = None,
|
|
50
|
+
request_id: str | None = None,
|
|
51
|
+
request: Mapping[str, Any] | None = None,
|
|
52
|
+
response: Mapping[str, Any] | None = None,
|
|
53
|
+
) -> None:
|
|
54
|
+
super().__init__(message)
|
|
55
|
+
self.status_code = status_code
|
|
56
|
+
self.message = message
|
|
57
|
+
self.error_type = error_type
|
|
58
|
+
self.details = details
|
|
59
|
+
self.request_id = request_id
|
|
60
|
+
self.request = dict(request or {})
|
|
61
|
+
self.response = dict(response or {})
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class EdgarAuthError(EdgarAPIError):
|
|
65
|
+
"""Raised for authentication and authorization errors."""
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class EdgarRateLimitError(EdgarAPIError):
|
|
69
|
+
"""Raised for rate-limit errors."""
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class EdgarValidationError(EdgarAPIError):
|
|
73
|
+
"""Raised for request validation errors."""
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class EdgarNotFoundError(EdgarAPIError):
|
|
77
|
+
"""Raised when the requested API resource is not found."""
|
edgarparser/py.typed
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Marker file for PEP 561 typing support.
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: edgarparser-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for the hosted EdgarParser SEC filings API
|
|
5
|
+
Project-URL: Homepage, https://www.edgarparser.com
|
|
6
|
+
Project-URL: Documentation, https://docs.edgarparser.com
|
|
7
|
+
Project-URL: Hosted API, https://www.edgarparser.com
|
|
8
|
+
Project-URL: Tool Reference, https://docs.edgarparser.com/tools
|
|
9
|
+
Project-URL: Source, https://github.com/henrysouchien/edgarparser-python
|
|
10
|
+
Project-URL: Issues, https://github.com/henrysouchien/edgarparser-python/issues
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Requires-Dist: requests>=2.31.0
|
|
15
|
+
Provides-Extra: dev
|
|
16
|
+
Requires-Dist: build; extra == 'dev'
|
|
17
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
18
|
+
Requires-Dist: pyyaml; extra == 'dev'
|
|
19
|
+
Requires-Dist: twine; extra == 'dev'
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# edgarparser-sdk
|
|
23
|
+
|
|
24
|
+
Python SDK for the hosted EdgarParser API.
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install edgarparser-sdk
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
from edgarparser import EdgarClient
|
|
32
|
+
|
|
33
|
+
client = EdgarClient(api_key="...")
|
|
34
|
+
print(client)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Status
|
|
38
|
+
|
|
39
|
+
This package is being implemented in the EdgarParser source repo and is not
|
|
40
|
+
published yet. The current local package exports `EdgarClient`, typed SDK
|
|
41
|
+
errors, and the first v1 hosted-API endpoint methods.
|
|
42
|
+
|
|
43
|
+
## Package Boundary
|
|
44
|
+
|
|
45
|
+
Install `edgarparser-sdk` and import `edgarparser` when you want the hosted
|
|
46
|
+
EdgarParser API from Python.
|
|
47
|
+
|
|
48
|
+
Use `edgar-parser` when you want the local parsing library.
|
|
49
|
+
|
|
50
|
+
Use `edgar-mcp` when you want AI-agent tools over the hosted API.
|
|
51
|
+
|
|
52
|
+
The SDK is intentionally a thin HTTP client. It should not parse filings
|
|
53
|
+
locally, rank metric matches, resolve tag equivalence, or mutate server caches
|
|
54
|
+
as a hidden side effect.
|
|
55
|
+
|
|
56
|
+
## Configuration
|
|
57
|
+
|
|
58
|
+
`EdgarClient` accepts an explicit API key:
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from edgarparser import EdgarClient
|
|
62
|
+
|
|
63
|
+
client = EdgarClient(api_key="edgar_...")
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
It can also read `EDGAR_API_KEY`:
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from edgarparser import EdgarClient
|
|
70
|
+
|
|
71
|
+
client = EdgarClient()
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Use `base_url` for staging or local API testing:
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
client = EdgarClient(api_key="edgar_...", base_url="http://127.0.0.1:8000")
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## V1 Methods
|
|
81
|
+
|
|
82
|
+
The current local SDK surface includes:
|
|
83
|
+
|
|
84
|
+
- `get_financials`
|
|
85
|
+
- `get_metric`
|
|
86
|
+
- `get_metric_series`
|
|
87
|
+
- `list_metrics`
|
|
88
|
+
- `search_metrics`
|
|
89
|
+
- `get_statement`
|
|
90
|
+
- `get_filings`
|
|
91
|
+
- `get_filing_document`
|
|
92
|
+
- `search_filing_text`
|
|
93
|
+
- `warm_metric_cache`
|
|
94
|
+
- `warm_metric_cache_status`
|
|
95
|
+
|
|
96
|
+
## Examples
|
|
97
|
+
|
|
98
|
+
From `packages/edgarparser/` or the synced package repo, run examples with
|
|
99
|
+
`EDGAR_API_KEY` set:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
EDGAR_API_KEY=... python examples/financials.py
|
|
103
|
+
EDGAR_API_KEY=... python examples/metric_series.py
|
|
104
|
+
EDGAR_API_KEY=... python examples/filing_search.py
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Development
|
|
108
|
+
|
|
109
|
+
From the repo root:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
python -m pip install -e packages/edgarparser
|
|
113
|
+
python -m pytest packages/edgarparser/tests -q
|
|
114
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
edgarparser/__init__.py,sha256=VNp5Tyj4b5FJi73Hv85j1tXhnpWZsiPNSBdFLPHp170,636
|
|
2
|
+
edgarparser/_manifest.py,sha256=cBvx3wQjJHPMvjoFa3DR6p2CDP33NrsS4SSbKDIDxP4,5816
|
|
3
|
+
edgarparser/client.py,sha256=08RRM_tln9tGj7Y15obKA_Xnv6VuM9ypnBdh2vxQ9Dk,20408
|
|
4
|
+
edgarparser/errors.py,sha256=DKq262VbNNzGwzHzHjiwZO5JzuHM0ZwUDkQ0H775--U,2007
|
|
5
|
+
edgarparser/py.typed,sha256=0VrMqa_u6HfLYNPxflMqTVvjIovV_taKM7nltQcS1TA,42
|
|
6
|
+
edgarparser_sdk-0.1.0.dist-info/METADATA,sha256=st83AW-9y-_G3Qu52mTIjnRmyyCzveIPhZUsu9nbLVA,2771
|
|
7
|
+
edgarparser_sdk-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
8
|
+
edgarparser_sdk-0.1.0.dist-info/licenses/LICENSE,sha256=3SuIgQXssHX7NSO3otrkAeSPGz59jsRzpHjumfn7Ajw,1073
|
|
9
|
+
edgarparser_sdk-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Henry Chien
|
|
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.
|