xippios-usda-wasde 0.1.1__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 (38) hide show
  1. xippios_usda_wasde-0.1.1/.gitignore +23 -0
  2. xippios_usda_wasde-0.1.1/CHANGELOG.md +103 -0
  3. xippios_usda_wasde-0.1.1/LICENSE +201 -0
  4. xippios_usda_wasde-0.1.1/PKG-INFO +168 -0
  5. xippios_usda_wasde-0.1.1/README.md +136 -0
  6. xippios_usda_wasde-0.1.1/docs/upstream/FETCHED.md +98 -0
  7. xippios_usda_wasde-0.1.1/docs/upstream/New_WASDE_Filename_Format.pdf +0 -0
  8. xippios_usda_wasde-0.1.1/docs/upstream/layout.md +410 -0
  9. xippios_usda_wasde-0.1.1/docs/upstream/pages/about-wasde.md +19 -0
  10. xippios_usda_wasde-0.1.1/docs/upstream/pages/historical-changes-revisions.md +148 -0
  11. xippios_usda_wasde-0.1.1/docs/upstream/pages/historical-wasde-report-data.md +64 -0
  12. xippios_usda_wasde-0.1.1/docs/upstream/pages/publication-wasde.md +50 -0
  13. xippios_usda_wasde-0.1.1/docs/upstream/pages/release-wasde.md +25 -0
  14. xippios_usda_wasde-0.1.1/docs/upstream/pages/wasde-faqs.md +76 -0
  15. xippios_usda_wasde-0.1.1/docs/upstream/pages/wasde-report.md +41 -0
  16. xippios_usda_wasde-0.1.1/pyproject.toml +118 -0
  17. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/__init__.py +31 -0
  18. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/_client.py +49 -0
  19. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/_version.py +10 -0
  20. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/_vocabulary.py +327 -0
  21. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/api/__init__.py +4 -0
  22. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/enums.py +9 -0
  23. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/errors.py +11 -0
  24. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/http.py +18 -0
  25. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/mcp.py +33 -0
  26. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/models.py +415 -0
  27. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/params.py +18 -0
  28. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/parse/__init__.py +15 -0
  29. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/parse/wasde_pdf.py +94 -0
  30. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/parse/wasde_xls.py +146 -0
  31. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/parse/wasde_xml.py +356 -0
  32. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/py.typed +0 -0
  33. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/reference/README.md +82 -0
  34. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/reference/attribute.json +2714 -0
  35. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/reference/commodity.json +352 -0
  36. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/reference/region.json +687 -0
  37. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/reference/table.json +547 -0
  38. xippios_usda_wasde-0.1.1/src/xippios/usda/wasde/tasks.py +867 -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,103 @@
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.1] - 2026-10-29
10
+
11
+ The first version on PyPI. 0.1.0 was tagged on 2026-10-28, on its release PR's merge,
12
+ but never published: the pending trusted publisher on PyPI named another project, and
13
+ a publish run whose tag exists cannot be re-run from the start, so the release is
14
+ re-done as a patch, as `publish.yml` prescribes. 0.1.1 ships 0.1.0 unchanged; what it
15
+ contains is listed under 0.1.0 in `CHANGELOG.md`.
16
+
17
+ ## [0.1.0] - 2026-10-28
18
+
19
+ ### Added
20
+
21
+ - Scaffold from [sdk-template](https://github.com/xippios/sdk-template): configured
22
+ client for USDA WAOB World Agricultural Supply and Demand Estimates, MCP server and
23
+ FastAPI router wired to the task layer, test harness with core's family check, CI,
24
+ the nightly live tests and the release train, in which a release PR's merge tags and
25
+ publishes.
26
+ - Depends on `xippios-usda-esmis` 0.1.0 (`~=0.1.0`), the package that finds and
27
+ downloads USDA report files on ESMIS.
28
+ - Upstream documentation snapshot in `docs/upstream/`, captured by
29
+ `scripts/refresh_upstream.py`: the ESMIS publication page and the page of the newest
30
+ release, WAOB's WASDE page and the four pages its menu links (About WASDE, the FAQ,
31
+ Historical Changes & Revisions, the historical data page), and WAOB's 2018 notice of
32
+ the file names; a page www.usda.gov refuses to automated requests is kept from USDA's
33
+ CDN origin, its www.usda.gov address recorded by status. `layout.md` describes the
34
+ XML, XLS, TXT and PDF files as observed in the October 2026 release and the file kinds
35
+ and names of every release ESMIS lists.
36
+ - `list_releases(since, until)` and `get_latest_release()`: WASDE's releases in ESMIS
37
+ through `xippios-usda-esmis`'s tasks, each a `Release` with its id, its release time as
38
+ printed, its files, its month (`"YYYY-MM"`) and its `revision` (`"v2"` for a month
39
+ WAOB reposted); MCP tools `usda_wasde_list_releases` and `usda_wasde_get_latest_release`.
40
+ - `get_release(month)`, a bulk task, Python only: the XML of the latest release, or of
41
+ the month's latest release that carries one, downloaded through esmis into a temporary
42
+ directory and parsed into one `WasdeXmlCell` per value, 6543 for October 2026;
43
+ `meta.vintage` is the file's `Report_Month`, `meta.endpoint` the file's name.
44
+ - `parse.parse_wasde_xml(path)`: the XML of pages 8 to 37 read with the standard
45
+ library's ElementTree, labels as printed; `unit` is the subtitle of the pages that
46
+ state their unit there and the reliability tables' label for their average, smallest
47
+ and largest, `None` on the U.S. pages, whose unit rows the XML repeats in every row
48
+ group; an attribute the parser does not know raises `ValidationError`.
49
+ - Six XML samples cut from the October 2026 file by `scripts/cut_sample.py`, the esmis
50
+ catalog fixtures and the download's replay fixture, its body a sample; the live test
51
+ fetches the latest XML once. `docs/upstream/layout.md` now says that the XML repeats
52
+ each unit row in every row group, which unit a path carries, and which attributes on
53
+ elements are layout text.
54
+ - `list_tables(search)`, `list_commodities(search)` and `list_regions(search)`, MCP tools
55
+ `usda_wasde_list_tables`, `usda_wasde_list_commodities` and `usda_wasde_list_regions`:
56
+ answered without a request from four lists packaged under `reference/`, read from the
57
+ October 2026 release (`wasde1026.xml`, `wasde1026.xls`): its 30 table pages with
58
+ their titles, subtitles, footnotes and matrices, the 43 supply-and-use matrices of
59
+ pages 11 to 30, 32 and 33 with their commodity and region, its 70 region texts with
60
+ their pages, and its 451 row labels by matrix (`reference/attribute.json`, for the
61
+ tasks to come, no task yet).
62
+ The XML names the commodity of no matrix as a whole: on pages 12 to 15 it is the XLS's
63
+ block title of the same position, and the refresh refuses to write when a page's
64
+ titles and matrices differ in number; elsewhere the title's words. Only page 32's
65
+ records carry a `commodity`, one per row (e.g. `Beef`, `Pork`, `Broiler`, `Turkey`, `Red
66
+ Meat & Poultry`), while the list names its matrix `Meats`, so
67
+ `list_commodities(search="beef")` answers nothing. `meta.vintage` is the
68
+ release's `Report_Month`. `scripts/refresh_reference.py` downloads the latest XML and
69
+ XLS through esmis (five requests) and writes the lists, refreshed before each release;
70
+ the nightly live test compares them with the latest release, the month word of the
71
+ reliability titles masked and each table footer compared only for whether it is set,
72
+ never its text, which changes every release.
73
+ - `xlrd` is a dependency, reading the XLS's block titles and its narrative sheet.
74
+ - `get_table(table, month)` and `get_balance_sheet(commodity, region, month)`, MCP tools
75
+ `usda_wasde_get_table` and `usda_wasde_get_balance_sheet`: the values of one page of
76
+ the month's XML, or of one commodity's supply-and-use matrix as the packaged commodity
77
+ list names it, the U.S. or Mexico page for `"United States"` (the default) or
78
+ `"Mexico"` where the commodity has one (page 11's by-class wheat table left to
79
+ `get_table`), else the rows of its world pages whose region, without indent and
80
+ footnote marker, is the one given (`"Argentina"`, `"World"`). Both read the XML as
81
+ `get_release` does, one download per call, nothing kept, with its `meta`; a page,
82
+ commodity or region the packaged lists lack is refused before anything is sent,
83
+ naming the closest. Their records, `WasdeTableValue`, are `WasdeXmlCell` projected
84
+ without the page's labels (page title, subtitle, footnotes, report month), which
85
+ `list_tables` and `meta.vintage` state once. MCP caps of their own, each with a note
86
+ that says how to see the rest: `get_table` 400 rows or 128 KB, `get_balance_sheet`
87
+ 300 rows or 128 KB; every page and balance sheet of October 2026 fits.
88
+ - `read_report_text(month)`, MCP tool `usda_wasde_read_report_text`: the release's
89
+ narrative as text, from its XLS's sheet `WASDE Text` (25 paragraphs for October 2026,
90
+ `meta.vintage` the month the first table sheet prints), or, for a release without an
91
+ XLS or whose XLS holds no such sheet, from its PDF's narrative pages, up to the page
92
+ headed Interagency Commodity Estimates Committees, `meta.vintage` the ESMIS release id
93
+ (`"95659"`), since a PDF prints a date, not a month label; no figure is read from a
94
+ PDF.
95
+ - `parse.parse_wasde_xls(path)` and `parse.parse_wasde_pdf(path)`, the narrative's
96
+ parsers (`WasdeXlsText`, `WasdePdfPage`); `pypdf` is a dependency, `xlwt` a dev
97
+ dependency that writes the XLS sample.
98
+ - `scripts/cut_sample.py` cuts XLS samples (sheets copied cell by cell with xlwt) and
99
+ keeps PDF samples whole: an XLS sample of the October 2026 release's sheets `WASDE
100
+ Text` and `Page 8`, the July 2010 PDF (release 95659) and their download fixtures, a
101
+ second XML download fixture whose body is the sample of pages 11 and 24. The live
102
+ tests fetch the latest release's PDF once beside its XML and XLS and run the new tasks
103
+ on those files.
@@ -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,168 @@
1
+ Metadata-Version: 2.5
2
+ Name: xippios-usda-wasde
3
+ Version: 0.1.1
4
+ Summary: Typed client, MCP tools and HTTP routes for USDA WAOB World Agricultural Supply and Demand Estimates
5
+ Project-URL: Homepage, https://github.com/xippios/sdk-usda-wasde
6
+ Project-URL: Upstream, https://www.usda.gov/oce/commodity/wasde
7
+ Project-URL: Changelog, https://github.com/xippios/sdk-usda-wasde/blob/main/CHANGELOG.md
8
+ Project-URL: Issues, https://github.com/xippios/sdk-usda-wasde/issues
9
+ Author: XIPPIOS GmbH
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: httpx,mcp,pydantic,sdk,usda-wasde
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: pypdf>=6.21
22
+ Requires-Dist: xippios-core~=0.3.0
23
+ Requires-Dist: xippios-usda-esmis~=0.1.0
24
+ Requires-Dist: xlrd>=2.0.2
25
+ Provides-Extra: http
26
+ Requires-Dist: xippios-core[http]~=0.3.0; extra == 'http'
27
+ Provides-Extra: mcp
28
+ Requires-Dist: xippios-core[mcp]~=0.3.0; extra == 'mcp'
29
+ Provides-Extra: testing
30
+ Requires-Dist: xippios-core[testing]~=0.3.0; extra == 'testing'
31
+ Description-Content-Type: text/markdown
32
+
33
+ # xippios-usda-wasde
34
+
35
+ Typed Python client, MCP server and FastAPI routes for
36
+ [USDA WAOB World Agricultural Supply and Demand Estimates](https://www.usda.gov/oce/commodity/wasde), part of the
37
+ [xippios SDK family](https://github.com/xippios). Names and semantics follow the
38
+ upstream documentation; every response carries release metadata (source, endpoint,
39
+ retrieved_at, published_at, vintage).
40
+
41
+ ## Install
42
+
43
+ ```bash
44
+ uv add xippios-usda-wasde # client only
45
+ uv add "xippios-usda-wasde[mcp]" # + MCP server
46
+ uv add "xippios-usda-wasde[http]" # + FastAPI router
47
+ ```
48
+
49
+ It depends on `xippios-usda-esmis`, installed with it, to list WASDE's releases in ESMIS's
50
+ catalog and to download their files; this package's server serves its own tools only.
51
+
52
+ No API key is needed.
53
+
54
+ ## 30-second example
55
+
56
+ ```python
57
+ from datetime import date
58
+
59
+ from xippios.usda.wasde import (
60
+ get_balance_sheet,
61
+ get_latest_release,
62
+ get_release,
63
+ list_commodities,
64
+ list_releases,
65
+ read_report_text,
66
+ )
67
+
68
+ latest = get_latest_release() # the newest WASDE release in ESMIS
69
+ latest.data.id, latest.data.month # "796099", "2026-10"
70
+ latest.meta.published_at # 2026-10-09 12:00:00: ESMIS's printed time, no zone (ADR-0022)
71
+
72
+ releases = list_releases(since=date(2026, 1, 1)) # bound it: without since, 29 requests
73
+ [release.month for release in releases.data if release.revision] # ["2026-06", "2026-05"]
74
+
75
+ page_12 = list_commodities(search="sr12") # packaged with the package: no request
76
+ [row.commodity for row in page_12.data] # ["FEED GRAINS", "CORN"]: matrix1 and matrix2
77
+
78
+ corn = get_balance_sheet("CORN") # page 12's U.S. corn matrix, read from the latest XML
79
+ corn.meta.endpoint, corn.meta.vintage, len(corn.data) # "wasde1026.xml", "October 2026", 60
80
+ corn.data[0].attribute, corn.data[0].cell_value # "Area Planted", "90.9" (2024/25)
81
+ # its subtitle and footnotes are page 12's in list_tables(search="sr12"), stated once
82
+
83
+ october = get_release("2026-10") # Python only: every value, 6543 records, one download
84
+ narrative = read_report_text("2026-10") # the XLS's sheet WASDE Text, one string a paragraph
85
+ narrative.data[1][:6] # "WHEAT:"
86
+ ```
87
+
88
+ Each record of `get_release` is one value of the release's tables with the labels its
89
+ page prints, as printed (`WasdeXmlCell`): 6543 for October 2026, pages 8 to 37. `unit`
90
+ is what the file states: the subtitle of the world and summary pages (8 to 10, 18 to 30),
91
+ the label of a reliability table for its average, smallest and largest; on the U.S.
92
+ pages it is `None`, since the XML does not say which of its repeated unit rows the page
93
+ shows (the XLS and the TXT print them in place). `list_tables`, `list_commodities` and
94
+ `list_regions` answer from lists packaged with the package, read from the October 2026
95
+ release's files (ESMIS release 796099) by `scripts/refresh_reference.py`
96
+ (`reference/README.md`) and refreshed before each release: its 30 table pages with
97
+ their titles, subtitles and footnotes, the
98
+ 43 supply-and-use matrices of pages 11 to 30, 32 and 33 with their commodities, and its
99
+ 70 region texts, as printed. The XML names none of these matrices' commodities as a
100
+ whole: on pages 12 to 15 they are the XLS's block titles; only page 32's records carry a
101
+ `commodity`, one per row (e.g. `Beef`, `Pork`, `Broiler`, `Turkey`, `Red Meat & Poultry`),
102
+ while the list names its matrix `Meats`, so `list_commodities(search="beef")` answers
103
+ nothing.
104
+
105
+ `get_table` and `get_balance_sheet` answer a slice of `get_release`'s records, a page or
106
+ one commodity's matrix, the world pages' rows of one region, named as the packaged lists
107
+ name them (`"CORN"` is page 12's U.S. corn, `"Corn"` the world corn pages; `"Argentina"`
108
+ matches `" Argentina"`). Their records (`WasdeTableValue`) leave out the page's
109
+ own labels: its subtitle and footnotes, to which a marker such as `Trade 2/` refers, are
110
+ `list_tables`'s, stated once per page with its titles, the page's number line
111
+ (` WASDE - 676 - 12`) is left out, and the report month is `meta.vintage`. So every page
112
+ and balance sheet of October 2026 fits its tool's cap (`get_table` 400 rows or 128 KB,
113
+ `get_balance_sheet` 300 rows or 128 KB), each with a note that says how to see the rest
114
+ should one not. Each call downloads the month's XML and keeps nothing, so a Python
115
+ caller wanting several slices of one month calls `get_release` once.
116
+
117
+ `read_report_text` answers the narrative as text, from the XLS's sheet `WASDE Text`, or
118
+ from the PDF's narrative pages for a release without an XLS or whose XLS has no such
119
+ sheet; no figure is ever read from a PDF. `meta.vintage` is the month the XLS prints, or
120
+ for a PDF, which prints a date, the ESMIS release id. Task functions are listed in the
121
+ status table below.
122
+
123
+ ## MCP
124
+
125
+ ```json
126
+ {
127
+ "mcpServers": {
128
+ "usda-wasde": {
129
+ "command": "uvx",
130
+ "args": ["--from", "xippios-usda-wasde[mcp]", "xippios-usda-wasde-mcp"]
131
+ }
132
+ }
133
+ }
134
+ ```
135
+
136
+ Tools are read-only and named `usda_wasde_<verb>_<noun>`. Results are capped, at
137
+ 200 rows or 64 KB unless a tool has a cap of its own, with a note on how to see the rest.
138
+ `--http` serves streamable HTTP instead of stdio.
139
+
140
+ ## Status
141
+
142
+ <!-- Core's family check (tests/test_family.py) reads this table: keep the "## Status"
143
+ heading and the "Task function" column. Each row's Task function cell starts with the
144
+ task's name in backticks, alone or as its call (`get_data(code, year)`); several tasks in
145
+ one row are backticked names separated by commas; prose may follow. The tables list
146
+ exactly tasks.__all__. -->
147
+
148
+ | Upstream operation | Task function | MCP tool | Status |
149
+ | --- | --- | --- | --- |
150
+ | ESMIS `esmis_api_release_findByIdentifier` for `wasde`, through xippios-usda-esmis's `list_releases`, pages walked newest first | `list_releases(since=None, until=None)` | `usda_wasde_list_releases` | alpha |
151
+ | ESMIS `esmis_api_release_findByIdentifier` for `wasde`, page 0, through xippios-usda-esmis's `get_latest_release` | `get_latest_release()` | `usda_wasde_get_latest_release` | alpha |
152
+ | the release's XML file, downloaded through xippios-usda-esmis's `download_release_file`, parsed by `parse_wasde_xml` | `get_release(month=None)`, a bulk task | none, Python only | alpha |
153
+ | the XML's pages, their titles, subtitles, footnotes and matrices, packaged from the latest release (`reference/table.json`), no request | `list_tables(search=None)` | `usda_wasde_list_tables` | alpha |
154
+ | the XML's supply-and-use matrices of pages 11 to 30, 32 and 33 with their commodities, on pages 12 to 15 the XLS's block titles, packaged (`reference/commodity.json`), no request | `list_commodities(search=None)` | `usda_wasde_list_commodities` | alpha |
155
+ | the XML's region texts with their pages, packaged (`reference/region.json`), no request | `list_regions(search=None)` | `usda_wasde_list_regions` | alpha |
156
+ | one page of the release's XML, as `get_release` reads it, its values without the page's labels (`list_tables` states them), one download per call | `get_table(table, month=None)` | `usda_wasde_get_table` | alpha |
157
+ | one commodity's supply-and-use matrix of the release's XML, a U.S. or Mexico page or the world pages' rows of one region, matrices from `reference/commodity.json`, its values without the page's labels, one download per call | `get_balance_sheet(commodity, region="United States", month=None)` | `usda_wasde_get_balance_sheet` | alpha |
158
+ | the release's narrative: its XLS's sheet `WASDE Text` read with xlrd, else its PDF's narrative pages read with pypdf, text only | `read_report_text(month=None)` | `usda_wasde_read_report_text` | alpha |
159
+
160
+ ## Upstream terms and attribution
161
+
162
+ Data comes from USDA WAOB World Agricultural Supply and Demand Estimates (https://www.usda.gov/oce/commodity/wasde), on whatever terms upstream
163
+ states for it, if any; this package adds no rights to it. Documentation snapshot and its
164
+ attribution: `docs/upstream/FETCHED.md`.
165
+
166
+ ## Licence
167
+
168
+ Apache-2.0. See [LICENSE](LICENSE).
@@ -0,0 +1,136 @@
1
+ # xippios-usda-wasde
2
+
3
+ Typed Python client, MCP server and FastAPI routes for
4
+ [USDA WAOB World Agricultural Supply and Demand Estimates](https://www.usda.gov/oce/commodity/wasde), part of the
5
+ [xippios SDK family](https://github.com/xippios). Names and semantics follow the
6
+ upstream documentation; every response carries release metadata (source, endpoint,
7
+ retrieved_at, published_at, vintage).
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ uv add xippios-usda-wasde # client only
13
+ uv add "xippios-usda-wasde[mcp]" # + MCP server
14
+ uv add "xippios-usda-wasde[http]" # + FastAPI router
15
+ ```
16
+
17
+ It depends on `xippios-usda-esmis`, installed with it, to list WASDE's releases in ESMIS's
18
+ catalog and to download their files; this package's server serves its own tools only.
19
+
20
+ No API key is needed.
21
+
22
+ ## 30-second example
23
+
24
+ ```python
25
+ from datetime import date
26
+
27
+ from xippios.usda.wasde import (
28
+ get_balance_sheet,
29
+ get_latest_release,
30
+ get_release,
31
+ list_commodities,
32
+ list_releases,
33
+ read_report_text,
34
+ )
35
+
36
+ latest = get_latest_release() # the newest WASDE release in ESMIS
37
+ latest.data.id, latest.data.month # "796099", "2026-10"
38
+ latest.meta.published_at # 2026-10-09 12:00:00: ESMIS's printed time, no zone (ADR-0022)
39
+
40
+ releases = list_releases(since=date(2026, 1, 1)) # bound it: without since, 29 requests
41
+ [release.month for release in releases.data if release.revision] # ["2026-06", "2026-05"]
42
+
43
+ page_12 = list_commodities(search="sr12") # packaged with the package: no request
44
+ [row.commodity for row in page_12.data] # ["FEED GRAINS", "CORN"]: matrix1 and matrix2
45
+
46
+ corn = get_balance_sheet("CORN") # page 12's U.S. corn matrix, read from the latest XML
47
+ corn.meta.endpoint, corn.meta.vintage, len(corn.data) # "wasde1026.xml", "October 2026", 60
48
+ corn.data[0].attribute, corn.data[0].cell_value # "Area Planted", "90.9" (2024/25)
49
+ # its subtitle and footnotes are page 12's in list_tables(search="sr12"), stated once
50
+
51
+ october = get_release("2026-10") # Python only: every value, 6543 records, one download
52
+ narrative = read_report_text("2026-10") # the XLS's sheet WASDE Text, one string a paragraph
53
+ narrative.data[1][:6] # "WHEAT:"
54
+ ```
55
+
56
+ Each record of `get_release` is one value of the release's tables with the labels its
57
+ page prints, as printed (`WasdeXmlCell`): 6543 for October 2026, pages 8 to 37. `unit`
58
+ is what the file states: the subtitle of the world and summary pages (8 to 10, 18 to 30),
59
+ the label of a reliability table for its average, smallest and largest; on the U.S.
60
+ pages it is `None`, since the XML does not say which of its repeated unit rows the page
61
+ shows (the XLS and the TXT print them in place). `list_tables`, `list_commodities` and
62
+ `list_regions` answer from lists packaged with the package, read from the October 2026
63
+ release's files (ESMIS release 796099) by `scripts/refresh_reference.py`
64
+ (`reference/README.md`) and refreshed before each release: its 30 table pages with
65
+ their titles, subtitles and footnotes, the
66
+ 43 supply-and-use matrices of pages 11 to 30, 32 and 33 with their commodities, and its
67
+ 70 region texts, as printed. The XML names none of these matrices' commodities as a
68
+ whole: on pages 12 to 15 they are the XLS's block titles; only page 32's records carry a
69
+ `commodity`, one per row (e.g. `Beef`, `Pork`, `Broiler`, `Turkey`, `Red Meat & Poultry`),
70
+ while the list names its matrix `Meats`, so `list_commodities(search="beef")` answers
71
+ nothing.
72
+
73
+ `get_table` and `get_balance_sheet` answer a slice of `get_release`'s records, a page or
74
+ one commodity's matrix, the world pages' rows of one region, named as the packaged lists
75
+ name them (`"CORN"` is page 12's U.S. corn, `"Corn"` the world corn pages; `"Argentina"`
76
+ matches `" Argentina"`). Their records (`WasdeTableValue`) leave out the page's
77
+ own labels: its subtitle and footnotes, to which a marker such as `Trade 2/` refers, are
78
+ `list_tables`'s, stated once per page with its titles, the page's number line
79
+ (` WASDE - 676 - 12`) is left out, and the report month is `meta.vintage`. So every page
80
+ and balance sheet of October 2026 fits its tool's cap (`get_table` 400 rows or 128 KB,
81
+ `get_balance_sheet` 300 rows or 128 KB), each with a note that says how to see the rest
82
+ should one not. Each call downloads the month's XML and keeps nothing, so a Python
83
+ caller wanting several slices of one month calls `get_release` once.
84
+
85
+ `read_report_text` answers the narrative as text, from the XLS's sheet `WASDE Text`, or
86
+ from the PDF's narrative pages for a release without an XLS or whose XLS has no such
87
+ sheet; no figure is ever read from a PDF. `meta.vintage` is the month the XLS prints, or
88
+ for a PDF, which prints a date, the ESMIS release id. Task functions are listed in the
89
+ status table below.
90
+
91
+ ## MCP
92
+
93
+ ```json
94
+ {
95
+ "mcpServers": {
96
+ "usda-wasde": {
97
+ "command": "uvx",
98
+ "args": ["--from", "xippios-usda-wasde[mcp]", "xippios-usda-wasde-mcp"]
99
+ }
100
+ }
101
+ }
102
+ ```
103
+
104
+ Tools are read-only and named `usda_wasde_<verb>_<noun>`. Results are capped, at
105
+ 200 rows or 64 KB unless a tool has a cap of its own, with a note on how to see the rest.
106
+ `--http` serves streamable HTTP instead of stdio.
107
+
108
+ ## Status
109
+
110
+ <!-- Core's family check (tests/test_family.py) reads this table: keep the "## Status"
111
+ heading and the "Task function" column. Each row's Task function cell starts with the
112
+ task's name in backticks, alone or as its call (`get_data(code, year)`); several tasks in
113
+ one row are backticked names separated by commas; prose may follow. The tables list
114
+ exactly tasks.__all__. -->
115
+
116
+ | Upstream operation | Task function | MCP tool | Status |
117
+ | --- | --- | --- | --- |
118
+ | ESMIS `esmis_api_release_findByIdentifier` for `wasde`, through xippios-usda-esmis's `list_releases`, pages walked newest first | `list_releases(since=None, until=None)` | `usda_wasde_list_releases` | alpha |
119
+ | ESMIS `esmis_api_release_findByIdentifier` for `wasde`, page 0, through xippios-usda-esmis's `get_latest_release` | `get_latest_release()` | `usda_wasde_get_latest_release` | alpha |
120
+ | the release's XML file, downloaded through xippios-usda-esmis's `download_release_file`, parsed by `parse_wasde_xml` | `get_release(month=None)`, a bulk task | none, Python only | alpha |
121
+ | the XML's pages, their titles, subtitles, footnotes and matrices, packaged from the latest release (`reference/table.json`), no request | `list_tables(search=None)` | `usda_wasde_list_tables` | alpha |
122
+ | the XML's supply-and-use matrices of pages 11 to 30, 32 and 33 with their commodities, on pages 12 to 15 the XLS's block titles, packaged (`reference/commodity.json`), no request | `list_commodities(search=None)` | `usda_wasde_list_commodities` | alpha |
123
+ | the XML's region texts with their pages, packaged (`reference/region.json`), no request | `list_regions(search=None)` | `usda_wasde_list_regions` | alpha |
124
+ | one page of the release's XML, as `get_release` reads it, its values without the page's labels (`list_tables` states them), one download per call | `get_table(table, month=None)` | `usda_wasde_get_table` | alpha |
125
+ | one commodity's supply-and-use matrix of the release's XML, a U.S. or Mexico page or the world pages' rows of one region, matrices from `reference/commodity.json`, its values without the page's labels, one download per call | `get_balance_sheet(commodity, region="United States", month=None)` | `usda_wasde_get_balance_sheet` | alpha |
126
+ | the release's narrative: its XLS's sheet `WASDE Text` read with xlrd, else its PDF's narrative pages read with pypdf, text only | `read_report_text(month=None)` | `usda_wasde_read_report_text` | alpha |
127
+
128
+ ## Upstream terms and attribution
129
+
130
+ Data comes from USDA WAOB World Agricultural Supply and Demand Estimates (https://www.usda.gov/oce/commodity/wasde), on whatever terms upstream
131
+ states for it, if any; this package adds no rights to it. Documentation snapshot and its
132
+ attribution: `docs/upstream/FETCHED.md`.
133
+
134
+ ## Licence
135
+
136
+ Apache-2.0. See [LICENSE](LICENSE).