# US Treasury Fiscal Data Scraper — Debt & Spending (`copious_atoll/us-treasury-fiscal-data`) Actor

Extract US Treasury fiscal data including national debt (Debt to the Penny), monthly public debt statements, Treasury spending and revenue, average interest rates on securities, and exchange rates. Free API, no proxy needed.

- **URL**: https://apify.com/copious\_atoll/us-treasury-fiscal-data.md
- **Developed by:** [Grim R](https://apify.com/copious_atoll) (community)
- **Categories:** E-commerce
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## US Treasury Fiscal Data Scraper

Extract official US government fiscal data from the Treasury Fiscal Data API. Get daily national debt figures, monthly public debt statements, government revenue and spending data, average interest rates on Treasury securities, and Treasury exchange rates. All data comes directly from the US Department of the Treasury.

> **Disclaimer:** This actor is unofficial and is not affiliated with, sponsored by, or endorsed by the U.S. Department of the Treasury or FiscalData.Treasury.gov.

### What national debt and fiscal data can you extract?

This actor wraps the free US Treasury Fiscal Data API to extract five key datasets:

- **Debt to the Penny** — daily total US national debt (public debt and intragovernmental holdings)
- **Monthly Statement of Public Debt** — detailed breakdown of marketable and non-marketable Treasury securities outstanding
- **Monthly Treasury Statement** — federal government revenue and spending by category (tax receipts, outlays, surplus/deficit)
- **Average Interest Rates on Treasury Securities** — rates on bills, notes, bonds, TIPS, and floating rate notes
- **Treasury Exchange Rates** — official exchange rates for foreign currencies used by government agencies

All data is sourced from official Treasury reporting systems and updated on the schedules maintained by the Bureau of the Fiscal Service.

### How to query Treasury fiscal data

**Select a dataset:** Choose from the five available datasets using the dropdown selector.

**Filter by date range:** Set start and end dates in YYYY-MM-DD format to narrow results. For example, set Date From to `2024-01-01` to get data from January 2024 onward.

**Control result size:** Use the Max Results parameter (1 to 10,000) to limit the number of records returned. Default is 100.

### Output example

Each record in the output contains the original Treasury API fields plus metadata. Here is an example from the Debt to the Penny dataset:

```json
{
    "record_date": "2025-03-14",
    "tot_pub_debt_out_amt": "36218000000000.00",
    "govt_account_invest_hold_amt": "7200000000000.00",
    "tot_pub_debt_out_amt_held_by_pub": "29018000000000.00",
    "src_line_nbr": "1",
    "record_fiscal_year": "2025",
    "record_fiscal_quarter": "2",
    "record_calendar_year": "2025",
    "record_calendar_quarter": "1",
    "record_calendar_month": "03",
    "record_calendar_day": "14",
    "_dataset": "debt_to_penny",
    "_datasetLabel": "Debt to the Penny",
    "_endpoint": "/v2/accounting/od/debt_to_penny"
}
```

### How much does it cost to scrape Treasury fiscal data?

This actor uses **pay-per-event pricing**. You pay per record returned.

- **$0.00005 per actor start** (Apify default)
- **Per-result charge** based on the number of records extracted
- **No proxy costs** — Treasury Fiscal Data is a free government API with no authentication required

A typical query for daily national debt over one year returns approximately 250 records at minimal cost. Monthly datasets return 12 records per year.

**Tip:** Set the `maxResults` parameter to control costs. Start with 100 results and increase as needed.

### Who uses government spending and national debt data?

- **Finance analysts and economists** — track national debt trends, interest rate changes, and government spending patterns
- **Journalists and media organizations** — report on federal budget, deficit, and debt ceiling developments
- **Academic researchers** — study fiscal policy, monetary economics, and government finance over time
- **Policy analysts** — monitor Treasury activity for think tanks and advocacy organizations
- **Fintech developers** — build dashboards and data products using official Treasury data
- **Data scientists and AI engineers** — train economic models on historical government fiscal data
- **Forex traders** — use Treasury exchange rates and interest rate data to inform currency trading strategies

### Input parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| dataset | string | Which dataset to query: debt\_to\_penny, monthly\_public\_debt, monthly\_treasury\_statement, avg\_interest\_rates, or exchange\_rates |
| dateFrom | string | Start date (YYYY-MM-DD) |
| dateTo | string | End date (YYYY-MM-DD) |
| maxResults | integer | Maximum records to return (1-10000, default 100) |

### Treasury Fiscal Data API details

This actor queries the official API at `https://api.fiscaldata.treasury.gov/services/api/fiscal_service`. The API is free, requires no API key, and has no documented rate limit. This actor throttles requests at 0.2 seconds between calls to be a responsible consumer. Automatic retry with exponential backoff handles any transient failures.

### Integrations

Export your data as JSON, CSV, or Excel. Schedule daily runs to track national debt changes automatically. Use webhooks to trigger downstream workflows when new fiscal data is published.

This actor works as an **MCP server** — AI agents can discover and use it to access Treasury fiscal data programmatically.

# Actor input Schema

## `dataset` (type: `string`):

Select which Treasury fiscal dataset to query. Options: Debt to the Penny (daily national debt), Monthly Public Debt statement, Monthly Treasury Statement (revenue/spending), Average Interest Rates on Treasury securities, or Treasury Exchange Rates.

## `dateFrom` (type: `string`):

Start date for data extraction (YYYY-MM-DD format). Filters records where record\_date >= this value.

## `dateTo` (type: `string`):

End date for data extraction (YYYY-MM-DD format). Filters records where record\_date <= this value. Defaults to today.

## `maxResults` (type: `integer`):

Maximum number of records to return.

## Actor input object example

```json
{
  "dataset": "debt_to_penny",
  "dateFrom": "2024-01-01",
  "maxResults": 100
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "dataset": "debt_to_penny",
    "dateFrom": "2024-01-01",
    "maxResults": 100
};

// Run the Actor and wait for it to finish
const run = await client.actor("copious_atoll/us-treasury-fiscal-data").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "dataset": "debt_to_penny",
    "dateFrom": "2024-01-01",
    "maxResults": 100,
}

# Run the Actor and wait for it to finish
run = client.actor("copious_atoll/us-treasury-fiscal-data").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "dataset": "debt_to_penny",
  "dateFrom": "2024-01-01",
  "maxResults": 100
}' |
apify call copious_atoll/us-treasury-fiscal-data --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=copious_atoll/us-treasury-fiscal-data",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/e8jAA9by8fdnKPcVC/builds/K8lLyP2i0KVJxnLmG/openapi.json
