NIFTY SERV SECTOR (NSERV) OHLC API — Intraday and daily endpoints for price retrieval
You need to chart the NIFTY Services Sector index (NSERV), backfill daily candles, and trigger alerts on intraday highs/lows. By the end of this guide you’ll pull the latest NSERV quote, understand how to request OHLC and intraday data, and wire the response into your charting or analytics pipeline without guessing fields or units.
What you will build: latest price, intraday candles, and daily OHLC for NSERV
This walkthrough focuses on three endpoints relevant to the NIFTY Services Sector index:
- Latest: to get the most recent NSERV print and the USD-per-index cross for dashboards and alerts.
- OHLC: to retrieve open, high, low, and close for a date (daily bars).
- Intraday: to fetch interval-based candles for the trading session (for 1–60 minute charts and alerting).
We’ll use a real response for the Latest endpoint and outline how to call the OHLC and Intraday endpoints so you can ship the integration fast. If you are not fully sure about the symbol code for your target index or variants, verify the ticker first on the Indices-API Supported Symbols page.
How NSERV quotes are expressed (base, rates, and USD cross)
Indices-API returns data relative to a base currency. For the endpoints covered here, the base is USD. That means the rates object expresses “units per USD.” For indices, rates.NSERV represents how many NSERV units one USD buys. The reciprocal USDNSERV (when provided) represents how many USD one NSERV unit is worth.
- rates.NSERV = NSERV per 1 USD
- rates.USDNSERV = USD per 1 NSERV
For rendering a chart in USD terms, most teams use rates.USDNSERV directly. If the cross is not present in a specific response, use 1.0 / rates.NSERV to compute USD per NSERV safely, taking care with precision.
One request to get the live NSERV print
Use the Latest endpoint to pull the current NSERV quote and the USD cross. The request uses the access_key query parameter for authentication.
curl -s "https://indices-api.com/api/latest?access_key=YOUR_API_KEY&symbols=NSERV"
Example of a real JSON response (do not alter any values; this is exactly what the API returned):
{"data":{"success":true,"timestamp":1794012060,"date":"2026-11-07","base":"USD","rates":{"NSERV":0.0028837565676001,"USD":1,"USDNSERV":346.7699081244618}}}
Fields you will use:
- success: boolean flag to check request status.
- timestamp: UNIX epoch seconds for when the rates were computed. Use it to avoid repainting old data.
- date: the UTC calendar date of the snapshot. Useful for labeling and end-of-day tasks.
- base: the base currency, here “USD”.
- rates.NSERV: NSERV-per-USD. In this sample, 1 USD = 0.0028837565676001 NSERV.
- rates.USDNSERV: USD-per-NSERV. In this sample, 1 NSERV = 346.7699081244618 USD.
JavaScript example: fetch latest NSERV and compute a display price
This snippet calls the same Latest endpoint, validates the response, and extracts the USD price. If USDNSERV is present, it uses that field; otherwise, it inverts rates.NSERV.
async function fetchNservLatest() {
const url = "https://indices-api.com/api/latest?access_key=YOUR_API_KEY&symbols=NSERV";
const res = await fetch(url, { method: "GET" });
if (!res.ok) throw new Error("HTTP error " + res.status);
const payload = await res.json();
// Basic validation
if (!payload || !payload.data || payload.data.success !== true) {
throw new Error("API success flag is false or payload is malformed");
}
const { timestamp, date, base, rates } = payload.data;
if (!rates || (rates.NSERV == null && rates.USDNSERV == null)) {
throw new Error("Expected NSERV or USDNSERV in rates");
}
// Prefer USD-per-index if provided; otherwise compute 1 / (NSERV-per-USD)
const usdPerIndex = (rates.USDNSERV != null)
? rates.USDNSERV
: (1.0 / rates.NSERV);
return {
date,
timestamp,
base,
usdPerIndex,
raw: payload.data
};
}
fetchNservLatest()
.then(({ date, timestamp, usdPerIndex }) => {
console.log("NSERV latest on", date, "(ts:", timestamp + "):", usdPerIndex, "USD per index");
})
.catch(err => {
console.error("Failed to fetch NSERV latest:", err);
});
Daily OHLC and intraday candles for NSERV
For candles, you will use two endpoints:
- OHLC: open-high-low-close/YYYY-MM-DD for daily bars.
- Intraday: interval-based candles for a given trading date.
Both endpoints return time-bucketed prices that align with trading sessions; weekends and local holidays will typically have no candles. Because the index trades on a regional schedule, you should treat timestamps as UTC for storage and convert to the user’s timezone for display.
Request formats, accepted parameters, and the exact response schema for OHLC and Intraday are documented in the Indices-API Documentation. Use NSERV as your symbol and confirm symbol details on the Symbols page before you wire the endpoint into production.
Design tips for OHLC and intraday integrations
- Always check the success flag and handle empty candles on non-trading days.
- Treat end_date as exclusive for time windows and do not set end_date to “today” for historical backfills; use up to yesterday to avoid partial-day ambiguity.
- Cache intraday series client-side for your chart’s visible range to avoid redundant calls when the user pans/zooms. Server-side caches are recommended at 30–60 seconds for “latest-like” widgets, depending on your plan’s refresh interval.
- Use the timestamp on each candle (or the top-level timestamp) as your freshness key and to deduplicate incoming updates.
How often the latest data updates and how to handle caching
Update frequency for the Latest endpoint depends on plan tier. Expect refresh intervals like every 60 minutes or every 10 minutes. If you’re rendering auto-updating dashboards, align your polling and cache invalidation with your plan’s granularity to avoid unnecessary requests and mismatched expectations.
- Client caching: throttle fetches to the known update cadence; add exponential backoff on failures.
- Server caching: cache-by-symbol with a TTL no shorter than the plan’s refresh interval; propagate cache headers to clients if applicable.
- Intraday/OHLC: do not re-request complete sessions repeatedly. Page or window requests by date and interval, updating only the final “developing” candle inside the active session.
Comparing the endpoints you’ll use
| Endpoint | What it returns | Primary use | Typical polling | Notes |
|---|---|---|---|---|
| Latest | Snapshot with base, date, timestamp, and rates (e.g., NSERV, USDNSERV) | Top-of-screen price, PnL calc, alert triggers | Align with plan refresh (e.g., 60 or 10 minutes) | Use USDNSERV for USD price; compute inverse if missing |
| OHLC | Daily open, high, low, close for a date (per symbol) | Daily charts, EOD analytics, performance tiles | Once per session; refetch after official close | Do not assume today’s close before the session ends |
| Intraday | Interval-based candles (e.g., 1m/5m/15m) for a trading date | Real-time charting, intraday alerts, VWAP bands | Update the final in-progress candle; windowed fetches | No candles on weekends/holidays; timezone matters |
Data correctness and time boundaries
Keep these boundary rules in mind when you build backfills and alerts:
- Do not set end_date to the current date when you are requesting historical ranges or time series. Use up to the last fully completed trading day.
- Weekend and holiday dates will not produce new OHLC or intraday candles; your chart should skip these gracefully.
- Timestamps in responses are UNIX epoch seconds; store and compare them as integers to avoid float rounding issues.
- Dates are calendar dates in UTC. If your product shows local market time, convert on the client.
Backfill strategy for NSERV
For an initial build, backfill daily OHLC first. Populate the last 6–24 months of daily bars in your warehouse, then layer intraday only for the most recent N sessions you need for short-term analytics. This prioritizes stable data first and reduces costs and latency.
- Daily OHLC backfill: iterate dates from your chosen start_date to yesterday; insert idempotently by symbol+date.
- Intraday backfill: fetch for the last M trading days only (e.g., 20–60), as most UIs don’t show deep intraday history by default.
- Latest sync: keep a thin “latest_quotes” table keyed by symbol to accelerate tiles and alert checks.
Python example: using the latest snapshot in analytics
The following Python code requests the latest NSERV snapshot, extracts the USD price, and prints structured diagnostics for logging or monitoring. It expects the same response fields shown above.
import requests
import math
import time
API_URL = "https://indices-api.com/api/latest"
API_KEY = "YOUR_API_KEY"
def get_latest_nserv():
params = {
"access_key": API_KEY,
"symbols": "NSERV"
}
r = requests.get(API_URL, params=params, timeout=10)
r.raise_for_status()
payload = r.json()
if not payload or "data" not in payload or not payload["data"].get("success", False):
raise RuntimeError("API returned an unsuccessful response")
data = payload["data"]
ts = data.get("timestamp")
date = data.get("date")
base = data.get("base", "USD")
rates = data.get("rates", {})
if "USDNSERV" in rates:
usd_per_index = rates["USDNSERV"]
elif "NSERV" in rates and rates["NSERV"] != 0:
usd_per_index = 1.0 / rates["NSERV"]
else:
raise RuntimeError("Missing NSERV and USDNSERV in rates")
return {
"timestamp": ts,
"date": date,
"base": base,
"usd_per_index": usd_per_index,
"raw": data
}
if __name__ == "__main__":
snap = get_latest_nserv()
print("NSERV latest:")
print("- date:", snap["date"])
print("- timestamp:", snap["timestamp"])
print("- base:", snap["base"])
print("- USD per index:", snap["usd_per_index"])
Operational guidance: retries, precision, and alerts
- Retries: use short, bounded retries (e.g., 2–3 attempts) on network timeouts. Respect the API’s pacing.
- Precision: when computing USD per index from 1 / rates.NSERV, use decimal or high-precision floats to avoid UI drift; always display rounded values distinctly from stored values.
- Alerts: to trigger “crossed intraday high” or “price change exceeds X%,” combine a Latest snapshot with your most recent intraday high/low, refreshing on the plan’s cadence.
- Monitoring: log timestamp and symbol alongside each fetch; warn if the timestamp goes stale compared to your expected refresh window.
Where to find parameters and advanced usage
For full details on optional parameters (e.g., intervals, date formats, pagination windows if applicable) and response schemas for OHLC and Intraday endpoints, see the Documentation. If you’re exploring additional symbols beyond NSERV, confirm them on the Symbols page first to avoid mismatches.
To understand how Indices-API fits into a multi-asset content pipeline, visit MCP for integration context.
Plan, pricing, and trial
Production usage, including near real-time updates, is available on the PRO plan (49.99 USD/month) with a 7-day trial to validate your integration before you go live. Use the trial to confirm your intraday polling strategy, caching intervals, and backfill volume.
Additional references for NSERV context
- Indices-API Homepage for product overview and updates.
- NSE India market data to understand local trading sessions and holidays relevant to NSERV.
FAQ
How do I convert the latest response into a USD price for charting?
Use rates.USDNSERV if available. If not, compute 1.0 / rates.NSERV. Store and display the result as USD per index unit.
Why is there no data for a weekend date?
Indices normally don’t print new trading data on weekends and local holidays. For OHLC and intraday, skip non-trading days and avoid scheduling backfills for those dates.
What timestamp should I use for deduplication?
Use the top-level timestamp field from the response as your freshness key. For intraday candles, use each candle’s timestamp; only replace the final in-progress candle during the active session.
Can I request historical NSERV data up to today?
Avoid setting end_date to the current date for historical/time-series pulls. Use up to the last fully completed trading day to ensure you don’t ingest partial data.
How frequently should I poll the Latest endpoint?
Match your polling interval to your plan’s update frequency (for example, 60 or 10 minutes). Add short client- and server-side caches with TTLs aligned to that cadence.
Get your API key and ship it
Ready to integrate NSERV into your dashboard or research pipeline? Start your 7-day trial and get an API key here: Register. Then read the endpoint details for OHLC and intraday, and confirm your symbols, in the Documentation and Symbols pages. You can be plotting NSERV in USD within minutes.