US Public Debt & Treasury Interest Rate History avatar

US Public Debt & Treasury Interest Rate History

Pricing

$0.50 / 1,000 datapoints

Go to Apify Store
US Public Debt & Treasury Interest Rate History

US Public Debt & Treasury Interest Rate History

US Treasury Fiscal Data scraper for Debt to the Penny and Average Interest Rates. Filter dates and export accounting series as JSON with exact debt amounts, units and source links.

Pricing

$0.50 / 1,000 datapoints

Rating

0.0

(0)

Developer

Grit

Grit

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

a day ago

Last modified

Categories

Share

Retrieve dated US public-debt totals and average Treasury security interest rates from the official Fiscal Data API, with exact debt amounts, units and source links.

Choose Debt to the Penny or Average Interest Rates, filter by date, sort the records and page through history. This actor is for Treasury accounting series. usaspending-awards concerns award recipients; world-bank-indicators concerns World Bank indicators. This actor returns neither of those, and does not collect exchange rates, recipient records or individual records.

Official sources

The API host is https://api.fiscaldata.treasury.gov/services/api/fiscal_service. These are the two supported endpoints; there is no custom URL or endpoint input. No source API key is required.

What it returns

Each successful row represents one dated debt observation or one dated security-category rate. Dataset rows are available through the Actor's Results link and can be exported with Apify's dataset tools.

FieldTypeMeaning
statusstringok or error
datasetstringdebt_to_penny or avg_interest_rates
recordDatestringTreasury's observation date, YYYY-MM-DD
totalPublicDebtstringTotal public debt outstanding, exact USD decimal; debt rows
debtHeldByPublicstringDebt held by the public, exact USD decimal; debt rows
intragovernmentalHoldingsstringIntragovernmental holdings, exact USD decimal; debt rows
averageInterestRatenumberReported percentage, such as 7.577; rate rows
securityTypestringTreasury security type, such as Non-marketable; rate rows
securityDescriptionstringTreasury security category, such as Domestic Series; rate rows
unitsstringUSD for debt or percent for rates
sourceEndpointstringFull official endpoint URL
sourceUrlstringOfficial request URL including filters, sort and pagination
retrievedAtstringUTC retrieval timestamp
errorCodestringError rows: invalid_record, request_failed or invalid_response
errorstringError detail, without an untrusted response body
pageNumberintegerError rows: API page containing the failure

Debt amounts stay as decimal strings to preserve cents for these large totals. Rate numbers are percentages: 7.577 means 7.577%, not a fractional value of 0.07577. Fields for the other series are absent. Error rows can omit recordDate and value fields.

Input examples

The exact prefilled input is:

{"dataset":"debt_to_penny","sort":"-record_date","maxItems":5}

It requests page[size]=5 and starts at page one. An empty input object uses these defaults.

Historical category rates:

{
"dataset": "avg_interest_rates",
"startDate": "2026-01-01",
"endDate": "2026-08-31",
"securityType": "Marketable",
"securityDescription": "Treasury Bills",
"sort": "record_date",
"pageSize": 5,
"pageNumber": 1,
"maxItems": 20
}
InputDefaultBehavior
datasetdebt_to_pennySelects one supported Treasury series
startDate, endDateNo boundsInclusive record_date filters; optional YYYY-MM-DD dates
sort-record_dateAPI fields separated by commas; - means descending
maxItems5Maximum dataset rows in this run, including errors; integer 1–100,000
pageSize5API rows per page; integer 1–1,000, capped to maxItems once
pageNumber1One-based starting page after filters and sort; integer 1–1,000,000
securityTypeNo filterExact security_type_desc, rates only
securityDescriptionNo filterExact security_desc, rates only

Sort fields: record_date for either series; debt also permits tot_pub_debt_out_amt, debt_held_public_amt and intragov_hold_amt; rates also permit security_desc, security_type_desc and avg_interest_rate_amt. Date and security fields are appended as stable tie-breaks when absent. Page size stays fixed across pages, including the final page. To continue a paginated export, keep the same filters, sort and effective page size. Category filters are exact source labels and apply only to the rates dataset.

Real output examples

This debt row was produced by the local prefill run on 2026-10-06. The complete five-row output is in sample_output.json.

