SET (SETI) Price History API: Pagination, Filtering, and Rate Limit Handling
You need to backfill the SET Index (SETI) into your app, chart it over arbitrary ranges, and keep paging through long histories without tripping rate limits. By the end of this guide, you will fetch SETI time series reliably, chunk large requests, filter what you store, and implement defensive retry/caching so your dashboard and alerts stay responsive.
What we’re building: a robust SETI history fetcher
We’ll focus on two endpoints you’ll actually use to ship this:
- Latest: to validate connectivity and sanity-check your pipeline before backfilling.
- Time-series and historical: to fetch daily prices across a date range you control, in paginated chunks.
We’ll keep the examples on the SET Index (symbol SETI). If you need to confirm the symbol or discover related Thailand indices, check the Indices-API Supported Symbols.
All examples assume you’ve created an API key. If you haven’t, start here: Register. There’s a PRO plan at $49.99/mo with a 7-day trial.
How prices are quoted: base currency, units, and weekends
Indices-API returns index quotes relative to a base currency (by default USD). Rates are expressed as a ratio against the base. For example, a field like USDSETI represents how many SETI units one USD buys, and a plain SETI rate represents a price relative to USD depending on the endpoint. You’ll read base, date, and timestamp fields to interpret the snapshot correctly.
Trading-day calendars matter. The SET trades on Thailand business days; weekends and Thailand market holidays have no new daily bar. When you query a date range, you should expect gaps for non-trading days. Do not assume 7 data points per week. Fetching long ranges in chunks (for example, one quarter at a time) will keep your calls fast and easier to retry if a segment fails.
First step: verify your pipeline with Latest
Before you paginate through months of SETI history, confirm your key and parsing using the latest endpoint. This request authenticates via the access_key query parameter.
curl -s "https://indices-api.com/api/latest?access_key=YOUR_API_KEY"
Below is an official response payload you can use to validate your parser. Use these exact values to make sure you’re reading the envelope and the rates correctly.
{"data":{"success":true,"timestamp":1795221600,"date":"2026-11-21","base":"USD","rates":{"SETI":0.023328400927557,"USD":1,"USDSETI":42.86620429344285}}}
What to extract and why:
- data.success: boolean integrity check before using the payload.
- data.timestamp: Unix epoch seconds for when the snapshot was generated. Store this for auditability.
- data.date: the market date for the snapshot, not necessarily “now” (close-driven).
- data.base: quote base currency (USD). All rate fields are relative to this base.
- data.rates.SETI: a rate keyed by the symbol.
- data.rates.USDSETI: cross that can be useful when converting between USD and index units, depending on your use case.
Notes:
- End-of-day updates are aligned to trading sessions; intraday availability depends on plan level. Check update frequency and plan capabilities in the Indices-API Documentation.
- If you cache results, key by date and symbol. The latest endpoint updates on a schedule; a short TTL prevents hammering the API.
Fetch historical days and time series for SETI
For backfills and charting, you’ll call historical and time-series endpoints. These return daily data keyed by date. Use them to pull stable, replayable snapshots for analytics, backtesting, and compliance logs.
Choosing the right endpoint
| Endpoint | Use it for | Pros | Considerations |
|---|---|---|---|
| Historical (single date) | Pull one known date, e.g., to correct a gap. | Predictable, small payload, easy to re-run. | One call per date; use sparingly for backfills. |
| Time-series (date range) | Backfill and charting across a span (e.g., 2024-01-01 to 2024-03-31). | Fewer calls; ordered series per date. | Chunk long periods to manage payload size and retries. |
Key rules to avoid dead ends:
- Do not set end_date to today. Use the most recent trading day (yesterday or last business day) to ensure a closed bar.
- Expect gaps for weekends/holidays and handle missing dates gracefully.
- If you request very long spans, split into smaller ranges to simulate pagination and control memory usage.
Client-side pagination strategy for SETI backfills
Indices-API returns complete ranges for time-series queries, but you should still implement client-side pagination by chunking date ranges. This keeps each response small, improves retryability, and avoids rate-limit bursts.
- Chunk size: 30 to 90 days per request is a practical starting point for daily bars.
- Retry on transient errors with exponential backoff (e.g., 500, 502, 429). Jitter helps prevent thundering herd.
- Cache completed chunks by start/end date to resume partial backfills without re-fetching.
- Validate each chunk by comparing the number of trading days returned with an expected count derived from an exchange calendar, if you have one.
Filtering: fetch only the fields and dates you need
Filtering starts in your request (limit to the symbol of interest) and continues in your processing (drop unused symbols/fields before persisting). For daily analytics you typically keep: date, timestamp, base, and the specific index rate for SETI. If your use case requires conversions (USD ↔ index units), store the direct symbol key (SETI) and the cross (USDSETI) when present.
For time windows, filter at ingestion by enforcing a max end date less than today and skipping known non-trading dates. Your ETL can pre-compute a target date list and only persist rows where a rate exists in the response.
Production-ready example: fetch latest for SETI in Python with retries
This sample calls the latest endpoint, parses the exact fields you’ll use (base, date, timestamp, rates), and implements basic backoff for rate-limit or transient errors. Adapt the same approach for historical or time-series requests and iterate over your backfill chunks.
import os
import time
import json
import requests
from datetime import datetime, timezone
API_KEY = os.getenv("INDICES_API_KEY", "YOUR_API_KEY")
BASE_URL = "https://indices-api.com/api/latest"
def get_latest_seti(max_retries=5, backoff_seconds=1.0):
params = {"access_key": API_KEY}
for attempt in range(1, max_retries + 1):
resp = requests.get(BASE_URL, params=params, timeout=15)
if resp.status_code == 200:
data = resp.json()
# Expect the official envelope with 'data' and the fields shown in the sample
payload = data.get("data", {})
if not payload.get("success"):
raise RuntimeError(f"API returned success=false: {data}")
ts = payload.get("timestamp")
date_str = payload.get("date")
base = payload.get("base")
rates = payload.get("rates", {})
seti = rates.get("SETI")
usdseti = rates.get("USDSETI")
if seti is None:
raise KeyError("SETI not found in rates. Confirm symbol on the Symbols page.")
# Normalize timestamp to ISO-8601 for storage
ts_iso = datetime.fromtimestamp(ts, tz=timezone.utc).isoformat() if ts else None
return {
"timestamp": ts,
"timestamp_iso": ts_iso,
"date": date_str,
"base": base,
"seti": seti,
"usdseti": usdseti
}
elif resp.status_code in (429, 500, 502, 503, 504):
sleep_for = backoff_seconds * (2 ** (attempt - 1))
time.sleep(sleep_for)
continue
else:
resp.raise_for_status()
raise TimeoutError("Exceeded max retries when calling latest endpoint")
if __name__ == "__main__":
record = get_latest_seti()
print(json.dumps(record, indent=2))
What this does:
- Uses access_key as a query parameter, as required by the API.
- Parses data.success, timestamp, date, base, and rates.SETI/ USDSETI for downstream use.
- Implements a conservative retry policy for 429/5xx and backs off exponentially.
- Outputs a compact record ready to store in your time-series DB keyed by date+symbol.
Building your historical SETI importer: pagination, rate limits, and caching
To backfill months or years of SETI, iterate over a calendar in fixed windows and call time-series for each window. Even if the API returns large ranges, chunking is safer and faster to recover when a single call fails. A typical flow:
- Determine the last persisted trading date for SETI in your storage.
- Generate windows from that date forward to the last complete trading day (never use today as end_date).
- For each window:
- Call time-series with start_date and end_date.
- Parse base, and then rates[YYYY-MM-DD]["SETI"] for each key date present.
- Store only SETI and the fields you need (drop other symbols to reduce I/O).
- Cache the window payload on disk or object storage so a re-run can skip the network if unchanged.
- Respect a minimum delay between calls to avoid hitting rate limits, and retry with backoff on 429/5xx.
If you need step-by-step coverage of available endpoints and expected response shapes for time-series and historical, refer to the Indices-API Documentation. Confirm the exact SETI symbol and any related Thai indices via the Indices-API Supported Symbols.
Operational tips that save time
- Timezones: Use the timestamp field to anchor a record in UTC and the date field as the market date. Store both.
- Idempotency: Make your importer safe to re-run. Upserts keyed by (symbol, date) and checksums of payload chunks avoid duplicates.
- Caching policy: Cache “latest” snapshots briefly (minutes) and historical/time-series aggressively (hours to days), since historical bars don’t change.
- Filtering for charts: If your charting library expects a single numeric close per day, map the daily SETI rate to your y-value and keep base/date for tooltips.
- Monitoring: Alert on missing expected trading days to catch upstream calendar mismatches or network failures.
End-to-end cURL + JSON walkthrough for SETI
Here’s a copy-pasteable cURL you can run to verify your environment. It hits the same endpoint shown above and returns a payload that includes SETI and USDSETI quotes relative to USD.
curl -s "https://indices-api.com/api/latest?access_key=YOUR_API_KEY"
Sample payload to validate your parser (use these exact values when writing tests):
{"data":{"success":true,"timestamp":1795221600,"date":"2026-11-21","base":"USD","rates":{"SETI":0.023328400927557,"USD":1,"USDSETI":42.86620429344285}}}
After parsing:
- Use base to interpret the rate fields.
- Use date and timestamp to align the record to a trading day and UTC time.
- Use rates.SETI as your daily price input; keep USDSETI if your calculations need that cross.
Rate-limit handling and resiliency patterns
You’ll eventually encounter 429 or transient 5xx errors when coordinating large backfills. The safe path:
- Detect 429/5xx and implement exponential backoff with jitter. Cap retries to protect your job queue.
- Respect a small sleep between chunked calls, especially during initial backfills.
- Persist progress markers (last completed end_date) so a job restarts from the last chunk, not from scratch.
- Use strong caching for completed chunks; re-reads fetch from cache rather than the network.
For more advanced controls (e.g., queuing, job orchestration, and parallelization caps), see your internal scheduler, or explore managed compute patterns such as the MCP reference for guidance on building reliable, resumable pipelines.
Validation: trading days, end_date rules, and sanity checks
Before you persist a window, run a few checks:
- End-date rule: Don’t request today as end_date; use the last completed trading day to avoid partial data.
- Weekend/holiday gaps: Confirm that missing dates align with non-trading days; don’t treat them as errors.
- Monotonic dates: Ensure the response keys are in chronological order; sort if necessary.
- Base consistency: Verify base == USD for all chunks. If you change base in future requests, version your storage schema.
Where to go next
Explore examples and response formats for time-series and historical in the Indices-API Documentation. Confirm the exact symbol code and available indices in the Indices-API Supported Symbols. For background on the SET Index methodology and session times, see the Stock Exchange of Thailand’s official resources at SET Index Overview.
FAQ
Can I request today as the end_date?
No. Use the last completed trading day. Today may be incomplete or unavailable, and requests should target closed bars.
What currency are rates returned in?
By default, USD is the base. Read the base field in each response and treat rates accordingly. Store base alongside your values.
How do I handle missing days in a time series?
They’re usually weekends or Thai market holidays. Treat missing dates as non-trading days rather than errors. If you need consistent x-axes, forward-fill in the presentation layer, not in storage.
What’s the best way to avoid rate-limit errors during backfills?
Chunk long ranges (e.g., 30–90 days), add a small inter-request delay, and implement exponential backoff on 429/5xx. Cache completed chunks and resume from the last successful end_date.
How can I confirm I’m using the correct symbol for the SET Index?
Use the SETI symbol, and verify it on the Indices-API Supported Symbols page before deploying.
Ready to chart SETI and ship your backfill? Create your key and start integrating in minutes: Register.