How to Get US 10Y Treasury (DGS10) Prices via API
You need to get the US 10-Year Treasury yield into your app and keep it updated for charts, alerts, and backtesting. By the end of this guide you’ll know how to look up the right symbol for the US 10Y (commonly referenced as DGS10), call the Indices-API latest endpoint, backfill a series, and compute daily fluctuations—all while handling weekends/holidays, caching, and update cadence.
What you’ll build: a DGS10 yield fetcher and change monitor
Our concrete goal is to pull the latest US 10Y yield reading, then prepare for historical backfill and day-over-day change tracking. We’ll use the Latest endpoint in a working example, and cover how you would extend the same logic to time-series and fluctuation data for dashboards, trading tools, or research pipelines.
One important step: confirm the exact symbol code in the API before you ship. While “DGS10” is the common public identifier (for example on FRED), your first task is to verify the symbol on the Indices-API symbols page. If the symbol differs (e.g., a vendor prefix/suffix), use that exact code in your requests.
Find the correct US 10Y symbol first
Before pasting code, verify the supported symbol for the US 10-Year Treasury yield. Do not guess the code in production:
- Open the searchable symbols catalog: Browse the Indices-API Supported Symbols.
- Search for “US 10Y” or “DGS10.” Copy the exact symbol string as provided there.
- If you don’t find DGS10 by that name, use the listed alternative code in all requests below.
Why this matters: attempting to query an unrecognized symbol will return an error. You’ll see that in the live example below.
Latest US 10Y yield: endpoint, request, and response fields
The Latest endpoint returns real-time rates relative to a base currency. By default, Indices-API responses are relative to USD and exposed as fields under rates. For equity indices like GSPC (S&P 500), you’d read rates.USDGSPC. For the US 10Y symbol, you’ll read the same pattern: rates.USD{YOUR_SYMBOL}.
Endpoint:
- GET https://indices-api.com/api/latest
- Query parameters: access_key=YOUR_API_KEY, symbols=YOUR_SYMBOL
Plans update at different cadences (for example every 60 minutes or every 10 minutes, depending on your subscription). If you need higher freshness, plan accordingly.
curl you can paste
curl -G https://indices-api.com/api/latest \
--data-urlencode "access_key=YOUR_API_KEY" \
--data-urlencode "symbols=DGS10"
If the symbol you used is not supported under that literal code, you will receive the following error envelope. This is a real error response; do not assume success until you confirm the symbol on the symbols page.
{"success":false,"error":{"code":400,"type":"invalid_symbol","info":"One or more invalid symbols have been specified."}}
What these fields mean and how you’ll use them:
- success: Boolean indicating whether the request returned data. Check this before parsing rates.
- error.code, error.type, error.info: Diagnostic info to handle symbol issues programmatically. For invalid_symbol, re-check the code on the symbols page and retry.
When success is true, the latest payload includes keys you will use in your app logic:
- timestamp: Unix timestamp for when the rates were calculated.
- date: The ISO date for the snapshot.
- base: The base currency, typically “USD.”
- rates: A mapping from base to instrument. For equities this looks like rates.USDGSPC. For the US 10Y, it will be rates.USD{YOUR_SYMBOL}. The unit is “per index” in general responses; for a yield-like series, consult the symbol’s unit on the symbols page to interpret values correctly.
JavaScript example: fetch latest DGS10 and handle invalid symbols
This snippet requests the latest value, checks success, and then reads the rate from the rates map. Keep rates, base, date, and timestamp handy for chart labels and data lineage.
async function fetchUS10Y() {
const params = new URLSearchParams({
access_key: 'YOUR_API_KEY',
symbols: 'DGS10' // Replace with the exact code from the Symbols page if this fails
});
const url = `https://indices-api.com/api/latest?${params.toString()}`;
const res = await fetch(url);
const data = await res.json();
if (!data.success) {
// Example of the real error you may see if the symbol is wrong:
// {"success":false,"error":{"code":400,"type":"invalid_symbol","info":"One or more invalid symbols have been specified."}}
throw new Error(`${data.error.type}: ${data.error.info}`);
}
const { timestamp, date, base, rates } = data;
// For GSPC you would read rates.USDGSPC. For US 10Y, confirm exact code on the Symbols page.
const symbol = 'DGS10'; // replace if needed
const field = `USD${symbol}`;
const latest = rates[field];
if (typeof latest === 'undefined') {
throw new Error(`Rate field ${field} not found. Check the symbol and documentation.`);
}
return { latest, timestamp, date, base };
}
fetchUS10Y()
.then(({ latest, timestamp, date, base }) => {
console.log('US 10Y latest:', latest);
console.log('As of:', date, 'timestamp:', timestamp, 'base:', base);
})
.catch(err => {
console.error('Failed to fetch US 10Y:', err.message);
});
Tip: if you need deeper parameter coverage or additional examples for historical and fluctuation queries, see the Indices-API Documentation.
Backfill DGS10: using time-series for daily history
Once the symbol is confirmed, your next task is to backfill the series so your charts and factor models don’t start “today at noon.” The time-series endpoint returns daily historical rates between a start_date and an end_date of your choice.
- Choose a date range. The end_date cannot be today; use yesterday to avoid incomplete sessions and to satisfy endpoint constraints.
- Expect gaps for weekends and US market holidays—Treasury yields post on business days. The endpoint will return only available dates.
- Interpretation: the same base/rates pattern applies. Parse base, rates[YYYY-MM-DD].USD{YOUR_SYMBOL}, and carry timestamp/date metadata for reproducibility.
Implementation pattern:
- Request a manageable window (for example 1–3 years) per call if you are building an initial ETL job.
- Cache the fetched range locally (database or flat files) and append updates nightly after the daily close becomes available.
- If your app displays intraday updates, daily time-series should still be appended by date boundaries, not by frequent polls, to avoid partial bars.
Refer to the time-series usage notes in the Documentation for parameters and field layout. Always pass your verified US 10Y symbol.
Alerting and day-over-day monitoring with fluctuation
If you need to detect how the US 10Y moved between two dates (for example, “Did the 10-year jump more than N bps since yesterday?”), the fluctuation endpoint provides start_rate, end_rate, change, and change_pct over a chosen interval. Use this to power alerting and simple analytics without re-implementing comparison logic.
- Pick start_date and end_date. Remember, end_date should not be today.
- Read fields under rates.{YOUR_SYMBOL} in the response object (start_rate, end_rate, change, change_pct).
- For yields, interpret absolute changes in the correct unit (e.g., percentage or decimal). Validate the unit for the instrument on the symbols page before setting alert thresholds.
Because fluctuation aggregates over a date range, it naturally handles weekends and holidays by using the nearest available business days inside your interval. For a detailed parameter list and examples, consult the Documentation.
Practical integration details you don’t want to rediscover
Base currency and how to read quotes
- base is typically USD in Indices-API responses. Interpret values under rates as “per index” with USD as the base. Confirm the unit for the US 10Y symbol on the Symbols page.
- For equities like GSPC, you’d read rates.USDGSPC. For the US 10Y, you’ll read rates.USD{YOUR_SYMBOL} after verifying the correct code.
Update frequency and caching
- Update cadence depends on plan. Latest may refresh every 60 minutes, 10 minutes, or according to your subscription tier.
- Client-side caching: if you’re refreshing a dashboard, cache responses for at least one update interval to avoid rate spikes and jitter.
- Server caching: persist the last good payload with timestamp. If a transient error occurs, display cached data with a stale label instead of a blank chart.
Trading days vs weekends/holidays
- The US 10Y yield reflects US Treasury business days. Weekends and some holidays have no update, so historical series will skip these dates.
- When requesting ranges, set end_date to the most recent business day. Do not set end_date to today.
Error handling and symbol validation
- If you see success=false with type=invalid_symbol, re-check the exact ticker on the symbols page. Do not hardcode public identifiers without verification.
- Build a preflight validator into your ETL: query the symbols catalog once at deploy time and map your app’s semantic names (e.g., “US_10Y”) to the API’s canonical symbol.
From “works on my laptop” to production
Here’s a minimal production-ready flow you can implement quickly:
- Symbol discovery step: resolve “US 10Y” to a supported symbol using the Symbols catalog and persist the mapping in your config.
- Latest fetcher: poll the Latest endpoint at the cadence that matches your plan. Read base, date, timestamp, and rates.USD{SYMBOL}.
- Daily backfill job: after the US session close, call the time-series endpoint from last-known-date+1 to yesterday and append to your store.
- Change monitor: call the fluctuation endpoint for yesterday vs the prior business day. Trigger alerts above your basis-point threshold.
- Caching and observability: store raw JSON, timestamped, for audits; log success=false envelopes and include error.type in alerts for fast triage.
About pricing, trial, and getting your key
You can start with a 7-day trial. The PRO plan is $49.99/month. Get your API key and start shipping in minutes: Register for an Indices-API account.
For an overview of coverage and methodology, see Indices-API MCP. If you’re integrating other indices alongside the US 10Y (e.g., S&P 500, Dow, FTSE 100), browse the Documentation for endpoint guides and response schemas.
Reference links and data context
- Indices-API home: indices-api.com
- US 10-Year Treasury Yield reference (FRED DGS10): FRED: DGS10 series page
- Indices-API docs: Full endpoint documentation
- Symbols search: Find supported symbols
FAQ
How do I confirm the exact US 10Y symbol?
Use the searchable symbols catalog here: Indices-API Supported Symbols. Search for “US 10Y” or “DGS10” and copy the returned symbol string verbatim.
Why did I get invalid_symbol for DGS10?
The API did not recognize that literal symbol. Open the symbols page, find the canonical symbol, and retry the request. The error payload looks like the real example shown above and includes type=invalid_symbol for quick triage.
What fields do I need to chart the latest yield?
Read base, date, timestamp, and the specific rate at rates.USD{YOUR_SYMBOL}. Use timestamp for labeling and caching, and date for daily aggregation.
Why can’t I set end_date to today?
The time-series and fluctuation endpoints operate on completed sessions. Use yesterday (or the most recent business day) as end_date to avoid partial or unavailable data.
How often does latest update?
It depends on your plan (for example, every 60 minutes or every 10 minutes). Implement client/server caching to match your plan’s cadence and avoid unnecessary duplicate requests.
Ready to integrate the US 10Y in minutes? Start your 7-day trial and get your API key now: Register. Then follow the Documentation to wire up latest, time-series, and fluctuation for your DGS10 workflows.