arche-sdk 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. arche_sdk-0.1.0/.gitignore +147 -0
  2. arche_sdk-0.1.0/LICENSE +202 -0
  3. arche_sdk-0.1.0/PKG-INFO +280 -0
  4. arche_sdk-0.1.0/README.md +253 -0
  5. arche_sdk-0.1.0/pyproject.toml +53 -0
  6. arche_sdk-0.1.0/src/arche_sdk/__init__.py +49 -0
  7. arche_sdk-0.1.0/src/arche_sdk/_version.py +5 -0
  8. arche_sdk-0.1.0/src/arche_sdk/auth.py +26 -0
  9. arche_sdk-0.1.0/src/arche_sdk/client.py +63 -0
  10. arche_sdk-0.1.0/src/arche_sdk/config.py +37 -0
  11. arche_sdk-0.1.0/src/arche_sdk/envelopes.py +50 -0
  12. arche_sdk-0.1.0/src/arche_sdk/errors.py +148 -0
  13. arche_sdk-0.1.0/src/arche_sdk/models/__init__.py +109 -0
  14. arche_sdk-0.1.0/src/arche_sdk/models/ai.py +32 -0
  15. arche_sdk-0.1.0/src/arche_sdk/models/bulk.py +202 -0
  16. arche_sdk-0.1.0/src/arche_sdk/models/companies.py +54 -0
  17. arche_sdk-0.1.0/src/arche_sdk/models/edgar.py +374 -0
  18. arche_sdk-0.1.0/src/arche_sdk/models/fundamentals.py +7 -0
  19. arche_sdk-0.1.0/src/arche_sdk/models/reconciliation.py +41 -0
  20. arche_sdk-0.1.0/src/arche_sdk/models/statements.py +113 -0
  21. arche_sdk-0.1.0/src/arche_sdk/pagination.py +32 -0
  22. arche_sdk-0.1.0/src/arche_sdk/py.typed +0 -0
  23. arche_sdk-0.1.0/src/arche_sdk/request_options.py +22 -0
  24. arche_sdk-0.1.0/src/arche_sdk/resources/__init__.py +17 -0
  25. arche_sdk-0.1.0/src/arche_sdk/resources/_base.py +98 -0
  26. arche_sdk-0.1.0/src/arche_sdk/resources/bulk.py +484 -0
  27. arche_sdk-0.1.0/src/arche_sdk/resources/companies.py +81 -0
  28. arche_sdk-0.1.0/src/arche_sdk/resources/filings.py +186 -0
  29. arche_sdk-0.1.0/src/arche_sdk/resources/narratives.py +92 -0
  30. arche_sdk-0.1.0/src/arche_sdk/resources/statements.py +810 -0
  31. arche_sdk-0.1.0/src/arche_sdk/transport.py +245 -0
  32. arche_sdk-0.1.0/tests/conftest.py +155 -0
  33. arche_sdk-0.1.0/tests/integration/test_bulk_client.py +454 -0
  34. arche_sdk-0.1.0/tests/integration/test_companies_client.py +80 -0
  35. arche_sdk-0.1.0/tests/integration/test_filings_client.py +173 -0
  36. arche_sdk-0.1.0/tests/integration/test_narratives_client.py +71 -0
  37. arche_sdk-0.1.0/tests/integration/test_split_fiscal_year_statements.py +243 -0
  38. arche_sdk-0.1.0/tests/integration/test_statements_client.py +602 -0
  39. arche_sdk-0.1.0/tests/unit/test_auth.py +81 -0
  40. arche_sdk-0.1.0/tests/unit/test_bulk_license.py +106 -0
  41. arche_sdk-0.1.0/tests/unit/test_bulk_sync.py +270 -0
  42. arche_sdk-0.1.0/tests/unit/test_client.py +50 -0
  43. arche_sdk-0.1.0/tests/unit/test_company_references.py +78 -0
  44. arche_sdk-0.1.0/tests/unit/test_config.py +16 -0
  45. arche_sdk-0.1.0/tests/unit/test_envelopes.py +54 -0
  46. arche_sdk-0.1.0/tests/unit/test_errors.py +145 -0
  47. arche_sdk-0.1.0/tests/unit/test_fundamentals_exports.py +13 -0
  48. arche_sdk-0.1.0/tests/unit/test_imports.py +30 -0
  49. arche_sdk-0.1.0/tests/unit/test_pagination.py +105 -0
  50. arche_sdk-0.1.0/tests/unit/test_query_serialization.py +104 -0
  51. arche_sdk-0.1.0/tests/unit/test_request_options.py +45 -0
  52. arche_sdk-0.1.0/tests/unit/test_statement_quality_model.py +102 -0
  53. arche_sdk-0.1.0/tests/unit/test_transport.py +86 -0
  54. arche_sdk-0.1.0/tests/unit/test_transport_additional.py +63 -0
  55. arche_sdk-0.1.0/tests/unit/test_usd_values.py +86 -0
  56. arche_sdk-0.1.0/tests/unit/test_version_identity_fields.py +67 -0
