{
  "openapi": "3.0.1",
  "info": {
    "title": "🇺🇸 US Treasury Data Scraper",
    "description": "Extract official US national debt figures, federal outlays, and average interest rates directly from the Treasury API into structured financial rows.",
    "version": "0.1",
    "x-build-id": "ki9cw48SnHzHcz1dQ"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/taroyamada~treasury-fiscal-data-digest/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-taroyamada-treasury-fiscal-data-digest",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/taroyamada~treasury-fiscal-data-digest/runs": {
      "post": {
        "operationId": "runs-sync-taroyamada-treasury-fiscal-data-digest",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/taroyamada~treasury-fiscal-data-digest/run-sync": {
      "post": {
        "operationId": "run-sync-taroyamada-treasury-fiscal-data-digest",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "required": [
          "feeds"
        ],
        "properties": {
          "feeds": {
            "title": "Treasury feeds to monitor (required)",
            "type": "array",
            "description": "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.",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "title": "Feed ID",
                  "type": "string",
                  "description": "Stable identifier used in snapshots and output rows."
                },
                "name": {
                  "title": "Feed name",
                  "type": "string",
                  "description": "Human-readable label for this feed in the digest output."
                },
                "source": {
                  "title": "Feed source",
                  "type": "string",
                  "description": "Treasury Fiscal Data endpoint family to summarize.",
                  "enum": [
                    "debt_to_penny",
                    "avg_interest_rates",
                    "mts_table_1",
                    "record_setting_auction"
                  ]
                },
                "securityTypes": {
                  "title": "Security types",
                  "type": "string",
                  "description": "Comma-separated security type filter. Used mainly by record_setting_auction (Bills, Notes, Bonds, TIPS, FRNs, CMBs) and optionally avg_interest_rates (Marketable, Non-marketable)."
                },
                "securityDescriptions": {
                  "title": "Security descriptions",
                  "type": "string",
                  "description": "Comma-separated security description filter for avg_interest_rates feeds (for example Treasury Bills,Treasury Notes,Treasury Bonds)."
                },
                "securityTerms": {
                  "title": "Security terms",
                  "type": "string",
                  "description": "Comma-separated tenor filter for record_setting_auction feeds (for example 4-Week,13-Week,10-Year,30-Year)."
                },
                "lookbackDays": {
                  "title": "Feed-specific lookback window (days)",
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 730,
                  "description": "Override the global lookbackDays for this individual feed. For record_setting_auction this controls how recent a record-setting date must be to get a recent_record_event signal."
                },
                "maxEvidence": {
                  "title": "Feed-specific evidence cap",
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 50,
                  "description": "Override the global maxEvidencePerFeed for this individual feed."
                }
              }
            }
          },
          "watchTerms": {
            "title": "Watch terms (comma-separated)",
            "type": "string",
            "description": "Keywords to flag in digest evidence titles, summaries, and source dimensions. Use this for terms like deficit, 10-Year, Treasury Bills, or Bonds."
          },
          "lookbackDays": {
            "title": "Global lookback window (days)",
            "minimum": 1,
            "maximum": 730,
            "type": "integer",
            "description": "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.",
            "default": 90
          },
          "maxEvidencePerFeed": {
            "title": "Max evidence rows per feed",
            "minimum": 1,
            "maximum": 50,
            "type": "integer",
            "description": "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.",
            "default": 10
          },
          "delivery": {
            "title": "Delivery mode",
            "enum": [
              "dataset",
              "webhook"
            ],
            "type": "string",
            "description": "dataset stores results in the Apify dataset. webhook posts the digest JSON to webhookUrl.",
            "default": "dataset"
          },
          "webhookUrl": {
            "title": "Webhook URL (required when delivery=webhook)",
            "type": "string",
            "description": "POST target for the digest payload. Leave empty for dataset delivery."
          },
          "datasetMode": {
            "title": "Dataset output mode",
            "enum": [
              "all",
              "action_needed",
              "new_only"
            ],
            "type": "string",
            "description": "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.",
            "default": "all"
          },
          "snapshotKey": {
            "title": "Snapshot key for recurring state",
            "type": "string",
            "description": "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.",
            "default": "treasury-fiscal-data-digest-state"
          },
          "debtToPennyApiUrl": {
            "title": "Debt to the Penny API URL",
            "type": "string",
            "description": "Treasury Fiscal Data endpoint for daily debt totals. No authentication required.",
            "default": "https://api.fiscaldata.treasury.gov/services/api/fiscal_service/v2/accounting/od/debt_to_penny"
          },
          "avgInterestRatesApiUrl": {
            "title": "Average interest rates API URL",
            "type": "string",
            "description": "Treasury Fiscal Data endpoint for monthly average rates across marketable and non-marketable debt.",
            "default": "https://api.fiscaldata.treasury.gov/services/api/fiscal_service/v2/accounting/od/avg_interest_rates"
          },
          "mtsTable1ApiUrl": {
            "title": "Monthly Treasury Statement Table 1 API URL",
            "type": "string",
            "description": "Treasury Fiscal Data endpoint for receipts, outlays, and surplus/deficit summary rows.",
            "default": "https://api.fiscaldata.treasury.gov/services/api/fiscal_service/v1/accounting/mts/mts_table_1"
          },
          "recordSettingAuctionApiUrl": {
            "title": "Record-setting auction API URL",
            "type": "string",
            "description": "Treasury Fiscal Data endpoint for record-setting auction highs and lows by security type and term.",
            "default": "https://api.fiscaldata.treasury.gov/services/api/fiscal_service/v2/accounting/od/record_setting_auction"
          },
          "requestTimeoutSeconds": {
            "title": "HTTP request timeout (seconds)",
            "minimum": 5,
            "maximum": 120,
            "type": "integer",
            "description": "Timeout for each Treasury API or webhook request.",
            "default": 30
          },
          "notifyOnNoNew": {
            "title": "Emit digest even when no changes were found",
            "type": "boolean",
            "description": "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.",
            "default": true
          },
          "dryRun": {
            "title": "Dry run (skip snapshot writes and webhook delivery)",
            "type": "boolean",
            "description": "Validate and fetch without persisting state or posting webhooks. Safe for testing input shapes.",
            "default": false
          },
          "nowIso": {
            "title": "Override current time (ISO string, for testing)",
            "type": "string",
            "description": "Set a fixed ISO timestamp to make runs deterministic against fixture data."
          },
          "debtFixturePath": {
            "title": "Debt fixture file path (testing)",
            "type": "string",
            "description": "Local JSON fixture for offline debt_to_penny tests."
          },
          "ratesFixturePath": {
            "title": "Rates fixture file path (testing)",
            "type": "string",
            "description": "Local JSON fixture for offline avg_interest_rates tests."
          },
          "mtsFixturePath": {
            "title": "MTS fixture file path (testing)",
            "type": "string",
            "description": "Local JSON fixture for offline mts_table_1 tests."
          },
          "auctionFixturePath": {
            "title": "Auction fixture file path (testing)",
            "type": "string",
            "description": "Local JSON fixture for offline record_setting_auction tests."
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}