Us Treasury Yield Curve Scraper
Pricing
from $2.99 / 1,000 results
Us Treasury Yield Curve Scraper
US Treasury Yield Curve Scraper is a Python tool designed to extract daily constant-maturity market yields, tenors (1-month to 30-year), and yield spreads from the U.S. Department of the Treasury. It exports structured macroeconomic data into clean CSV or JSON format.
Pricing
from $2.99 / 1,000 results
Rating
0.0
(0)
Developer
real-estate-api
Maintained by CommunityActor stats
0
Bookmarked
2
Total users
1
Monthly active users
2 days ago
Last modified
Categories
Share
US Treasury Yield Curve Scraper — Daily Treasury Par Yield Curve Rates
Overview
US Treasury Yield Curve Scraper collects daily Treasury par yield curve rates published by the U.S. Department of the Treasury. It organizes the available historical rates into structured records, with one row per curve date and columns for standard maturities ranging from one month to 30 years.
Choose yearly CSV collection, monthly XML collection, or both modes to build a historical interest-rate dataset for financial analysis, economic research, yield curve visualization, and model development. Export the results as JSON, CSV, or Excel through the Apify dataset.
Features
- Historical rate collection: Collect published Treasury par yield curve observations by year or month.
- Multiple collection modes: Select yearly CSV, monthly XML, or both.
- Standard maturity columns: Capture available short-term and long-term Treasury yields.
- Date filtering: Keep observations on or after a specified start date.
- Duplicate prevention: Avoid duplicate curve dates within the same collection mode.
- Structured output: Store each observation as a flat dataset row.
- Scheduled updates: Refresh the dataset periodically to capture newly published observations.
- Spreadsheet exports: Download the collected records in JSON, CSV, or Excel format.
Use Cases
- Historical curve archives: Preserve yearly Treasury yield observations for financial modeling.
- Maturity comparisons: Chart 2-year, 10-year, and 30-year yields from one dataset.
- Monthly updates: Collect a specific month when only recent observations are needed.
- Financial research: Export Treasury rates for economic analysis and reporting.
- Model development: Prepare structured interest-rate data for yield curve models and forecasting workflows.
- Scheduled snapshots: Build a growing historical dataset through recurring collection runs.
Input Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
mode | String | csv | Collection mode: csv for yearly files, xml for monthly files, or both for both formats. |
years | Array of integers | [2025] | Calendar years to collect in CSV mode. |
months | Array of strings | ["202501"] | Months to collect in XML mode, formatted as YYYYMM. |
rateType | String | daily_treasury_yield_curve | Identifies the daily par yield curve series. |
startDate | String | Empty | Optional earliest observation date. Accepts YYYY-MM-DD or MM/DD/YYYY. |
maxItems | Integer | 100 | Maximum number of successful rows to save. Hard maximum: 1,000. |
requestDelaySecs | Number | 1 | Minimum delay between requests, in seconds. |
timeoutSecs | Integer | 300 | Maximum run duration. Previously saved rows are retained when the run stops. |
requestTimeoutSecs | Integer | 30 | Maximum wait for an individual response. |
Example Input
1. Collect the 2025 yearly yield curve
{"mode": "csv","years": [2025],"months": ["202501"],"rateType": "daily_treasury_yield_curve","startDate": "","maxItems": 100,"requestDelaySecs": 1,"timeoutSecs": 300,"requestTimeoutSecs": 30}
2. Collect a specific month
{"mode": "xml","years": [],"months": ["202501"],"rateType": "daily_treasury_yield_curve","startDate": "","maxItems": 100,"requestDelaySecs": 1,"timeoutSecs": 300,"requestTimeoutSecs": 30}
3. Collect both yearly and monthly data
{"mode": "both","years": [2024, 2025],"months": ["202501", "202502"],"rateType": "daily_treasury_yield_curve","startDate": "2025-01-01","maxItems": 1000,"requestDelaySecs": 1,"timeoutSecs": 300,"requestTimeoutSecs": 30}
For both mode, yearly files are processed before monthly files. Select the years and months you want to collect to avoid unnecessary requests.
What Data Does This Actor Extract?
Each successful record represents a Treasury yield curve observation for one date. The maturity columns contain rates expressed as percentages, following the source's published field names.
Extracted Data Fields
| Field | Description |
|---|---|
Date | Observation date, generally formatted as MM/DD/YYYY. |
1 Mo | One-month Treasury yield, as a percentage. |
1.5 Month | One-and-a-half-month yield, when available in the source file. |
2 Mo | Two-month Treasury yield, as a percentage. |
3 Mo | Three-month Treasury yield, as a percentage. |
4 Mo | Four-month Treasury yield, as a percentage. |
6 Mo | Six-month Treasury yield, as a percentage. |
1 Yr | One-year Treasury yield, as a percentage. |
2 Yr | Two-year Treasury yield, as a percentage. |
3 Yr | Three-year Treasury yield, as a percentage. |
5 Yr | Five-year Treasury yield, as a percentage. |
7 Yr | Seven-year Treasury yield, as a percentage. |
10 Yr | Ten-year Treasury yield, as a percentage. |
20 Yr | Twenty-year Treasury yield, as a percentage. |
30 Yr | Thirty-year Treasury yield, as a percentage. |
mode | Collection format associated with the row: csv or xml. |
scraped_at | UTC timestamp indicating when the record was saved. |
Available maturity columns may vary by source file and observation period. Some values may be absent when the source does not provide them.
Example Output
{"Date": "12/31/2025","1 Mo": 3.74,"1.5 Month": 3.75,"2 Mo": 3.67,"3 Mo": 3.67,"4 Mo": 3.63,"6 Mo": 3.59,"1 Yr": 3.48,"2 Yr": 3.47,"3 Yr": 3.55,"5 Yr": 3.73,"7 Yr": 3.94,"10 Yr": 4.18,"20 Yr": 4.79,"30 Yr": 4.84,"mode": "csv","scraped_at": "2026-10-12T00:00:00+00:00"}
The values above illustrate the output structure. Actual records depend on the selected period and the Treasury data available at collection time.
Working with Your Dataset
Once collection finishes, open the Apify dataset and select your preferred export format.
- JSON: Suitable for Python data processing, structured storage, and integration into analytical workflows.
- CSV: Useful for Pandas, spreadsheet applications, and statistical analysis.
- Excel: Convenient for reviewing observations, preparing reports, and sharing results.
For example, you can use the Date, 2 Yr, 10 Yr, and 30 Yr columns to create maturity comparison charts or calculate yield spreads. Always check for missing observations before performing calculations.
Important Notes
- The default mode is
csv, with the year set to 2025. - CSV mode collects yearly files; XML mode collects monthly files.
- The
bothmode processes yearly files before monthly files. - The
startDateparameter filters observations to dates on or after the specified date. - The maximum number of saved successful rows is 1,000 per run.
- The default row limit is 100. A yearly file may be downloaded in full even when the configured row limit is small.
- Treasury data files can take several seconds to respond. Longer collection periods may require additional run time.
- Requests are processed sequentially, with a minimum delay between requests.
- Duplicate dates within the same collection mode are skipped.
- Data availability depends on the publication schedule and the records available when the actor runs.
- The maturity columns follow the source's published names; available columns can differ between historical files.
- The actor is intended for collecting published observations, not for predicting future interest rates or providing investment advice.
FAQ
What is the Treasury par yield curve?
It is a series of Treasury yields across different maturities, published for financial analysis and reference. The observations can be used to compare short-term and long-term interest rates.
What is the difference between CSV and XML modes?
CSV mode collects yearly files, while XML mode collects monthly records. The both mode processes the selected yearly files first and then the selected monthly files.
How fresh is the collected data?
The dataset reflects the information published by the Treasury when the collection runs. A scheduled run can help capture new observations as they become available.
Why is collecting a year sometimes slow?
Yearly files can take several seconds to download and process. The actor uses sequential requests and a configurable per-request timeout to accommodate slower responses.
Can I collect only recent observations?
Yes. Set startDate to the earliest date you want to keep and select the appropriate years or months.
Why are some yield values missing?
The available maturity columns and values can vary across source files and observation dates. Missing values should be handled appropriately before analysis.
Can I export the results to Excel?
Yes. The completed dataset can be downloaded as JSON, CSV, or Excel.
Can I use the data for financial models?
The dataset can support historical analysis and model development. Validate the observations, account for missing data, and ensure that your model is appropriate for your intended use.
Disclaimer
This actor is an independent data-collection tool and is not affiliated with, endorsed by, sponsored by, or officially associated with the U.S. Department of the Treasury. The collected information is provided for research and analytical purposes. Users are responsible for assessing the suitability of the data for their intended applications. The dataset is not investment advice or a recommendation to buy or sell financial instruments.
Is Web Scraping Legal?
Collecting information that is already public is generally legal. Scraping is not the same thing as hacking, and there is no single law that bans it. The limits are the usual ones: do not break into accounts, do not take private or confidential data, and be careful with personal data and copyrighted works. A site's terms can also restrict how you access it. Facts such as a public name, price, or rating are not the same thing as republishing someone's article or photo.
This actor collects information from public pages. It does not log in and it does not bypass access controls.
For a longer explanation, see Apify's article Is web scraping legal?.