---
name: usda-fas-gats-api-ingestion
description: "How to get USDA FAS Global Agricultural Trade API data into a pandas DataFrame and Parquet: access, the request, the format, limits, quirks and terms."
---

# Load USDA GATS monthly exports into pandas and Parquet

Source entry: https://signal-lab-jet.vercel.app/datasets/usda-fas-gats-api
Provider: https://apps.fas.usda.gov/opendataweb/home
Checked against the provider's documentation: 2026-11-01

## Access
- Obtain a free api.data.gov key through the FAS portal signup form.
- Set the key in FAS_API_KEY and send it in the API_KEY header.

## Request
```bash
curl 'https://apps.fas.usda.gov/OpenData/api/gats/censusExports/partnerCode/CH/year/2025/month/1' -H "API_KEY: $FAS_API_KEY" -H 'Accept: application/json'
```

## Format
JSON array or XML response of monthly U.S. Census agricultural exports for one partner, year and month, with commodity and unit identifiers and trade measures.

## Load into pandas and Parquet
Needs Python 3 with requests, pandas and pyarrow.
```python
"""USDA GATS monthly U.S. exports -> pandas -> Parquet."""
import os
import requests
import pandas as pd

URL = "https://apps.fas.usda.gov/OpenData/api/gats/censusExports/partnerCode/CH/year/2025/month/1"
headers = {"API_KEY": os.environ["FAS_API_KEY"], "Accept": "application/json"}
r = requests.get(URL, headers=headers, timeout=60)
r.raise_for_status()
df = pd.json_normalize(r.json())
df.to_parquet("usda_fas_gats_ch_2025_01.parquet", index=False)
print(len(df), "GATS export rows", len(df.columns), "columns")
```
Not run: it needs a free API key.

## Limits
- Rate limit: Not stated.
- U.S. Census trade routes select one partner, year and month per call.
- UN Comtrade routes select one reporter and year per call.

## Quirks
- The Swagger example uses partner code CH for China; obtain valid codes from the countries endpoint instead of assuming ISO codes.
- U.S. Census commodities are available at HS10 detail, while the documented UN trade routes use HS6.
- Census data receive annual corrections, and UN data update only after national submissions are standardized.

## Terms and attribution
- Access or use of the FAS API constitutes acceptance of its terms.
- GATS combines U.S. Census Bureau trade data and UN Commodity Trade Statistics data.
- Do not alter or falsely represent content and still claim FAS as the source.
- Terms page: https://apps.fas.usda.gov/opendataweb/home

## Sources
- https://apps.fas.usda.gov/opendatawebV2/main.6da18f8b4fa8a2baed40.js: "Historical U.S. agricultural trade data is available back to 1967."
- https://apps.fas.usda.gov/opendatawebV2/main.6da18f8b4fa8a2baed40.js: "UN trade data is available for nearly 200 countries or areas, dating from the inception of the Harmonized System (HS) of trade codes in 1989 to present."
- https://apps.fas.usda.gov/opendata/swagger/docs/v1: "Census reports data on a monthly basis with corrections applied once a year."

## Help improve this skill
Missing a source, or see something to improve? Call the MCP tool suggest_source or feedback (or POST /api/suggest or /api/feedback). Reviewed ideas: https://signal-lab-jet.vercel.app/agent-suggestions

Information for educational purposes only. Free tiers, limits and licenses belong to the providers and may change; check the provider's own terms before using the data.
