---
name: us-treasury-fiscal-data-ingestion
description: "How to get U.S. Treasury Fiscal Data API data into a pandas DataFrame and Parquet: access, the request, the format, limits, quirks and terms."
---

# Load U.S. Treasury Fiscal Data into pandas and Parquet

Source entry: https://signal-lab-jet.vercel.app/datasets/us-treasury-fiscal-data
Provider: https://fiscaldata.treasury.gov/api-documentation/
Checked against the provider's documentation: 2026-10-29

## Access
- No account, registration or API key.

## Request
```bash
curl 'https://api.fiscaldata.treasury.gov/services/api/fiscal_service/v2/accounting/od/debt_to_penny?fields=record_date,tot_pub_debt_out_amt&sort=-record_date&page%5Bsize%5D=5'
```

## Format
JSON: a data array of rows plus meta (count, labels, dataTypes, total-count, total-pages) and links. Numbers and dates arrive as strings.

## Load into pandas and Parquet
Needs Python 3 with requests, pandas and pyarrow.
```python
"""Debt to the Penny (U.S. Treasury Fiscal Data API) -> pandas -> Parquet. No key."""
import requests
import pandas as pd

URL = "https://api.fiscaldata.treasury.gov/services/api/fiscal_service/v2/accounting/od/debt_to_penny"
params = {"fields": "record_date,tot_pub_debt_out_amt", "filter": "record_date:gte:2020-01-01",
          "sort": "record_date", "page[size]": 500, "page[number]": 1}
rows = []
while True:
    r = requests.get(URL, params=params, timeout=30)
    r.raise_for_status()
    body = r.json()
    rows += body["data"]
    if params["page[number]"] >= body["meta"]["total-pages"]:
        break
    params["page[number]"] += 1

df = pd.DataFrame(rows)
df["record_date"] = pd.to_datetime(df["record_date"])
df["tot_pub_debt_out_amt"] = pd.to_numeric(df["tot_pub_debt_out_amt"])  # values arrive as strings
df.to_parquet("us_treasury_debt_to_penny.parquet", index=False)
print(len(df), "rows", df["record_date"].min().date(), "to", df["record_date"].max().date())
```
Run by us on 2026-10-29 (python 3.13.5 | pandas 3.1.0 | pyarrow 26.0.0 | requests 2.34.2). Result: 1,714 daily rows, 2020-01-02 to 2026-10-28.

## Limits
- Rate limit: Not stated.
- Pages default to 100 rows (page[size]); the snippet asks for 500 and follows meta total-pages.

## Quirks
- Values are strings (for example "40551054852362.41"); convert with pd.to_numeric.
- Debt to the Penny is posted at the end of each business day with the previous business day's data, so there are no weekend or holiday rows.
- Each dataset has its own endpoint path and field names, listed in the API documentation.

## Terms and attribution
- Treasury states the data is free "without restriction" for non-commercial or commercial use. No attribution requirement is stated.
- Terms page: https://fiscaldata.treasury.gov/api-documentation/

## Sources
- https://fiscaldata.treasury.gov/api-documentation/: "Our API is open, meaning that it does not require a user account or registration for a token."
- https://fiscaldata.treasury.gov/api-documentation/: "The data is offered free, without restriction, and available to copy, adapt, redistribute, or otherwise use for non-commercial or commercial purposes."
- https://fiscaldata.treasury.gov/datasets/debt-to-the-penny/: "Debt to the Penny is updated at the end of each business day with data from the previous business day."

## 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.
