FTSE/JSE Top 40 (SA40) Historical Price API — time series retrieval and sampling strategies
To chart the FTSE/JSE Top 40 over time, you need a repeatable way to retrieve daily observations, handle non-trading days and interpret the API’s USD-based quotes. This guide shows how to fetch and parse an SA40 snapshot, then turn historical time-series responses into a backfill and sampling pipeline without mistaking a currency-relative quote for a native index level.
Choose the series before you build the chart
Indices-API identifies the FTSE/JSE Top 40 in the supplied response as SA40. The response also contains USDSA40, its reciprocal quote. Confirm the current symbol specification in Symbols before you connect it to a production chart.
The distinction matters because the default base is USD. In the response below, rates.SA40 expresses SA40 units per USD, while rates.USDSA40 expresses the reciprocal, USD per SA40 unit. Neither label alone establishes that the value is the benchmark’s native published index level or an investable instrument’s price.
Pick one quote orientation for the entire series and label it explicitly. For example, “SA40 units per USD” is less ambiguous than “SA40 price.” If your product needs the exchange-published index level, verify the API’s measurement and units against the source you intend to match before treating either rate as that level.
Fetch and inspect a snapshot
Start with the latest endpoint to check authentication and the SA40 fields available to your application. Replace YOUR_API_KEY with your key; because the key is in the query string, avoid committing the command with a real key to a repository or sharing it in logs.
curl "https://indices-api.com/api/latest?access_key=YOUR_API_KEY"
A response has the following shape and values:
{"data":{"success":true,"timestamp":1795739700,"date":"2026-11-27","base":"USD","rates":{"SA40":0.00017782352556362,"USD":1,"USDSA40":5623.552883851859}}}
The outer data object contains the snapshot. Check success before using rates; then select SA40 or USDSA40 according to the quote orientation you chose. The USD entry is the base-to-base rate, not an additional SA40 observation.
base records the currency against which the rates are expressed. date is the response’s date label, and timestamp is a Unix timestamp in seconds, which can be displayed in UTC. Do not assume the date label is an exchange-session close or that it uses the exchange’s local timezone without checking the documentation.
Read the snapshot in Python
This example calls the same endpoint and retains decimal precision when parsing rates. Set INDICES_API_KEY in the environment before running it. It checks the response before accessing the two SA40 quote fields.
import json
import os
from datetime import datetime, timezone
from decimal import Decimal
from urllib.parse import urlencode
from urllib.request import urlopen
key = os.environ["INDICES_API_KEY"]
query = urlencode({"access_key": key})
url = "https://indices-api.com/api/latest?" + query
with urlopen(url, timeout=30) as response:
payload = json.load(response, parse_float=Decimal)
data = payload.get("data")
if not isinstance(data, dict) or not data.get("success"):
raise RuntimeError("Latest request did not return a successful snapshot")
rates = data.get("rates", {})
sa40 = rates.get("SA40")
usdsa40 = rates.get("USDSA40")
if sa40 is None or usdsa40 is None:
raise RuntimeError("SA40 quote fields are missing")
timestamp = data["timestamp"]
observed_utc = datetime.fromtimestamp(timestamp, tz=timezone.utc)
print("Base:", data["base"])
print("Date label:", data["date"])
print("Timestamp UTC:", observed_utc.isoformat())
print("SA40 units per USD:", sa40)
print("USD per SA40 unit:", usdsa40)
A successful response can still be unsuitable for a particular chart: the date may be stale for your use case, the quote orientation may not match your stored series, or a required rate may be absent. Treat those conditions separately from a transport failure, and keep the original date, timestamp and base alongside the value you store.
Backfill daily observations
The time-series endpoint is the appropriate starting point for a historical chart because it returns daily rates over a selected date range. Its response example groups rates by date, with symbol values nested inside each date. The time-series example has start_date, end_date and base fields; unlike the latest example above, it does not show a timestamp for each observation.
Use Documentation for the current time-series request syntax, date-range limits, access conditions and response handling. Select the confirmed SA40 symbol and a historical range supported by your plan. The time-series end_date cannot be today, so stop the historical request before today rather than trying to include the current day.
Keep the latest snapshot and the historical series as distinct inputs. A latest response has a timestamp and a date label; a daily historical observation is keyed by date. Adding the latest value to a historical chart can be useful, but mark it as a current snapshot rather than silently treating it as a completed daily observation.
Build a repeatable backfill
- Define the desired historical window and the quote orientation to store. Confirm the available SA40 history rather than assuming a coverage start date.
- Divide the window into requests that comply with the documented date-range limit. If the windows overlap, deduplicate by date, symbol, base and quote orientation.
- For each returned date, read the SA40 rate only if the requested symbol is present. Preserve the returned date key and base with the numerical value.
- Sort observations by date before charting or calculating changes. Do not rely on JSON object order as your time-series ordering.
- Record missing or incomplete dates for review. Retry failed requests separately from dates for which the API returned no observation.
Use the documented request limits to decide how to partition a long backfill. Check the documentation for any pagination behavior applicable to your request; do not assume that one successful response necessarily covers a longer interval than the range you submitted. Store enough request context to rerun a window if a download fails or historical data is revised.
For a scheduled incremental job, request only the eligible historical period after your last stored observation, subject to the rule that end_date cannot be today. It can be useful to revisit a small overlap and upsert observations, provided your application records when a previously stored value changes. That approach avoids creating duplicates when a job is retried.
Sampling, calendars and quote direction
A daily API response is not automatically a clean trading-session calendar. The South African market has weekends and market holidays, and a provider may omit a non-trading date or return a carried value. Inspect the returned dates and verify the provider’s convention before assuming that every date represents a new session.
For a trading-day chart, retain actual observations and align them with an authoritative market calendar. For a calendar-day display, decide whether to leave gaps or carry the last available observation forward. If you carry values, mark them as filled in your own dataset: a repeated value is not evidence that trading occurred or that the index was unchanged during an active session.
For weekly or monthly views, first store the daily observations, then select the last available eligible observation in each period. This avoids assuming that a period ends on a trading day. Keep the selected observation’s actual date visible so a user can distinguish the sampling date from the calendar-period label.
Calculate a percentage change only between observations with the same base and quote orientation. A rise in SA40 units per USD corresponds to a fall in its reciprocal, all else being equal; a percentage change in one orientation is not interchangeable with the percentage change in the other. If you need native-index returns, first establish how the supplied USD-relative quote relates to the benchmark and any currency movement.
Missing observations need an explicit policy. Skipping a missing day means a change may span multiple sessions; filling it may create an artificial zero change. For research pipelines, retain the raw observations and make any filling or downsampling a reproducible derived step rather than overwriting the source series.
Freshness and operational checks
The latest endpoint’s update frequency depends on the subscription: the supplied information describes updates every 60 minutes or every 10 minutes for some plans. Check your plan and the documentation for the applicable cadence. Polling more frequently than the data updates does not guarantee a fresher observation.
Cache latest responses for an interval appropriate to that cadence and your product’s freshness requirement. Display the response timestamp or a clearly labeled last-updated time, especially when a dashboard remains open. Do not replace the provider timestamp with the time your server fetched the response; those are different events.
Historical windows can usually be cached separately from the latest snapshot. Use a cache key that distinguishes the requested date range, symbol, base and quote orientation. Set a review or refresh policy for past windows if corrections matter to your application, and retain the retrieval time so you can identify which version of a series was used in a report.
Keep the access key server-side when possible, redact query strings from logs and error reports, and handle failed responses without exposing the request URL to end users. Validate that the returned base and required rate match what your storage layer expects before updating a chart or firing an alert.
An alert based on the latest quote should also account for staleness and orientation. Compare like with like, reject a missing or unexpectedly old observation according to your own policy, and state whether the threshold applies to SA40 per USD or its reciprocal. This prevents a quote-direction change from reversing the apparent meaning of a move.
For teams integrating data into other workflows, the MCP page describes another integration option. The same checks for symbol, units, dates and freshness still apply to any downstream use.
FAQ
Can I request today in a historical time series?
No. The time-series end_date cannot be today. Use an eligible historical end date and, if needed, show the latest snapshot separately with its timestamp.
Why does my SA40 series have weekend gaps?
Weekends are generally non-trading days, and the API may not provide a new trading observation for every calendar date. Check the returned dates and provider conventions before filling gaps or interpreting repeated values.
Which rate should I plot: SA40 or USDSA40?
Choose the orientation that matches your product and label the units. SA40 is expressed per USD in the supplied snapshot; USDSA40 is the reciprocal. Verify the measurement before presenting either as the benchmark’s native index level.
How far back can I retrieve SA40?
Confirm SA40 coverage and the date-range limits available to your plan in the documentation before designing a backfill. Request only supported windows and handle missing observations explicitly.
Ready to test the snapshot and plan your backfill? Get a free API key through Register, then verify your SA40 quote and historical access before connecting the series to your application.