xippios-usda-nass
Typed Python client, MCP server and FastAPI routes for USDA NASS Quick Stats, part of the xippios SDK family. Names and semantics follow the upstream documentation; every response carries its metadata (source, endpoint, retrieved_at, request).
Scope
Of Quick Stats' API the package wraps the three operations that its documentation lists
(docs/upstream/): api_GET, the published estimates for a set of filters, read as JSON,
get_counts, the count of the same filters, and get_param_values, the values that a
parameter takes, of which the package ships nine lists and refreshes them before each
release. A filter is any column of the column definitions, with any of the documented
operators. A documented choice that a caller cannot make stands here with its public issue:
formatandcallbackofapi_GET: the documentation offers CSV and XML beside JSON, and JSONP by a callback, and the package asks for JSON (https://github.com/xippios/sdk-usda-nass/issues/65).- The Data Set Download files, which the documentation names as the way past 50,000 records beside narrower filters: the package reads no file, and refuses a query over the limit with the filters that narrow it and the split by year that serves a range (https://github.com/xippios/sdk-usda-nass/issues/66).
What the package adds is the count before a query, the check of each filter against the
packaged column table and lists before a request, and a split by year where one call cannot
serve a range. It fixes no filter, ranks nothing and derives no figure for the caller: the
thirteen tasks of 0.3.0 that fixed filters over api_GET left in 0.4.0, and the query of
each stays one get_data call with the same filters.
Install
uv add xippios-usda-nass # client only
uv add "xippios-usda-nass[mcp]" # + MCP server
uv add "xippios-usda-nass[http]" # + FastAPI router
Set NASS_API_KEY in the environment. Nothing is read from files.
30-second example
from xippios.usda.nass import tasks
filters = {
"commodity_desc": "CORN",
"statisticcat_desc": "AREA PLANTED",
"agg_level_desc": "STATE",
"state_alpha": "VA",
"year": 2012,
}
tasks.count_data(filters).data # 2 records would come back from api_GET
records = tasks.get_data(filters).data
records[0].short_desc # 'CORN - ACRES PLANTED'
records[0].value, records[0].value_number # '510,000', Decimal('510000'); JSON: 510000
tasks.list_param_values("sector_desc").data # ['ANIMALS & PRODUCTS', 'CROPS', ...]
get_data counts the records first: zero matches return an empty result, more than
50,000 raise QueryTooLarge with the count and a hint, narrower filters or a split by
year, before anything is fetched. list_param_values lists the values a filter can take,
nine of them packaged and every other fetched live. The client keeps a count and the data for 300 seconds and a list fetched
live for a day, so the same call within that time sends nothing, and a year that Quick
Stats publishes within those 300 seconds reads as none until they pass.
get_data(filters, split_by_year=True) fetches the years one at a time where one call
cannot serve them, when its filters bound the years as year, year__GE with
year__LE, or year__GE alone up to the current UTC year; any other year filter, and a
year__GE or year__LE past the current UTC year, is refused with
InvalidRequestError before a call. Quick Stats keeps one bound on year per query: it
counts year__GE with year__LE as year__GE alone, and drops year__GE beside
year__LT (docs/upstream/OBSERVED.md, "One bound on year a query"), so a two-sided year
range is served only by this split. That form is always split, every year counted before anything is fetched; year
is counted and fetched once, and year__GE alone is counted first and split only over
the limit. One call splits into at most 20 years in Python and over HTTP, and 11 by
default on the MCP server, whose --split-years sets 1 to 20: a longer split raises
InvalidRequestError naming the ceiling, for a two-sided range before any call, for
year__GE alone after its count, while an open range within the limit is fetched whole
however far back it starts. A year counting 0 is passed over: it has no records, or none
published yet, which Quick Stats does not tell apart, so one note of meta.notes names
the years passed over, and meta.vintage stays None, since Quick Stats names no
release. A year over 50,000 on its own still raises QueryTooLarge naming it, and the
records come in year order. A split sums no yearly counts: meta.total stays None for a
two-sided range, which Quick Stats counts as year__GE alone, and keeps upstream's count
of the range for year__GE alone. A split costs up to two keyed calls per year. An answer
of one year without records says in its note that Quick Stats counted none, the count it
also gives a year not yet published.
Each record carries every column of Quick Stats under its upstream name; value stays
the published string and value_number its parsed form. meta.published_at stays
empty: Quick Stats publishes no release time and each row's load_time carries no zone,
so nothing is read into it.
Filters are Quick Stats column names, optionally suffixed with an operator (__GE,
__LE, __LIKE, ...), mapped to values; the columns are listed in
docs/upstream/param_define.md. Quick Stats ignores unknown column names, so the
package checks every key against its column table and raises InvalidRequestError,
naming the closest valid names, before anything is sent; it checks the value of a
packaged parameter (state_alpha, sector_desc, unit_desc, ...) against its packaged
list too and refuses an unknown one with UnknownCode before the call, since Quick Stats
counts no records for it.
MCP
{
"mcpServers": {
"usda-nass": {
"command": "uvx",
"args": ["--from", "xippios-usda-nass[mcp]", "xippios-usda-nass-mcp"],
"env": { "NASS_API_KEY": "..." }
}
}
}
Tools are read-only and named usda_nass_<verb>_<noun>. Results are capped, at
200 rows or 64 KB unless a tool has a cap of its own, with a note on how to see the rest:
usda_nass_list_param_values returns up to 1,000 values, since its lists run longer than
200 (docs/upstream/OBSERVED.md, "The lists' lengths"), and takes
offset, the values already shown, which continues a cut list from the package or the
client's cache without a request. usda_nass_get_data keeps 200 rows or 64 KB, and its
note names the filters that narrow a query; it takes no offset, since a continuation
would send its count and its data again once an answer passes the cache's 8 MiB. --http
serves streamable HTTP instead of stdio. --split-years YEARS, 1 to 20 and 11 by default,
is the most years one usda_nass_get_data call with split_by_year splits into, at most
23 keyed requests in 92 attempts at 11; the setting holds for the whole process.
Status
| Upstream operation | Task function | MCP tool | Status |
|---|---|---|---|
get_counts |
tasks.count_data(filters) |
usda_nass_count_data |
alpha |
api_GET |
tasks.get_data(filters, split_by_year=) |
usda_nass_get_data |
alpha |
get_param_values |
tasks.list_param_values(param) |
usda_nass_list_param_values |
alpha |
0.4.0 serves these three tasks, where 0.3.0 served sixteen, as ## Scope says, and
requires xippios-core 0.5.x (~=0.5.0); 0.3.0 does not work with core 0.5.0. Alpha: the
public surface may change in a minor version before 1.0 (conventions §12); CHANGELOG.md
lists every change.
Upstream terms and attribution
Data comes from USDA NASS Quick Stats (https://quickstats.nass.usda.gov) under its own terms of use;
this package adds no rights to it. Documentation snapshot: docs/upstream/.
The NASS API Terms of Service ask every service that uses the API to display this notice:
This product uses the NASS API but is not endorsed or certified by NASS.
Workflows
ci.yml runs ruff, its format check, mypy, pytest and pre-commit on Python 3.12, 3.13 and
3.14, requires a changelog entry of every pull request but Dependabot's and refuses a
fixture file over 256 KiB that a pull request adds or changes. It runs on every pull request and,
called by publish.yml, once for a release, and its job ci is the check the
organization's ruleset requires. It is handed no secret, and no variable switches it off.
publish.yml is the release train (conventions §12): on a push to main whose
pyproject.toml names a version that has no tag yet and has its section in CHANGELOG.md,
it runs ci.yml, refuses a core pinned to git, tags the merge commit, builds the package
and, once a reviewer of the environment pypi approves the run, publishes it to PyPI by
trusted publishing. Every push to main and a dispatch start it, and a push that brings no
release ends quietly. It is handed no secret: the step that tells a release is handed the
job's token as GH_TOKEN, the tag goes with the job's token and PyPI trusts the workflow
itself. Its job tag holds the one checkout of the repository that keeps its credentials,
since it pushes the tag with the job's token; every other checkout sets
persist-credentials: false (conventions §13). No variable switches it off.
live.yml runs every live test against the upstream with --tb=short --assert=plain, so
its public log holds neither a failing test's arguments nor the values an assertion compared.
It runs every night at 01:51 UTC and on demand, never on a pull request.
Its pytest step alone is handed XIPPIOS_LIVE_TESTS and, each from the secret of the same
name, NASS_API_KEY, so the checkout, setup-uv and uv sync see none.
A variable WORKFLOW_LIVE of off, the repository's over the organization's, switches it off.
conventions.yml calls the organization's review of a pull request against the documents
listed under Documents below, the check conventions / conventions, when a pull request
opens, is pushed to, reopens or is edited, and on a push to main or a dispatch the review
of the range of commits, range / range. It hands the review the organization's
secret of the model's key, by name. A variable WORKFLOW_CONVENTIONS of off, the
repository's over the organization's, switches both off.
adr-index.yml calls the organization's check of the ADR index, adr-index / adr-index,
which runs scripts/adr_index.py --check, when a pull request opens, is pushed to or
reopens. It hands over nothing, and the called workflow reads its switch itself: a variable
WORKFLOW_ADR_INDEX of off, the repository's over the organization's, skips the check.
siblings.yml runs .github/scripts/check-siblings.sh, which installs the wheel beside
every sibling on PyPI under the same provider namespace that shares its core minor and
beside the source packages it depends on, and proves that the namespace levels stay portions
(sdk-core ADR-0006, sdk-core ADR-0021). It runs on every pull request and push to main, a
check the ruleset does not require, in a workflow of its own, since ci.yml is core's file,
which publish.yml calls for a release. It hands the script the job's read-only token as
GITHUB_TOKEN, for the listing of the organization's repositories, since GitHub limits the
calls of a runner without one. A variable WORKFLOW_SIBLINGS of off, the repository's
over the organization's, switches it off.
Documents
- sdk-core: docs/conventions.md — the conventions every xippios source package follows: its layout, names, results, tests and releases.
- sdk-core: docs/adr.md — the index of the family's architecture decisions, which the conventions cite.
- sdk-core: docs/definition-of-done.md — what a change satisfies before its pull request is opened.
- sdk-core: docs/review-checklist.md — what the review of a pull request checks, in order.
- sdk-usda-nass: docs/adr.md — the index of this package's own decisions, generated from the records in
docs/adr/. - sdk-usda-nass: docs/upstream/FETCHED.md — the snapshot of the upstream documentation, the reference for names, parameters and semantics.
- sdk-usda-nass: docs/upstream/OBSERVED.md — what Quick Stats does that its documentation does not state, each note with the probe that showed it.
Licence
Apache-2.0. See LICENSE.
Metadata
Release files for xippios-usda-nass 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xippios_usda_nass-0.4.0.tar.gz | 67.8 kB | With provenance | Details for xippios_usda_nass-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xippios_usda_nass-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for xippios_usda_nass-0.4.0-py3-none-any.whl |
Total release size: 117.7 kB
Release files / xippios_usda_nass-0.4.0.tar.gz
| Download URL | xippios_usda_nass-0.4.0.tar.gz |
|---|---|
| Size | 67.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
76d9c90c65cb164cc9a69647e39ae0ebbd2811df57ccfab64b629db465a752a1
|
|
BLAKE2b-256 checksum How to use checksums |
69b2535da612102aa0d6981ab04b7c0d514c229ca91f3d2baa55f63a480e5554
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.
Transparency logRelease files / xippios_usda_nass-0.4.0-py3-none-any.whl
| Download URL | xippios_usda_nass-0.4.0-py3-none-any.whl |
|---|---|
| Size | 50.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9fdaaa72daf902f73962dc050819857a94389b098f2449cae492b2decdaa4f2f
|
|
BLAKE2b-256 checksum How to use checksums |
3764100379892b798bd8108a2412d701ae29c02bb696ec8b49878d3f614883c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.
Transparency logSecurity for xippios-usda-nass 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for xippios_usda_nass-0.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.