xippios-usda-esmis 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.
- xippios_usda_esmis-0.1.0/.gitignore +23 -0
- xippios_usda_esmis-0.1.0/CHANGELOG.md +76 -0
- xippios_usda_esmis-0.1.0/LICENSE +201 -0
- xippios_usda_esmis-0.1.0/PKG-INFO +213 -0
- xippios_usda_esmis-0.1.0/README.md +184 -0
- xippios_usda_esmis-0.1.0/docs/upstream/FETCHED.md +90 -0
- xippios_usda_esmis-0.1.0/docs/upstream/openapi/esmis_public_api.yaml +395 -0
- xippios_usda_esmis-0.1.0/docs/upstream/pages/publication-wasde.md +40 -0
- xippios_usda_esmis-0.1.0/docs/upstream/pages/release-calendar.md +82 -0
- xippios_usda_esmis-0.1.0/docs/upstream/pages/release-wasde.md +18 -0
- xippios_usda_esmis-0.1.0/pyproject.toml +100 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/__init__.py +32 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/_client.py +151 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/_version.py +10 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/api/__init__.py +45 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/api/agency_find_all.py +27 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/api/agency_find_by_acronym.py +37 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/api/agency_find_by_id.py +36 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/api/publication_find_all.py +32 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/api/publication_find_by_agency.py +38 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/api/publication_find_by_id.py +37 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/api/publication_find_by_identifier.py +46 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/api/publication_search.py +37 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/api/release_find_all.py +30 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/api/release_find_by_id.py +35 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/api/release_find_by_identifier.py +50 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/api/release_find_by_pub_id.py +40 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/enums.py +9 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/http.py +16 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/mcp.py +30 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/models.py +377 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/params.py +43 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/py.typed +0 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/reference/README.md +51 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/reference/agency.json +98 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/reference/publication.json +38692 -0
- xippios_usda_esmis-0.1.0/src/xippios/usda/esmis/tasks.py +570 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# environments and caches
|
|
2
|
+
.venv/
|
|
3
|
+
__pycache__/
|
|
4
|
+
*.py[cod]
|
|
5
|
+
.mypy_cache/
|
|
6
|
+
.ruff_cache/
|
|
7
|
+
.pytest_cache/
|
|
8
|
+
.hypothesis/
|
|
9
|
+
|
|
10
|
+
# build artefacts
|
|
11
|
+
dist/
|
|
12
|
+
build/
|
|
13
|
+
*.egg-info/
|
|
14
|
+
|
|
15
|
+
# local secrets are never files, but belt and braces
|
|
16
|
+
.env
|
|
17
|
+
.env.*
|
|
18
|
+
.envrc
|
|
19
|
+
.envrc.*
|
|
20
|
+
|
|
21
|
+
# editors
|
|
22
|
+
.idea/
|
|
23
|
+
.vscode/
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
|
|
5
|
+
[Semantic Versioning](https://semver.org/) (pre-1.0: breaking changes bump the minor).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.1.0] - 2026-10-27
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Scaffold from [sdk-template](https://github.com/xippios/sdk-template): configured
|
|
14
|
+
client for USDA ESMIS, MCP server and FastAPI router wired to the task layer, test
|
|
15
|
+
harness with core's family check, CI, the nightly live tests and the release train,
|
|
16
|
+
in which a release PR's merge tags and publishes.
|
|
17
|
+
- Upstream documentation snapshot in `docs/upstream/`, fetched 2026-10-27, and its
|
|
18
|
+
capture script `scripts/refresh_upstream.py`: the ESMIS OpenAPI document verbatim,
|
|
19
|
+
the WASDE publication page and its newest release's page as Markdown, and an excerpt
|
|
20
|
+
of the release calendar, with `FETCHED.md` recording every fetch.
|
|
21
|
+
- README and CLAUDE.md name ESMIS in full; the README lists where the live API deviates
|
|
22
|
+
from its OpenAPI document, as probed on 2026-10-27.
|
|
23
|
+
- Attribution: the README and `docs/upstream/FETCHED.md` state that the ESMIS
|
|
24
|
+
documentation and release files are works of the United States Government, in the
|
|
25
|
+
public domain in the United States (17 U.S.C. § 105), and cite USDA's policy page.
|
|
26
|
+
- Endpoint wrappers for the twelve operations of the ESMIS catalog (agencies,
|
|
27
|
+
publications, releases) under `xippios.usda.esmis.api`, the models `Agency`, `Pager`,
|
|
28
|
+
`Publication`, `Release`, `PublicationResults` and `ReleaseResults` typed as the wire
|
|
29
|
+
sends them, with the `StrEnum`s `Status`, `Subscribable` and `ResourceType` that a walk
|
|
30
|
+
of every publication page confirmed, and the client's `classify`: an unknown id, which
|
|
31
|
+
the four lookups by id answer with HTTP 404, is `NotFoundError`, and an identifier
|
|
32
|
+
carrying `/`, which ESMIS refuses, `InvalidRequestError`; the lookups by acronym or
|
|
33
|
+
identifier answer an unknown one with an empty HTTP 200, returned as such. Recorded
|
|
34
|
+
fixtures and replay tests in `tests/test_api.py`; CLAUDE.md gains the ESMIS specifics.
|
|
35
|
+
- Seven catalog tasks, each an MCP tool and an HTTP route: `list_agencies`,
|
|
36
|
+
`search_publications` and `get_publication`, `list_releases` (newest first, with
|
|
37
|
+
`since`, `until` and `page`), `get_release`, `get_latest_release` and
|
|
38
|
+
`list_release_files` (each file's URL, name and format, the model `ReleaseFile`).
|
|
39
|
+
`meta.endpoint` names the operationId, `meta.total` upstream's count for the paged
|
|
40
|
+
lists, `meta.vintage` the release id; `meta.published_at` of a task about one release
|
|
41
|
+
is its `release_datetime` as printed, the `+0000` dropped, with `published_at_naive`
|
|
42
|
+
set (ADR-0022). An unknown identifier raises `NotFoundError` where one record is asked
|
|
43
|
+
for and gives the empty list from `list_releases`.
|
|
44
|
+
- `download_release_file(release_id, format, dest)`, a bulk task in `BULK_TASKS`,
|
|
45
|
+
Python only: it streams one file of a release to the path the caller names with
|
|
46
|
+
core's `download`, nothing cached, `meta.endpoint` the file's name as upstream prints
|
|
47
|
+
it (`wasde1026.txt`), `meta.published_at` the release's printed time with the flag.
|
|
48
|
+
Replay tests for every task, the tools called end to end, the October 2026 WASDE
|
|
49
|
+
`.txt` recorded whole for the download's replay, and live tests for every task and
|
|
50
|
+
for the release order the release tasks rely on.
|
|
51
|
+
- Two packaged reference tables, written by `scripts/refresh_reference.py` with core's
|
|
52
|
+
`PackagedList.write` on 2026-10-27: `reference/publication.json`, the 2522
|
|
53
|
+
publications of every page of `/publication/findAll`, each the eight columns of the
|
|
54
|
+
new projection `PublicationRow`, and `reference/agency.json`, the 9 agencies with every
|
|
55
|
+
field.
|
|
56
|
+
- `list_publications(search=None, agency_acronym=None)`, an MCP tool and an HTTP route
|
|
57
|
+
answered from the packaged publication table without a request: `search` matches the
|
|
58
|
+
id, an identifier or the title (core's `matches`), `agency_acronym` an acronym the row
|
|
59
|
+
lists, and an acronym the packaged agency table lacks is refused with core's
|
|
60
|
+
`UnknownCode`, naming the closest. `meta.retrieved_at` is the table's fetch time and
|
|
61
|
+
`meta.endpoint` `esmis_api_publication_findAll` (ADR-0022). Its MCP tool keeps the
|
|
62
|
+
default cap, 200 rows or 64 KB, with a note naming the two filters, since the whole
|
|
63
|
+
table is 599,402 bytes; Python and HTTP callers get the whole table (ADR-0016). Live
|
|
64
|
+
tests compare the packaged agencies and the publication count with upstream.
|
|
65
|
+
|
|
66
|
+
### Changed
|
|
67
|
+
|
|
68
|
+
- `xippios-core` 0.3.0 from PyPI (`core_version` 0.3.0, `~=0.3.0`; template v0.2.2),
|
|
69
|
+
which brings the api.data.gov gateway module (C14, unused by this keyless source),
|
|
70
|
+
`AsyncClient.download` for bulk files (C15, ADR-0019) and ADR-0022's
|
|
71
|
+
`ResultMeta.published_at_naive`, which the release tasks need.
|
|
72
|
+
- `scripts/refresh_reference.py` refreshes the two packaged tables through `api/` (102
|
|
73
|
+
requests: the agencies and the 101 publication pages, bounded by `total_pages`) and
|
|
74
|
+
rewrites the provenance rows of `reference/README.md`; it generates no `enums.py`, and
|
|
75
|
+
`params.PACKAGED_LISTS` is empty, since the tables are `PackagedList` files that
|
|
76
|
+
`tasks.py` reads directly.
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: xippios-usda-esmis
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Typed client, MCP tools and HTTP routes for USDA ESMIS
|
|
5
|
+
Project-URL: Homepage, https://github.com/xippios/sdk-usda-esmis
|
|
6
|
+
Project-URL: Upstream, https://esmis.nal.usda.gov
|
|
7
|
+
Project-URL: Changelog, https://github.com/xippios/sdk-usda-esmis/blob/main/CHANGELOG.md
|
|
8
|
+
Project-URL: Issues, https://github.com/xippios/sdk-usda-esmis/issues
|
|
9
|
+
Author: XIPPIOS GmbH
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: agriculture,httpx,mcp,pydantic,sdk,usda-esmis
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.12
|
|
21
|
+
Requires-Dist: xippios-core~=0.3.0
|
|
22
|
+
Provides-Extra: http
|
|
23
|
+
Requires-Dist: xippios-core[http]~=0.3.0; extra == 'http'
|
|
24
|
+
Provides-Extra: mcp
|
|
25
|
+
Requires-Dist: xippios-core[mcp]~=0.3.0; extra == 'mcp'
|
|
26
|
+
Provides-Extra: testing
|
|
27
|
+
Requires-Dist: xippios-core[testing]~=0.3.0; extra == 'testing'
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# xippios-usda-esmis
|
|
31
|
+
|
|
32
|
+
Typed Python client, MCP server and FastAPI routes for
|
|
33
|
+
[USDA ESMIS](https://esmis.nal.usda.gov), the Economics, Statistics, and Market
|
|
34
|
+
Information System of USDA's National Agricultural Library, part of the
|
|
35
|
+
[xippios SDK family](https://github.com/xippios). Names and semantics follow the
|
|
36
|
+
upstream documentation; every response carries release metadata (source, endpoint,
|
|
37
|
+
retrieved_at, published_at, vintage).
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
uv add xippios-usda-esmis # client only
|
|
43
|
+
uv add "xippios-usda-esmis[mcp]" # + MCP server
|
|
44
|
+
uv add "xippios-usda-esmis[http]" # + FastAPI router
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
No API key is needed.
|
|
48
|
+
|
|
49
|
+
## 30-second example
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from pathlib import Path
|
|
53
|
+
|
|
54
|
+
from xippios.usda.esmis import download_release_file, get_latest_release, list_release_files
|
|
55
|
+
|
|
56
|
+
latest = get_latest_release("wasde") # the newest WASDE release
|
|
57
|
+
latest.data.id, latest.data.release_datetime # "796099", 2026-10-09 12:00:00+00:00, as printed
|
|
58
|
+
latest.meta.vintage # "796099": the release id
|
|
59
|
+
latest.meta.published_at # 2026-10-09 12:00:00, the printed time without its +0000
|
|
60
|
+
latest.meta.published_at_naive # True: upstream's text, no zone attached (ADR-0022)
|
|
61
|
+
|
|
62
|
+
files = list_release_files(int(latest.data.id))
|
|
63
|
+
[file.format for file in files.data] # ["pdf", "txt", "xls", "xml"]
|
|
64
|
+
|
|
65
|
+
# Python only, no MCP tool: streams the TXT to the path you name; nothing is cached
|
|
66
|
+
txt = download_release_file(796099, "txt", Path("wasde1026.txt"))
|
|
67
|
+
txt.data.path, txt.data.bytes, txt.data.content_type # wasde1026.txt, 122378, "text/plain"
|
|
68
|
+
txt.meta.endpoint # "wasde1026.txt": the file's name as upstream prints it
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`search_publications("wasde")` finds a publication's identifiers, and
|
|
72
|
+
`list_releases("wasde", since=date(2026, 1, 1))` its releases since a date, newest first.
|
|
73
|
+
|
|
74
|
+
`list_publications()` answers from the table of 2522 publications packaged with this
|
|
75
|
+
version, fetched on 2026-10-27, without a request:
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from xippios.usda.esmis import list_publications
|
|
79
|
+
|
|
80
|
+
wheat = list_publications(search="wheat") # id, identifier or title contains "wheat": 30
|
|
81
|
+
ers = list_publications(agency_acronym="ERS") # as list_agencies() spells it: 121
|
|
82
|
+
ers.meta.retrieved_at # 2026-10-27 17:24:48+00:00, when the table was fetched
|
|
83
|
+
ers.meta.endpoint # "esmis_api_publication_findAll", the operation it came from
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
An acronym the packaged agency table lacks raises `UnknownCode`, an
|
|
87
|
+
`InvalidRequestError` naming the closest (`"ers"`: did you mean `ERS`?).
|
|
88
|
+
|
|
89
|
+
## MCP
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"mcpServers": {
|
|
94
|
+
"usda-esmis": {
|
|
95
|
+
"command": "uvx",
|
|
96
|
+
"args": ["--from", "xippios-usda-esmis[mcp]", "xippios-usda-esmis-mcp"]
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Tools are read-only and named `usda_esmis_<verb>_<noun>`. Results are capped, at
|
|
103
|
+
200 rows or 64 KB unless a tool has a cap of its own, with a note on how to see the rest;
|
|
104
|
+
`usda_esmis_list_publications` keeps the default and says how to filter: unfiltered, its
|
|
105
|
+
packaged table is about 600 KB, so the tool returns its first 200 rows, while
|
|
106
|
+
`list_publications()` in Python and its HTTP route return the whole table.
|
|
107
|
+
`download_release_file` is no tool and no route: a bulk task, Python only (ADR-0019).
|
|
108
|
+
`--http` serves streamable HTTP instead of stdio.
|
|
109
|
+
|
|
110
|
+
## Status
|
|
111
|
+
|
|
112
|
+
<!-- Core's family check (tests/test_family.py) reads this table: keep the "## Status"
|
|
113
|
+
heading and the "Task function" column. Each row's Task function cell starts with the
|
|
114
|
+
task's name in backticks, alone or as its call (`get_data(code, year)`); several tasks in
|
|
115
|
+
one row are backticked names separated by commas; prose may follow. The tables list
|
|
116
|
+
exactly tasks.__all__ and tasks_write.__all__. -->
|
|
117
|
+
|
|
118
|
+
| Upstream operation | Task function | MCP tool | Status |
|
|
119
|
+
| --- | --- | --- | --- |
|
|
120
|
+
| `esmis_api_agency_findAll` | `list_agencies()` | `usda_esmis_list_agencies` | alpha |
|
|
121
|
+
| `esmis_api_publication_findAll`, every page, packaged (fetched 2026-10-27; no request) | `list_publications(search=None, agency_acronym=None)` | `usda_esmis_list_publications` | alpha |
|
|
122
|
+
| `esmis_api_publication_search`, every page unless `page` is given | `search_publications(query, page=None)` | `usda_esmis_search_publications` | alpha |
|
|
123
|
+
| `esmis_api_publication_findByIdentifier` | `get_publication(publication_identifier)` | `usda_esmis_get_publication` | alpha |
|
|
124
|
+
| `esmis_api_release_findByIdentifier`, pages walked newest first unless `page` is given | `list_releases(publication_identifier, since=None, until=None, page=None)` | `usda_esmis_list_releases` | alpha |
|
|
125
|
+
| `esmis_api_release_findById` | `get_release(release_id)` | `usda_esmis_get_release` | alpha |
|
|
126
|
+
| `esmis_api_release_findByIdentifier`, page 0 | `get_latest_release(publication_identifier)` | `usda_esmis_get_latest_release` | alpha |
|
|
127
|
+
| `esmis_api_release_findById` | `list_release_files(release_id)` | `usda_esmis_list_release_files` | alpha |
|
|
128
|
+
| `esmis_api_release_findById`, then the file | `download_release_file(release_id, format, dest)`, a bulk task | none, Python only | alpha |
|
|
129
|
+
|
|
130
|
+
## Where the live API deviates from its OpenAPI document (probed 2026-10-27)
|
|
131
|
+
|
|
132
|
+
The OpenAPI document in `docs/upstream/openapi/esmis_public_api.yaml` is the reference
|
|
133
|
+
for names and parameters; the live API answers differently in these points:
|
|
134
|
+
|
|
135
|
+
- every `id` is a JSON string, not an integer; the walk of every `/publication/findAll`
|
|
136
|
+
page on 2026-10-27 (pages 0 to 100) found 2522 publications with distinct ids, each a
|
|
137
|
+
string of digits;
|
|
138
|
+
- `Publication.agency`, `.identifier` and `.agency_acronym` are arrays, not strings;
|
|
139
|
+
- `agency_acronym` is absent on the publications the four other publication operations
|
|
140
|
+
answer, which carry `publication_agency_export_1` instead; `/publication/findAll`
|
|
141
|
+
carried `agency_acronym` on all 2522 publications of the walk and
|
|
142
|
+
`publication_agency_export_1` on none;
|
|
143
|
+
- `Publication.frequency` printed `""` on one publication of the walk (1172), a value
|
|
144
|
+
the document's enumeration does not list; `status`, `subscribable` and
|
|
145
|
+
`resource_type` held only the document's values;
|
|
146
|
+
- the list wrapper has `filters`, `sorters` and `system` (`{"page_key": "page"}`)
|
|
147
|
+
beside `pager` and `results`;
|
|
148
|
+
- `/publication/search` without `query`, or with an empty one, answers 200 with
|
|
149
|
+
`"pager": []` and empty results, although the document makes `query` required;
|
|
150
|
+
- absence answers differ per lookup, as recorded: an unknown id answers 404
|
|
151
|
+
`{"message": ""}` at `/agency/findById`, `/publication/findById`, `/release/findById`
|
|
152
|
+
and `/release/findByPubId`; an unknown name answers 200 with nothing,
|
|
153
|
+
`/agency/findByAcronym` an empty array, `/publication/findByAgency`,
|
|
154
|
+
`/publication/findByIdentifier` and `/release/findByIdentifier` empty results with
|
|
155
|
+
every pager count 0;
|
|
156
|
+
- an identifier carrying `/` (`Market and Trade Economics Division/FDS`) cannot be
|
|
157
|
+
looked up: the web server answers `%2F` in a path with its own HTML 404, and a raw
|
|
158
|
+
slash is no route; every publication recorded with such an identifier has another
|
|
159
|
+
without it (`FDS`);
|
|
160
|
+
- `page` is 0-based and a page holds 25 items, as the YAML's defaults say; undocumented
|
|
161
|
+
are that the page size is fixed and that a page past the last answers empty results
|
|
162
|
+
with `current_page` clamped;
|
|
163
|
+
- the orders are undocumented: `/release/findAll` comes highest id first, the newest
|
|
164
|
+
created, with `release_datetime` only mostly in that order (page 0 runs 2026-10-26,
|
|
165
|
+
2026-10-09, 2026-10-23); a publication's releases (`/release/findByIdentifier`) come
|
|
166
|
+
latest `release_datetime` first, as recorded on WASDE's pages 0 and 1 (50 releases,
|
|
167
|
+
2026-10-09 back to 2022-08-12), while their ids do not follow the dates (96169, 96170
|
|
168
|
+
and 96171 are August, July and June 2025); publication lists follow no id order
|
|
169
|
+
(`/publication/findAll` page 0: ids 2425, 1801, 1861, 1922;
|
|
170
|
+
`/publication/search?query=wasde`: 1762, 1831, 1154);
|
|
171
|
+
- `release_datetime` is `YYYY-MM-DDTHH:MM:SS+0000` (a zone, no colon);
|
|
172
|
+
- `Release.files` paths take two shapes: recent releases use
|
|
173
|
+
`/sites/default/release-files/{release id}/{name}.{ext}`
|
|
174
|
+
(`/sites/default/release-files/796099/wasde1026.txt`), older ones the hashed
|
|
175
|
+
three-segment path the YAML's example shows
|
|
176
|
+
(`/sites/default/release-files/8336h188j/2514qk05k/j0991c960/prog3925.pdf`);
|
|
177
|
+
- `Publication.upcoming_releases` is `[]` on most publications: the walk found items on
|
|
178
|
+
24 of 2522, 67 in all, each printed with an Eastern offset
|
|
179
|
+
(`2026-10-28T15:00:00-0400` and `2026-11-04T15:00:00-0500` for publication 1863),
|
|
180
|
+
where `release_datetime` prints `+0000`; the YAML lists no release-calendar operation;
|
|
181
|
+
- the zone label of release times: the API prints `release_datetime` with `+0000` and
|
|
182
|
+
the release page its `datetime` with `Z` (`2026-10-09T12:00:00+0000` and
|
|
183
|
+
`datetime="2026-10-09T12:00:00Z"` for the October 2026 WASDE), while the release
|
|
184
|
+
calendar, whose settings say `timeZone: "America/New_York"`, puts the WASDE releases
|
|
185
|
+
that `/release/findByIdentifier/wasde` (page 0) prints as `2025-09-12T12:00:00+0000`
|
|
186
|
+
and `2025-12-09T12:00:00+0000` at `2025-09-12T12:00:00-04:00` and
|
|
187
|
+
`2025-12-09T12:00:00-05:00`, and the October release's own file answers
|
|
188
|
+
`HEAD /sites/default/release-files/796099/wasde1026.txt` with
|
|
189
|
+
`Last-Modified: Fri, 09 Oct 2026 16:01:00 GMT`, 12:01 Eastern. The `+0000`/`Z` label
|
|
190
|
+
is contradicted by upstream's own calendar and file timestamps, which fit a noon
|
|
191
|
+
Eastern wall-clock time (the recorded download of `wasde1026.txt` answers the same
|
|
192
|
+
`Last-Modified`); the tasks keep `release_datetime` as printed, and those about one
|
|
193
|
+
release put its wall-clock time, the `+0000` dropped, into `meta.published_at` with
|
|
194
|
+
`published_at_naive` set (ADR-0022; CLAUDE.md, release times);
|
|
195
|
+
- the release calendar page (`docs/upstream/pages/release-calendar.md`) held 3776
|
|
196
|
+
events, drawn from a `publication_upcoming_releases` field (each event's
|
|
197
|
+
`startField`), while the API's `Publication.upcoming_releases` lists 67 upcoming
|
|
198
|
+
releases on 24 publications; every calendar event is classed `fc-event-past`, future
|
|
199
|
+
ones included, and WASDE's events stop at 2025-12-09.
|
|
200
|
+
|
|
201
|
+
## Upstream terms and attribution
|
|
202
|
+
|
|
203
|
+
Data comes from USDA ESMIS (https://esmis.nal.usda.gov) under its own terms of use;
|
|
204
|
+
this package adds no rights to it. The documentation and the release files are works of
|
|
205
|
+
the United States Government (USDA National Agricultural Library, ESMIS), in the public
|
|
206
|
+
domain in the United States (17 U.S.C. § 105); a suggested credit line is "Source:
|
|
207
|
+
USDA National Agricultural Library, ESMIS". The pages the snapshot reads print no
|
|
208
|
+
copyright line, and USDA's policy page is cited in `docs/upstream/FETCHED.md`,
|
|
209
|
+
Attribution. Documentation snapshot: `docs/upstream/`.
|
|
210
|
+
|
|
211
|
+
## Licence
|
|
212
|
+
|
|
213
|
+
Apache-2.0. See [LICENSE](LICENSE).
|