Skip to main content
This guide walks you through four common API calls: confirming the API is reachable, fetching historical price data, listing index constituents, and understanding how errors are returned. Base URL: https://psxdata-api.fastapicloud.dev

Step 1: Health check

Verify that the API is reachable and operational before making data requests.
Expected response
A status of "ok" means the API is healthy and accepting requests.

Step 2: Fetch historical prices

Retrieve daily OHLCV data for a symbol over a date range. Replace ENGRO with any PSX ticker.
Expected response
meta.count is the total number of trading-day records returned. is_anomaly flags data points that may be suspect due to corporate actions or data-feed issues.

Step 3: List index constituents

Fetch the current list of symbols that make up the KSE-100 index.
Expected response
data is a list of constituents. Each row contains symbol, idx_weight (percentage), market_cap_m (millions PKR), and optional freefloat_m or shares_m depending on the index.

Step 4: Handle a 404 error

The API returns structured errors for all 4xx and 5xx responses. Requesting a symbol that does not exist produces a 404.
Expected response (HTTP 404)
All errors follow the same envelope shape: an error object with status (HTTP code), code (machine-readable string), and message (human-readable description). See Introduction for the full list of error codes.

Next steps

  • Introduction — rate limits, error codes, and the response envelope in detail
  • API reference — endpoint-by-endpoint reference for all available resources