@@ -0,0 +1,147 @@
1
+ # ============================================================================
2
+ # Arche API - .gitignore
3
+ # Disciplined, minimal, and security-safe.
4
+ # ============================================================================
5
+
6
+ # --- Claude Code ---
7
+ # Local settings and worktrees stay private; shared project skills, settings
8
+ # and hooks are tracked. settings.local.json stays ignored.
9
+ .claude/*
10
+ !.claude/skills/
11
+ !.claude/settings.json
12
+ !.claude/hooks/
13
+
14
+ # --- Python bytecode / caches ---
15
+ __pycache__/
16
+ *.py[cod]
17
+ *.pyd
18
+
19
+ # --- Virtual environments ---
20
+ .venv/
21
+ venv/
22
+ ENV/
23
+
24
+ # --- Test / type / lint caches ---
25
+ .pytest_cache/
26
+ .mypy_cache/
27
+ .ruff_cache/
28
+ htmlcov/
29
+ .coverage
30
+ coverage.xml
31
+ coverage.json
32
+
33
+ # --- Environment / secrets files ---
34
+ .env
35
+ .env.*
36
+ !.env.example
37
+ !.env.development.sample
38
+ !.env.production.sample
39
+ !.env.ci.sample
40
+ .envrc
41
+
42
+ # --- Logs & archives ---
43
+ *.log
44
+ *.zip
45
+ # The webhook probe receiver deploys from its committed package.
46
+ !infra/production/webhook_probe_receiver/handler.zip
47
+
48
+ # --- OS / editor junk ---
49
+ .DS_Store
50
+ .idea/
51
+ .vscode/
52
+ inspectionProfile.xml
53
+
54
+ # --- Node / frontend ---
55
+ node_modules/
56
+ dist/
57
+
58
+ # --- Build artifacts ---
59
+ build/
60
+ *.so
61
+
62
+ # --- Packaging metadata (setuptools) ---
63
+ *.egg-info
64
+ *.egg-info/
65
+
66
+
67
+ # --- Native build artifacts (project-specific) ---
68
+ native/build/
69
+ native/__pycache__/
70
+ native/*.so
71
+ native/*.pyd
72
+ native/*.dll
73
+ native/*.dylib
74
+ native/*.egg-info/
75
+ native/compile_commands.json
76
+
77
+ # --- Project-specific generated artifacts ---
78
+ artifacts/
79
+ .tmp/
80
+ tmp_*
81
+ *.local.csv
82
+ *.local.json
83
+ *.local.jsonl
84
+ audit_report.json
85
+ docs/project_structure.txt
86
+
87
+ # --- Repo-private / tooling docs (do not publish) ---
88
+ AGENTS.md
89
+
90
+ # ---------------------------------------------------------------------------
91
+ # AI / Codex / LLM tooling artifacts (NEVER COMMIT)
92
+ # ---------------------------------------------------------------------------
93
+ .codex/
94
+ .codex-cache/
95
+ .codex-output/
96
+ .codex-tmp/
97
+ .ai/
98
+ .ai-cache/
99
+ .ai-output/
100
+ .llm/
101
+ .llm-cache/
102
+ .copilot/
103
+ .cursor/
104
+ .cursor-cache/
105
+ .cursor-tmp/
106
+
107
+ scratch/
108
+ scratchpad/
109
+ tmp-ai/
110
+ tmp-llm/
111
+
112
+ *.prompt.md
113
+ *.prompt.txt
114
+ *.agent.md
115
+ *.agent.log
116
+ *.llm.log
117
+ *.llm.json
118
+
119
+ # ---------------------------------------------------------------------------
120
+ # Terraform (NEVER COMMIT: state, plans, secrets, provider dirs)
121
+ # ---------------------------------------------------------------------------
122
+ **/.terraform/
123
+ *.tfstate
124
+ *.tfstate.*
125
+ *.tfplan
126
+ tfplan
127
+ crash.log
128
+ crash.*.log
129
+ **/*.tfvars
130
+ **/*.tfvars.json
131
+ .terraform.lock.hcl.bak
132
+ **/.terraform.lock.hcl.bak
133
+
134
+ # ---------------------------------------------------------------------------
135
+ # VPN / key material (NEVER COMMIT)
136
+ # ---------------------------------------------------------------------------
137
+ **/*.ovpn
138
+ **/*.pem
139
+ **/*.key
140
+ **/*.p12
141
+ **/*.pfx
142
+
143
+ # The OpenAPI snapshot test writes its normalized comparison here on a
144
+ # mismatch. Refreshing the snapshot leaves them behind, where `git add -A`
145
+ # sweeps them into the next commit.
146
+ tests/openapi/debug/
147
+ .aider*
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,280 @@
1
+ Metadata-Version: 2.5
2
+ Name: arche-sdk
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for Arche public data APIs
5
+ Project-URL: Homepage, https://arche.fi
6
+ Project-URL: Documentation, https://docs.arche.fi/sdks/python
7
+ Project-URL: Repository, https://github.com/ProtosSystems/arche-api
8
+ Project-URL: Issues, https://github.com/ProtosSystems/arche-api/issues
9
+ Author: Arche
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: api,arche,edgar,finance,sdk
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Office/Business :: Financial
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.11
21
+ Requires-Dist: httpx<1,>=0.27
22
+ Requires-Dist: pydantic<3,>=2.7
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
25
+ Requires-Dist: pytest>=8.0; extra == 'dev'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # Arche Python SDK
29
+
30
+ Typed, production-grade Python SDK for Arche public data APIs.
31
+
32
+ This initial release covers the primary public data surface:
33
+ - Companies
34
+ - Filings
35
+ - Statements
36
+ - Narratives
37
+ - Bulk export (Scale and Enterprise plans)
38
+
39
+ It does not include protected control-plane, billing, org/team/project/environment admin, usage, webhook, MCP, or internal ops routes.
40
+
41
+ ## Installation
42
+
43
+ ```bash
44
+ pip install arche-sdk
45
+ ```
46
+
47
+ For local monorepo usage:
48
+
49
+ ```bash
50
+ pip install -e sdks/python
51
+ ```
52
+
53
+ ## Authentication
54
+
55
+ ### API key
56
+
57
+ ```python
58
+ from arche_sdk import ArcheClient
59
+
60
+ client = ArcheClient(api_key="your_api_key")
61
+ ```
62
+
63
+ ### Bearer token for protected portal/control-plane routes
64
+
65
+ ```python
66
+ from arche_sdk import ArcheClient
67
+
68
+ client = ArcheClient(bearer_token="your_jwt_or_token")
69
+ ```
70
+
71
+ Use bearer auth only for protected portal/control-plane or internal routes that
72
+ explicitly require it. Public runtime API examples and quickstarts should use
73
+ `api_key`.
74
+
75
+ `api_key` and `bearer_token` are mutually exclusive; passing both raises
76
+ `ValueError`.
77
+
78
+ ## Quickstart
79
+
80
+ ### Companies
81
+
82
+ ```python
83
+ from arche_sdk import ArcheClient
84
+
85
+ with ArcheClient(api_key="...") as client:
86
+ company = client.companies.get("0000320193")
87
+ resolved = client.companies.resolve("AAPL")
88
+ completeness = client.companies.get_completeness("0000320193")
89
+ ```
90
+
91
+ ### Naming a company
92
+
93
+ Every method that takes a `cik` also accepts a ticker symbol in its place, and a
94
+ `ciks` list accepts tickers. Digits are sent as a CIK and anything else as a
95
+ ticker, which the API resolves to the company whose filings hold its statements
96
+ on the request's date; one list must hold CIKs only or tickers only. A
97
+ `company_id` (narratives) takes the company UUID, the CIK or the ticker.
98
+
99
+ ```python
100
+ with ArcheClient(api_key="...") as client:
101
+ versions = client.statements.list("AAPL", statement_type="INCOME_STATEMENT")
102
+ derived = client.statements.get_derived_metrics_time_series(
103
+ ciks=["AAPL", "MSFT"],
104
+ statement_type="INCOME_STATEMENT",
105
+ metrics=["GROSS_MARGIN"],
106
+ frequency="annual",
107
+ )
108
+ ```
109
+
110
+ ### Filings
111
+
112
+ ```python
113
+ with ArcheClient(api_key="...") as client:
114
+ page = client.filings.list("0000320193", filing_types=["10-K"], page=1, page_size=20)
115
+ filing = client.filings.get("0000320193", "0000320193-24-000001")
116
+ statements = client.filings.list_statements("0000320193", "0000320193-24-000001")
117
+ ```
118
+
119
+ ### Statements
120
+
121
+ ```python
122
+ with ArcheClient(api_key="...") as client:
123
+ versions = client.statements.list("0000320193", statement_type="INCOME_STATEMENT")
124
+ timeline = client.statements.get_restatement_timeline(
125
+ "0000320193", "INCOME_STATEMENT", 2024, "FY"
126
+ )
127
+ derived = client.statements.get_derived_metrics_time_series(
128
+ ciks=["0000320193"],
129
+ statement_type="INCOME_STATEMENT",
130
+ metrics=["GROSS_MARGIN"],
131
+ frequency="annual",
132
+ )
133
+
134
+ # As known at a date, only the statements asked for: here the FY2024
135
+ # income statement. snapshot_hash still names the full as-of selection.
136
+ as_of = client.statements.get_as_of_financials_page(
137
+ "2025-03-31",
138
+ "AAPL",
139
+ limit=10,
140
+ statement_type="INCOME_STATEMENT",
141
+ fiscal_year_from=2024,
142
+ fiscal_year_to=2024,
143
+ fiscal_period="FY",
144
+ )
145
+ ```
146
+
147
+ ### Narratives
148
+
149
+ ```python
150
+ with ArcheClient(api_key="...") as client:
151
+ narratives = client.narratives.list(
152
+ "11111111-1111-1111-1111-111111111111",
153
+ as_of="2024-12-31",
154
+ narrative_type="CHANGE_SUMMARY",
155
+ )
156
+ ```
157
+
158
+ ### Bulk export
159
+
160
+ Scale and Enterprise plans can take a complete local copy of the served corpus
161
+ as Parquet files instead of paging the API. `sync()` fetches only what changed:
162
+
163
+ ```python
164
+ with ArcheClient(api_key="...") as client:
165
+ result = client.bulk.sync("./arche-corpus")
166
+
167
+ print(result.snapshot_id, len(result.downloaded), "downloaded")
168
+ print(len(result.skipped), "already held")
169
+ ```
170
+
171
+ Download URLs are issued under the bulk-data license, which the organization
172
+ accepts once per license version. Until it has, `sync()` raises
173
+ `BulkLicenseNotAcceptedError`. Read the license and accept it from the SDK; the
174
+ person named confirms they may bind the organization:
175
+
176
+ ```python
177
+ with ArcheClient(api_key="...") as client:
178
+ current = client.bulk.license()
179
+ print(current.license_version, current.accepted)
180
+ if not current.accepted:
181
+ print(current.text)
182
+ client.bulk.accept_license(name="Jane Doe", email="jane@example.com")
183
+ ```
184
+
185
+ `accept_license()` accepts the version and SHA-256 that `license()` returns, so
186
+ the acceptance is of the text served at that moment. Accepting a version the
187
+ organization already accepted returns the existing record unchanged.
188
+
189
+ Run it again tomorrow against the same directory and it transfers only the
190
+ partitions whose bytes moved. A file is skipped when the local copy already
191
+ hashes to the `sha256` the snapshot's manifest records, so the skip is a
192
+ statement about the bytes on disk rather than about a timestamp, and an
193
+ interrupted sync resumes correctly. Digests are remembered in
194
+ `<destination>/.arche-bulk-sync.json` so a second sync does not reread
195
+ gigabytes to prove nothing changed; a file whose size or modification time
196
+ differs from the record is rehashed rather than trusted, and `rehash=True`
197
+ ignores the record entirely.
198
+
199
+ Restrict the sync, or watch it:
200
+
201
+ ```python
202
+ def show(event):
203
+ print(f"[{event.index}/{event.total}] {event.action} {event.path}")
204
+
205
+ with ArcheClient(api_key="...") as client:
206
+ client.bulk.sync("./arche-corpus", datasets=["statements", "financials"], progress=show)
207
+ ```
208
+
209
+ Read the contract, browse snapshots, or fetch one file:
210
+
211
+ ```python
212
+ with ArcheClient(api_key="...") as client:
213
+ for dataset in client.bulk.datasets():
214
+ print(dataset.dataset, dataset.partition_column, [c.name for c in dataset.columns])
215
+
216
+ manifest = client.bulk.snapshot() # "latest" by default
217
+ print(manifest.snapshot_id, manifest.read_at, manifest.bytes)
218
+
219
+ changed = [item.path for item in manifest.files if item.changed]
220
+ client.bulk.download_file(manifest.snapshot_id, changed[0], "./arche-corpus")
221
+ ```
222
+
223
+ Every download is verified against the manifest's checksum and raises
224
+ `ChecksumMismatchError` on a mismatch, removing the partial file. A manifest
225
+ path that would write outside the destination is refused rather than resolved. The URLs are
226
+ presigned and carry their own credentials: the SDK fetches them without an API
227
+ key, and each one is charged its file's full size against the organization's
228
+ daily download allowance when it is issued, not when the bytes move. Past the
229
+ allowance the API answers `RateLimitError` with code
230
+ `BULK_DOWNLOAD_BUDGET_EXCEEDED`.
231
+
232
+ Read the files with any Parquet reader. Partition directories are named
233
+ `fiscal_year_2025`, not Hive's `fiscal_year=2025`, because the files already
234
+ carry the partition as a column:
235
+
236
+ ```python
237
+ import duckdb
238
+
239
+ duckdb.sql("SELECT * FROM './arche-corpus/financials/*/*.parquet' LIMIT 5").show()
240
+ ```
241
+
242
+ ## Pagination
243
+
244
+ List endpoints return `Page[T]` with `page`, `page_size`, `total`, and `items`.
245
+
246
+ ```python
247
+ with ArcheClient(api_key="...") as client:
248
+ first_page = client.filings.list("0000320193", page=1, page_size=50)
249
+ if first_page.has_next:
250
+ second_page = client.filings.list("0000320193", page=2, page_size=50)
251
+
252
+ for filing in client.filings.iter_all("0000320193", page_size=100):
253
+ print(filing.accession_id)
254
+ ```
255
+
256
+ ## Error handling
257
+
258
+ ```python
259
+ from arche_sdk import ArcheClient
260
+ from arche_sdk.errors import APIError, RateLimitError
261
+
262
+ try:
263
+ with ArcheClient(api_key="...") as client:
264
+ client.companies.get("0000000000")
265
+ except RateLimitError as exc:
266
+ print(exc.retry_after, exc.rate_limit_remaining)
267
+ except APIError as exc:
268
+ print(exc.status_code, exc.code, exc.message, exc.trace_id, exc.request_id)
269
+ ```
270
+
271
+ ## Request ID and trace ID
272
+
273
+ - The SDK sends `X-Request-ID` on every request (auto-generated when missing).
274
+ - On API errors, the SDK exposes:
275
+ - `request_id` from response `X-Request-ID`
276
+ - `trace_id` from canonical error envelope (`error.trace_id`)
277
+
278
+ ## License
279
+
280
+ Apache License 2.0. See [LICENSE](LICENSE).