Kyrgyzstani Som OHLC API: Best Practices for Fetching Intraday Candles
You need to chart intraday candles and daily OHLC for a single benchmark, then denominate those prices in Kyrgyzstani Som (KGS) so downstream dashboards and alerts work in your product’s base currency. By the end of this guide you’ll fetch the latest level for the S&P 500 (GSPC), understand how to source OHLC and intraday candles, and structure the data so it can be expressed in KGS reliably—without fabricating candles or overfitting to any single trading day.
What you’re building: intraday and OHLC in KGS for a single index
We’ll focus on a single index symbol to keep the API mechanics unambiguous: GSPC (S&P 500). The same approach generalizes to other supported symbols. You’ll:
- Call the Latest endpoint to get the current S&P 500 level and metadata you’ll reuse in candles.
- Understand how the OHLC and Intraday endpoints are structured, and where to apply conversion to KGS.
- Handle trading days vs weekends, timestamp alignment, and caching.
- Avoid data pitfalls like using today as an end_date, which can yield partial or empty results.
If you’re unsure about the exact symbol codes for your target index or for KGS, confirm them on the Indices-API Supported Symbols page before you ship.
Endpoints you’ll actually use
To fetch intraday candles and OHLC for GSPC and then present them in KGS, you’ll use only the endpoints necessary for the job:
- Latest endpoint: establish the current “level” and base/timestamp metadata you’ll rely on for cache control and series heads.
- OHLC endpoint: fetch open, high, low, close for a date.
- Intraday endpoint: fetch interval-based candles for a specific date.
We’ll link to the full reference so you can extend this into time-series or fluctuations later; see the Indices-API Documentation.
First step: fetch the latest GSPC print
Use the Latest endpoint to grab the most recent snapshot. This is critical for:
- Top-of-book checks (is the market open? did the level move?).
- Timestamp alignment (don’t chart candles newer than your latest timestamp).
- Currency denomination: you’ll derive KGS-denominated values by combining index levels with the appropriate currency mapping, as explained below.
Complete curl example
Copy-paste and replace YOUR_API_KEY with your key. If you don’t have one, start the 7‑day trial on the PRO plan ($49.99/mo after) here: Register.
curl -s "https://indices-api.com/api/latest?access_key=YOUR_API_KEY"
Official JSON response (use-as-is)
{"data":{"success":true,"timestamp":1790901480,"date":"2026-10-02","base":"USD","rates":{"GSPC":0.00013043404537279,"USD":1,"USDGSPC":7666.709999999825}}}
How to read this payload
- success: Boolean request status.
- timestamp: UNIX epoch seconds. Use this to govern cache freshness and to avoid mixing candles across updates.
- date: Trading date in YYYY-MM-DD (UTC). Daily OHLC and intraday series should not exceed this value.
- base: USD. Rates are quoted relative to this base.
- rates.USDGSPC: The S&P 500 level quoted in USD terms (numeric level). In the example above it’s 7666.709999999825.
- rates.GSPC: A rate form tied to base currency conventions. For direct charting, rely on rates.USDGSPC for the actual level when your base is USD.
- rates.USD: Always 1 when base is USD.
From USD to Kyrgyzstani Som (KGS)
Your charts need candles denominated in KGS. There are two common paths:
- If the Symbols page lists a direct cross that yields KGS-denominated values for the index, use that symbol directly in the OHLC/Intraday calls.
- If not, convert the numeric USD level or candle values to KGS using currency conversion. Confirm the correct currency code for the Kyrgyzstani Som in the Indices-API Supported Symbols before implementation.
Implementation detail you’ll follow later when fetching candles:
- Get the candle values in USD (e.g., openUSD, highUSD, lowUSD, closeUSD).
- Obtain the USD→KGS rate applicable to the same timestamp window.
- Multiply each USD candle value by that conversion rate to produce KGS values. Keep the original USD candles for reference and audit.
Do not invent a symbol name. Always confirm the exact currency or cross on the Symbols page before coding.
Fetching daily OHLC for GSPC and denominating in KGS
The OHLC endpoint returns open, high, low, and close for a given date. The path format is documented as open-high-low-close/YYYY-MM-DD. You should:
- Pick a completed date (do not use today).
- Fetch OHLC for GSPC in USD.
- Convert each field to KGS using the matching USD→KGS rate for that trading day.
Practical handling tips:
- Timezone: The date field and endpoint dates are UTC; your chart axis should label using your user’s timezone but never shift the candle boundaries inadvertently.
- Market holidays and weekends: Expect the API to skip non-trading days for a given index. If you query a non-session date, handle a null/empty payload gracefully.
- End-of-day completeness: Always use a past date (yesterday or earlier). end_date should not be today because data may still be settling or returned as empty/partial.
Keep the latest snapshot handy (via the Latest endpoint) to cross-check whether your most recent candle aligns with timestamp boundaries. If your candle’s date equals the Latest date but the timestamp suggests the session is still active, treat the candle as “in-progress” and label accordingly in your UI.
Fetching intraday candles for GSPC and denominating in KGS
The Intraday endpoint returns interval-based candles for a specific date. The key behaviors to build around:
- Intervals are tied to a single date. Decide on your resolution (e.g., 1m, 5m) as supported by your plan and the endpoint parameters noted in the docs.
- Only use completed intervals for alerts or PnL calculations; you can still render in-progress intervals with a distinct style.
- For KGS, convert each candle value (open, high, low, close) from USD to KGS using the appropriate USD→KGS rate. If your UX tolerates small FX lag, you can apply a single conversion rate per candle date. For precise parity, reprice each interval with a timestamp-aligned conversion rate.
Because intraday datasets are larger, observe careful caching and pagination/streaming strategies (as described below) to reduce cost and latency for your users.
Code you can copy: pulling the latest GSPC level
Below is a minimal JavaScript example using fetch. It calls the same Latest endpoint you saw in curl and parses the fields you’ll reuse for candles and conversions. Replace YOUR_API_KEY before running.
async function getLatestGSPC() {
const url = "https://indices-api.com/api/latest?access_key=YOUR_API_KEY";
const res = await fetch(url);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const payload = await res.json();
// The official structure nests everything under 'data'.
const { success, timestamp, date, base, rates } = payload.data || {};
if (!success) throw new Error("API reported success=false");
// For direct charting in USD, use rates.USDGSPC for the index level.
const levelUSD = rates.USDGSPC;
// Example: a place to branch into KGS conversion.
// 1) Look up the correct code for Kyrgyzstani Som on the Symbols page.
// 2) Retrieve the USD→KGS rate for this timestamp or date.
// 3) Multiply: levelKGS = levelUSD * usdToKgsRate;
return {
timestamp, // UNIX epoch seconds (UTC)
date, // YYYY-MM-DD (UTC)
base, // 'USD'
levelUSD, // numeric S&P 500 level in USD terms
rawRates: rates
};
}
getLatestGSPC()
.then(console.log)
.catch(console.error);
How to structure your KGS-denominated candles end-to-end
The pipeline below is reliable and keeps your logic deterministic:
- Resolve symbols:
- Confirm GSPC and the Kyrgyzstani Som code on the Symbols page.
- If a direct index-in-KGS symbol exists, prefer it to avoid latency from multi-step conversions.
- Get completeness boundaries:
- Call Latest and record timestamp/date.
- For daily OHLC, target date = yesterday or a known completed trading day. Never pass today as end_date to any historical or time-windowed query.
- For intraday, target a single date and skip intervals beyond the Latest timestamp.
- Fetch candles:
- OHLC: Retrieve the open/high/low/close for the chosen date in USD terms if you don’t have a KGS-native symbol.
- Intraday: Retrieve intervals for the date in USD terms.
- Convert to KGS:
- Obtain USD→KGS rate(s) aligned to the date or interval timestamps. Confirm the FX symbol(s) on the Symbols page.
- Multiply each candle field by the rate you selected (per date or per interval).
- Keep both the USD and KGS values if your product supports currency toggles.
- Render with safety nets:
- Mark partially complete candles and avoid alerting on them.
- Display the candle timezone clearly to users, even if the backend is UTC.
- Cache and debounce updates so charts don’t jitter during rapid polling.
Practical details that save you time
- Base currency and units:
- Responses default to base USD. rates.USDGSPC is the S&P 500 level in USD. rates.USD is 1 when base is USD.
- When you convert to KGS, you’re changing the denomination of the level or candle prices, not the structure of the series.
- Trading days vs weekends:
- Equity indices do not trade on weekends and some holidays. Your date loops should skip non-session dates.
- If you query a non-trading date, expect empty or unchanged arrays. Don’t auto-backfill to the prior session unless that’s a conscious product decision.
- Update frequency:
- Latest updates depend on plan tier. Use the timestamp field to detect fresh data; if unchanged, serve from cache.
- For live-facing dashboards, poll modestly and rely on ETag-like logic (timestamp comparison) to avoid needless redraws.
- Caching:
- Cache Latest until timestamp moves. For completed dates (yesterday or older), cache indefinitely or until you rebalance your backfill job.
- Cache intraday intervals per date; only refresh the tail segments while the session is live.
- Dates and completeness:
- end_date should not be today in any historical/time-windowed request. Use yesterday for a complete candle set.
- Always propagate the API’s date and timestamp through your pipeline for auditability and reproducibility.
Validation and QA before launch
- Spot-check symbol correctness: Be sure GSPC and the Kyrgyzstani Som code match the Symbols directory.
- Cross-check candles: For completed days, reconcile your OHLC against a trusted public source before rolling to production. See, for example, Investopedia on candlesticks for interpretation patterns, and Wikipedia: S&P 500 for background.
- Conversion sanity checks: If you convert to KGS, ensure the FX multiplier yields plausible magnitudes. Log both USD and KGS for the first week, watch outliers, and add alerting if the FX series is stale.
- UI guardrails: Show which currency is currently applied (USD vs KGS) and make it toggleable if your users need side-by-side comparisons.
When to call which endpoint
| Task | Endpoint | Notes |
|---|---|---|
| Render today’s headline level | Latest | Use rates.USDGSPC for USD level; apply KGS conversion if needed. |
| Backfill daily OHLC tiles | OHLC | One date per call; never use today. Convert each field to KGS. |
| Build intraday charts/alerts | Intraday | One date per call; choose a supported interval. Convert per interval or per date. |
Common pitfalls and how to avoid them
- Mixing incomplete data: Don’t append today’s partial OHLC to a “completed days” panel. Use labels like “live” or “preliminary.”
- Using wrong symbols: Always confirm on the Symbols list instead of guessing.
- Timezone confusion: Store timestamps in UTC, and only localize at the UI layer.
- Over-polling: Poll Latest conservatively; redraw only when timestamp changes.
- FX lag: If you convert candles to KGS, decide explicitly whether to use one daily FX rate or time-aligned intraday FX rates. Document the choice for your users.
What to expect as you scale
As you move from a single index to a portfolio of indices or more granular intraday windows, structure your data layer around small, composable jobs:
- One worker for Latest snapshots across all symbols you display in headers.
- Daily batch jobs for OHLC backfill by date.
- Intraday stream that refreshes only the newest intervals for the current session.
- FX multipliers cached per date or per minute, depending on the precision you need for KGS conversion.
For deeper integration topics, consult the Indices-API Documentation and explore advanced features as needed. If you’re evaluating data routing or multi-cloud delivery, see MCP for platform considerations.
Frequently asked questions
How do I ensure my end_date is valid?
Use yesterday (or an older date) for any historical or OHLC/time-series request. Today can be incomplete or empty depending on exchange timing.
Which field represents the S&P 500 level for the Latest endpoint?
Use rates.USDGSPC for the numeric S&P 500 level in USD terms. The base is USD, and rates.USD equals 1.
How often should I poll Latest for a live dashboard?
Poll modestly based on your plan’s update frequency, and redraw only when the timestamp changes. Cache unchanged payloads to reduce cost and jitter.
How do I convert OHLC candles to KGS?
Confirm the correct Kyrgyzstani Som code on the Symbols page, fetch the USD→KGS rate for the candle’s date or interval, and multiply each USD value (open/high/low/close) by that rate. Keep both USD and KGS values for audit and toggling.
Can I request intraday candles across multiple days in one call?
The Intraday endpoint is per date. Query per date and stitch the results client-side or in your data warehouse. For parameters and limits, see the official docs.
Ship it
You now have the building blocks to fetch GSPC’s latest level, retrieve daily OHLC and intraday candles, and present those series in Kyrgyzstani Som with predictable caching and date handling. Grab your free key and start your 7‑day PRO trial ($49.99/mo after) here: Register. Once you’re set up, keep the Documentation and Symbols pages open while you wire intraday and OHLC into your charts.