# US Treasury Data Scraper (`taroyamada/treasury-fiscal-data-digest`) Actor

Extract official US national debt figures, federal outlays, and average interest rates directly from the Treasury API into structured financial rows.

- **URL**: https://apify.com/taroyamada/treasury-fiscal-data-digest.md
- **Developed by:** [naoki anzai](https://apify.com/taroyamada) (community)
- **Categories:** News, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $9.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

## Treasury Fiscal Data Digest | Debt, Rates & Budget Monitor

Build resilient financial data pipelines by extracting official government economic metrics directly from the U.S. Treasury Fiscal Data API. This scraper replaces fragile web scraping scripts and manual checks by connecting directly to the underlying agency feeds. Financial analysts, journalists, and data engineering teams can schedule daily or weekly runs to scrape exact national debt totals, federal budget receipts, and average interest rates without relying on delayed third-party aggregators.

By setting up custom keyword search filters and watchlists, you can filter massive federal datasets to extract only the details your research teams need. Every run returns a clean, summary-first digest row containing precise publication dates, reporting periods, agency identifiers, and numeric totals for debt and outlays.

Whether you are feeding internal compliance dashboards or building public macroeconomic trackers, this tool allows you to automate the extraction of Monthly Treasury Statement data. Seamlessly schedule the scraper to run in the background, ensuring your internal databases always reflect the most current official figures. Export your scraped results easily and integrate reliable federal fiscal data into your broader analytics strategy.

### Store Quickstart

What first success looks like:

### Key Features

- 🏛️ **Government-sourced** — Pulls directly from official agency feeds — no third-party aggregators
- ⏱️ **Timely digests** — Daily/weekly rollups of new filings, rulings, or actions
- 🔍 **Keyword watchlists** — Flag items matching your compliance/legal watch terms
- 📊 **Structured metadata** — Agency, date, docket, document type, link — all dataset-ready
- 📡 **Webhook alerts** — Push to legal/compliance teams the moment new items match watchlist

### Use Cases

| Who | Why |
|-----|-----|
| Developers | Automate recurring data fetches without building custom scrapers |
| Data teams | Pipe structured output into analytics warehouses |
| Ops teams | Monitor changes via webhook alerts |
| Product managers | Track competitor/market signals without engineering time |

### Input

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| feeds | array | **required** | One entry per watch target. Each feed produces one summary digest row. Use debt\_to\_penny for headline debt, avg\_interest |
| watchTerms | string | — | Keywords to flag in digest evidence titles, summaries, and source dimensions. Use this for terms like deficit, 10-Year,  |
| lookbackDays | integer | `90` | Used to fetch enough history for comparisons and to determine recency for record-setting auction dates. 90 works well fo |
| maxEvidencePerFeed | integer | `10` | Upper bound on nested evidence rows per feed digest. Keep it low for summary-first output; raise it only when you intent |
| delivery | string | `"dataset"` | dataset stores results in the Apify dataset. webhook posts the digest JSON to webhookUrl. |
| webhookUrl | string | — | POST target for the digest payload. Leave empty for dataset delivery. |
| datasetMode | string | `"all"` | all emits every feed digest row. action\_needed emits only feeds with critical signals or watch-term hits. new\_only emits |
| snapshotKey | string | `"treasury-fiscal-data-digest-state"` | Stable key used to persist seen evidence hashes across recurring runs so changedSinceLastRun and new\_only mode stay comp |

#### Input Example

```json
{
  "feeds": [
    {
      "id": "debt-daily",
      "name": "Debt to the Penny",
      "source": "debt_to_penny"
    },
    {
      "id": "marketable-rates",
      "name": "Marketable Treasury Rates",
      "source": "avg_interest_rates",
      "securityDescriptions": "Treasury Bills,Treasury Notes,Treasury Bonds"
    },
    {
      "id": "monthly-budget",
      "name": "MTS Receipts & Outlays",
      "source": "mts_table_1"
    },
    {
      "id": "record-auctions",
      "name": "Recent Record-Setting Auctions",
      "source": "record_setting_auction",
      "securityTypes": "Bills,Notes",
      "lookbackDays": 180
    }
  ],
  "watchTerms": "deficit,10-Year,Treasury Bills",
  "lookbackDays": 180,
  "maxEvidencePerFeed": 5,
  "delivery": "dataset",
  "datasetMode": "all",
  "snapshotKey": "treasury-fiscal-data-digest-quickstart",
  "notifyOnNoNew": true,
  "dryRun": false
}
```

### Input Examples

#### Example: Single-target audit

```json
{
  "targets": [
    "example-target-1"
  ],
  "maxResultsPerTarget": 30
}
```

#### Example: Bulk portfolio

```json
{
  "targets": [
    "target-1",
    "target-2",
    "target-3"
  ],
  "maxResultsPerTarget": 50,
  "snapshotKey": "treasury-fiscal-data-digest-state"
}
```

#### Example: Recurring delta watch

```json
{
  "targets": [
    "target-1"
  ],
  "snapshotKey": "treasury-fiscal-data-digest-state",
  "emitChangedOnly": true
}
```

### Output

| Field | Type | Description |
|-------|------|-------------|
| `meta` | object |  |
| `errors` | array |  |
| `digests` | array |  |
| `digests[].feedId` | string |  |
| `digests[].feedName` | string |  |
| `digests[].source` | string |  |
| `digests[].checkedAt` | timestamp |  |
| `digests[].latestRecordDate` | timestamp |  |
| `digests[].status` | string |  |
| `digests[].changedSinceLastRun` | boolean |  |
| `digests[].newEvidenceCount` | number |  |
| `digests[].totalEvidenceCount` | number |  |
| `digests[].actionNeeded` | boolean |  |
| `digests[].headline` | string |  |
| `digests[].recommendedAction` | string |  |
| `digests[].signalTags` | array |  |
| `digests[].watchTermHits` | array |  |
| `digests[].summaryMetrics` | object |  |
| `digests[].evidence` | array |  |
| `digests[].error` | null |  |

#### Output Example

```json
{
  "meta": {
    "feedCount": 4,
    "totalEvidenceRows": 8,
    "actionNeededCount": 3,
    "executiveSummary": {
      "overallStatus": "action_needed",
      "brief": "3 feed(s) require review; 4 changed since the last run."
    }
  },
  "digests": [
    {
      "feedId": "monthly-budget",
      "status": "action_needed",
      "headline": "February MTS: $307.5B deficit; FYTD $1T deficit.",
      "recommendedAction": "Review the widening monthly deficit and update receipts/outlays commentary.",
      "changedSinceLastRun": true,
      "evidence": [
        {
          "title": "Current-month receipts vs outlays (February)",
          "primaryValue": 307501433426.17,
          "unit": "USD"
        }
      ]
    }
  ]
}
```

### API Usage

Run this actor programmatically using the Apify API. Replace `YOUR_API_TOKEN` with your token from [Apify Console → Settings → Integrations](https://console.apify.com/account/integrations).

#### cURL

```bash
curl -X POST "https://api.apify.com/v2/acts/taroyamada~treasury-fiscal-data-digest/run-sync-get-dataset-items?token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "feeds": [ { "id": "debt-daily", "name": "Debt to the Penny", "source": "debt_to_penny" }, { "id": "marketable-rates", "name": "Marketable Treasury Rates", "source": "avg_interest_rates", "securityDescriptions": "Treasury Bills,Treasury Notes,Treasury Bonds" }, { "id": "monthly-budget", "name": "MTS Receipts & Outlays", "source": "mts_table_1" }, { "id": "record-auctions", "name": "Recent Record-Setting Auctions", "source": "record_setting_auction", "securityTypes": "Bills,Notes", "lookbackDays": 180 } ], "watchTerms": "deficit,10-Year,Treasury Bills", "lookbackDays": 180, "maxEvidencePerFeed": 5, "delivery": "dataset", "datasetMode": "all", "snapshotKey": "treasury-fiscal-data-digest-quickstart", "notifyOnNoNew": true, "dryRun": false }'
```

#### Python

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_API_TOKEN")
run = client.actor("taroyamada/treasury-fiscal-data-digest").call(run_input={
  "feeds": [
    {
      "id": "debt-daily",
      "name": "Debt to the Penny",
      "source": "debt_to_penny"
    },
    {
      "id": "marketable-rates",
      "name": "Marketable Treasury Rates",
      "source": "avg_interest_rates",
      "securityDescriptions": "Treasury Bills,Treasury Notes,Treasury Bonds"
    },
    {
      "id": "monthly-budget",
      "name": "MTS Receipts & Outlays",
      "source": "mts_table_1"
    },
    {
      "id": "record-auctions",
      "name": "Recent Record-Setting Auctions",
      "source": "record_setting_auction",
      "securityTypes": "Bills,Notes",
      "lookbackDays": 180
    }
  ],
  "watchTerms": "deficit,10-Year,Treasury Bills",
  "lookbackDays": 180,
  "maxEvidencePerFeed": 5,
  "delivery": "dataset",
  "datasetMode": "all",
  "snapshotKey": "treasury-fiscal-data-digest-quickstart",
  "notifyOnNoNew": true,
  "dryRun": false
})

for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)
```

#### JavaScript / Node.js

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

const client = new ApifyClient({ token: 'YOUR_API_TOKEN' });
const run = await client.actor('taroyamada/treasury-fiscal-data-digest').call({
  "feeds": [
    {
      "id": "debt-daily",
      "name": "Debt to the Penny",
      "source": "debt_to_penny"
    },
    {
      "id": "marketable-rates",
      "name": "Marketable Treasury Rates",
      "source": "avg_interest_rates",
      "securityDescriptions": "Treasury Bills,Treasury Notes,Treasury Bonds"
    },
    {
      "id": "monthly-budget",
      "name": "MTS Receipts & Outlays",
      "source": "mts_table_1"
    },
    {
      "id": "record-auctions",
      "name": "Recent Record-Setting Auctions",
      "source": "record_setting_auction",
      "securityTypes": "Bills,Notes",
      "lookbackDays": 180
    }
  ],
  "watchTerms": "deficit,10-Year,Treasury Bills",
  "lookbackDays": 180,
  "maxEvidencePerFeed": 5,
  "delivery": "dataset",
  "datasetMode": "all",
  "snapshotKey": "treasury-fiscal-data-digest-quickstart",
  "notifyOnNoNew": true,
  "dryRun": false
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

### Tips & Limitations

- Run daily for active watchlists; weekly for passive monitoring.
- Webhook delivery works well for compliance team Slack channels — include docket URL for 1-click access.
- Use `watchKeywords` generously — false positives are cheap to triage, false negatives miss filings.
- Pair with `regulatory-change-monitor` for cross-agency coverage.
- Archive Dataset rows weekly for long-term compliance evidence retention.

### FAQ

**How far back does history go?**

This actor monitors forward-only — new items since first run. For historical data, use the agency's own search tool.

**What timezones are used?**

All timestamps are UTC. Use your downstream pipeline to convert to agency-local time if needed.

**Does it translate non-English content?**

No — original language is preserved. Use downstream translation services if needed.

**Is the data official?**

Yes — sourced directly from official government websites and feeds. Not a third-party aggregator.

**Can I use this for legal research?**

For alerting and monitoring, yes. For litigation research, cross-verify with primary sources (agency websites) — this actor is a monitoring tool, not a legal database.

### Related Actors

Government & Regulatory cluster — explore related Apify tools:

- [EPA Enforcement Digest | ECHO Compliance Risk Monitor](https://apify.com/taroyamada/epa-enforcement-digest) — Monitor EPA ECHO all-media facility search, corporate compliance screener, and enforcement case feeds with one summary-first digest row per watched company, facility, or case feed.
- [FDA Warning Letters Digest | Summary-First Feed](https://apify.com/taroyamada/fda-warning-letter-digest) — Monitor public FDA warning letters with one summary-first digest row per configured feed.
- [Federal Register Digest | Agency Rule & Notice Monitor](https://apify.com/taroyamada/federal-register-digest) — Monitor Federal Register documents — rules, proposed rules, and notices — per configured agency feed.
- [Government Contract Award Monitor | Award & Competitor Watch](https://apify.com/taroyamada/government-contract-award-monitor) — Monitor public-sector contract award notices for new wins, notable awardees, incumbent recompetes, and competitor signals — one digest row per configured feed without brittle broad crawling.
- [Grants.gov Funding Digest | Opportunity Watch & Signal Digest](https://apify.com/taroyamada/grants-gov-funding-digest) — Monitor Grants.
- [NHTSA Vehicle Recall Digest | Recalls + Complaints Watch](https://apify.com/taroyamada/nhtsa-vehicle-recall-digest) — Monitor official NHTSA vehicle recall and complaint endpoints for watched model-family, VIN, and manufacturer feeds.
- [Product Safety Recall Digest | CPSC + openFDA Alerts](https://apify.com/taroyamada/product-safety-recall-digest) — Monitor CPSC saferproducts.
- [Regulatory Change Monitor API](https://apify.com/taroyamada/regulatory-change-monitor) — Monitor official regulator update feeds, government bulletin pages, and public compliance notices with one action-oriented digest row per monitored source.
- [OFAC Sanctions Change Digest | SDN List Monitor](https://apify.com/taroyamada/sanctions-change-digest) — Monitor the OFAC SDN (Specially Designated Nationals) sanctions list for additions and removals.
- [Tariff Trade Change Digest | Federal Register + HTS Monitor](https://apify.com/taroyamada/tariff-trade-change-digest) — Monitor U.
- [USPTO Patent Monitor API | JSON + Webhook](https://apify.com/taroyamada/uspto-patent-scraper) — Search and monitor US patent filings with multi-source fallback.
- [Campaign Finance & Lobbying Digest | FEC + LDA Watch](https://apify.com/taroyamada/campaign-finance-lobbying-digest) — Monitor official FEC OpenFEC committee reports and LDA.

### Cost

**Pay Per Event**:

- `actor-start`: $0.01 (flat fee per run)
- `dataset-item`: $0.003 per output item

**Example**: 1,000 items = $0.01 + (1,000 × $0.003) = **$3.01**

No subscription required — you only pay for what you use.

### ⭐ Was this helpful?

If this actor saved you time, please [**leave a ★ rating**](https://apify.com/taroyamada/treasury-fiscal-data-digest/reviews) on Apify Store. It takes 10 seconds, helps other developers discover it, and keeps updates free.

Bug report or feature request? Open an issue on the [Issues tab](https://apify.com/taroyamada/treasury-fiscal-data-digest/issues) of this actor.

# Actor input Schema

## `feeds` (type: `array`):

One entry per watch target. Each feed produces one summary digest row. Use debt\_to\_penny for headline debt, avg\_interest\_rates for monthly rates, mts\_table\_1 for receipts/outlays, and record\_setting\_auction for auction record watches.

## `watchTerms` (type: `string`):

Keywords to flag in digest evidence titles, summaries, and source dimensions. Use this for terms like deficit, 10-Year, Treasury Bills, or Bonds.

## `lookbackDays` (type: `integer`):

Used to fetch enough history for comparisons and to determine recency for record-setting auction dates. 90 works well for recurring runs; 365 is broader for discovery.

## `maxEvidencePerFeed` (type: `integer`):

Upper bound on nested evidence rows per feed digest. Keep it low for summary-first output; raise it only when you intentionally want a broader panel of securities or auction terms.

## `delivery` (type: `string`):

dataset stores results in the Apify dataset. webhook posts the digest JSON to webhookUrl.

## `webhookUrl` (type: `string`):

POST target for the digest payload. Leave empty for dataset delivery.

## `datasetMode` (type: `string`):

all emits every feed digest row. action\_needed emits only feeds with critical signals or watch-term hits. new\_only emits only feeds whose evidence changed since the prior run.

## `snapshotKey` (type: `string`):

Stable key used to persist seen evidence hashes across recurring runs so changedSinceLastRun and new\_only mode stay comparable. Use the same key across scheduled runs.

## `debtToPennyApiUrl` (type: `string`):

Treasury Fiscal Data endpoint for daily debt totals. No authentication required.

## `avgInterestRatesApiUrl` (type: `string`):

Treasury Fiscal Data endpoint for monthly average rates across marketable and non-marketable debt.

## `mtsTable1ApiUrl` (type: `string`):

Treasury Fiscal Data endpoint for receipts, outlays, and surplus/deficit summary rows.

## `recordSettingAuctionApiUrl` (type: `string`):

Treasury Fiscal Data endpoint for record-setting auction highs and lows by security type and term.

## `requestTimeoutSeconds` (type: `integer`):

Timeout for each Treasury API or webhook request.

## `notifyOnNoNew` (type: `boolean`):

When true, every feed always produces a digest row even if no new evidence was detected. When false, stable feeds are omitted from all mode output.

## `dryRun` (type: `boolean`):

Validate and fetch without persisting state or posting webhooks. Safe for testing input shapes.

## `nowIso` (type: `string`):

Set a fixed ISO timestamp to make runs deterministic against fixture data.

## `debtFixturePath` (type: `string`):

Local JSON fixture for offline debt\_to\_penny tests.

## `ratesFixturePath` (type: `string`):

Local JSON fixture for offline avg\_interest\_rates tests.

## `mtsFixturePath` (type: `string`):

Local JSON fixture for offline mts\_table\_1 tests.

## `auctionFixturePath` (type: `string`):

Local JSON fixture for offline record\_setting\_auction tests.

## Actor input object example

```json
{
  "feeds": [
    {
      "id": "debt-daily",
      "name": "Debt to the Penny",
      "source": "debt_to_penny"
    }
  ],
  "lookbackDays": 90,
  "maxEvidencePerFeed": 10,
  "delivery": "dataset",
  "datasetMode": "all",
  "snapshotKey": "treasury-fiscal-data-digest-state",
  "debtToPennyApiUrl": "https://api.fiscaldata.treasury.gov/services/api/fiscal_service/v2/accounting/od/debt_to_penny",
  "avgInterestRatesApiUrl": "https://api.fiscaldata.treasury.gov/services/api/fiscal_service/v2/accounting/od/avg_interest_rates",
  "mtsTable1ApiUrl": "https://api.fiscaldata.treasury.gov/services/api/fiscal_service/v1/accounting/mts/mts_table_1",
  "recordSettingAuctionApiUrl": "https://api.fiscaldata.treasury.gov/services/api/fiscal_service/v2/accounting/od/record_setting_auction",
  "requestTimeoutSeconds": 30,
  "notifyOnNoNew": true,
  "dryRun": false
}
```

# 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 = {
    "feeds": [
        {
            "id": "debt-daily",
            "name": "Debt to the Penny",
            "source": "debt_to_penny"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("taroyamada/treasury-fiscal-data-digest").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 = { "feeds": [{
            "id": "debt-daily",
            "name": "Debt to the Penny",
            "source": "debt_to_penny",
        }] }

# Run the Actor and wait for it to finish
run = client.actor("taroyamada/treasury-fiscal-data-digest").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 '{
  "feeds": [
    {
      "id": "debt-daily",
      "name": "Debt to the Penny",
      "source": "debt_to_penny"
    }
  ]
}' |
apify call taroyamada/treasury-fiscal-data-digest --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

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