{
"dataset": "debt_to_penny",
"sourceEndpoint": "https://api.fiscaldata.treasury.gov/services/api/fiscal_service/v2/accounting/od/debt_to_penny",
"sourceUrl": "https://api.fiscaldata.treasury.gov/services/api/fiscal_service/v2/accounting/od/debt_to_penny?sort=-record_date&page%5Bsize%5D=5&page%5Bnumber%5D=1",
"retrievedAt": "2026-10-06T08:30:33.306907+00:00",
"units": "USD",
"status": "ok",
"recordDate": "2026-10-02",
"totalPublicDebt": "40242446619209.33",
"debtHeldByPublic": "32428913787327.44",
"intragovernmentalHoldings": "7813532831881.89"
}

The separate local rates run produced this observation (selected fields; full row in evidence/behavior-results.json):

{
"dataset": "avg_interest_rates",
"status": "ok",
"recordDate": "2026-08-31",
"securityType": "Non-marketable",
"securityDescription": "Domestic Series",
"averageInterestRate": 7.577,
"units": "percent"
}

Pricing

Proposed event: datapoint at 0.0005 USD per successful saved observation (0.50 USD for 1,000 custom events). Error rows and empty results do not trigger this event. The SDK spending limit stops further results when the custom event budget is exhausted. Platform costs depend on the published pricing configuration.

The observed comparable Store leader, fortuitous_pirate/treasury-fiscal-scraper, lists 0.00365 USD per result plus a 0.05 USD startup event in the 2026-10-06 API snapshot. It is tied for most total users and leads those ties by total runs. See PRICING.md for the ranking, other prices, exact event proposal and receipts. Pricing is a proposal until the owner activates monetization.

Limits and errors

Requests run serially, with one connection. Each request has a 30-second timeout and up to three attempts for network failures, HTTP 429 and server errors, using bounded backoff. Other HTTP failures return a source-linked error row. A malformed observation becomes an uncharged error row while subsequent records continue; a failed page returns an error row and stops that series. An empty date range produces no rows. Invalid inputs fail with a clear message before requesting data.

Output reflects records available from Treasury at run time. Publication delays and source revisions can change the latest available date or historical values. Average interest rates are Treasury accounting category averages, not daily market yield curves. No currency conversion, award-recipient enrichment or individual-level records are provided.

Use with AI agents / MCP

An AI agent can invoke the published Actor through Apify's MCP server or Actor API, pass the JSON input above, then read the dataset through the Results link. Give the agent the two allowed dataset values, a date range and a small maxItems cap. Preserve recordDate, units, sourceEndpoint and sourceUrl in any answer so the observation can be checked. This repository supplies an Actor; it does not run a separate MCP server.

FAQ

Why are debt amounts strings? The values are large; keeping the decimal text avoids losing cents through floating-point conversion. Use a decimal-aware tool when calculating with them.

Why can several rows have the same date? The rates series has one observation per Treasury security category on a record date. Stable category sorting makes pagination predictable.

Why is the latest rate older than today's date? The actor returns Treasury's published record_date, not a fabricated current observation. Check the source link and retrieval timestamp.

Can I fetch exchange rates or spending recipients? The supported sources are limited to Debt to the Penny and Average Interest Rates. There is no recipient, individual, exchange-rate or custom endpoint option.

Are local runs charged? The local SDK ignores charging without an active pay-per-event model. Configure the datapoint event before publishing. Actual paid billing and cloud execution have not been tested here.

Local development and verification

Dependencies are listed in requirements.txt. The designated project environment already contains them; no packages were installed into it.

From the actor directory in PowerShell, place the desired input in storage/key_value_stores/default/INPUT.json, then run:

$env:APIFY_LOCAL_STORAGE_DIR = "$PWD/storage"
& C:/GritWork/earn/.venv/Scripts/python.exe -m src
& C:/GritWork/earn/.venv/Scripts/python.exe -m pytest -q -p no:cacheprovider
apify validate-schema

Tests include real-response fixtures and @pytest.mark.live smoke tests for both endpoints. Recorded result: 37 passed in 2.87s on 2026-10-06 (evidence/tests-final.log). The prefill saved 5 rows; a fresh repeat took 2.3561 seconds locally (evidence/behavior-results.json). These are local observations, not performance guarantees.

Input and dataset schemas passed apify validate-schema in this actor directory. Apify CLI 1.10.0 does not discover the required outputSchema key; the same output file also passed the CLI through the compatibility descriptor in evidence/schema-validation. No Docker build, cloud run or publication was performed.