Base URL
All API requests are made to the following base URL:Authentication
No authentication is required. All endpoints are public and can be called directly without API keys or tokens.Rate limits
Requests are rate-limited to 60 requests per minute per IP address across all endpoints. The limit is enforced by slowapi using the client’s remote IP address. When the limit is exceeded the API returns HTTP429 with the rate_limited error code (see Error codes below).
Using the API in a multi-user app
The 60 req/min limit is keyed on the remote IP address that reaches the API, not on individual end users. This matters when you build a frontend (Next.js, React, mobile app) on top of psxdata:- Calling the API directly from the browser — every user calls from their own IP, so each user has their own 60 req/min budget. In local development, though, every request comes from your single machine and shares one budget, so you will hit
429quickly while testing. - Calling the API from your backend (Next.js API route,
getServerSideProps, a serverless function, or any server you own) — every request comes from the same server IP, so all of your users share one 60 req/min budget. This will fail under real traffic unless you cache.
- Call psxdata from your backend, not the browser.
- Cache the response on your side (in-memory, Redis, or a database). Historical prices never change; intraday data on psxdata refreshes every 15 minutes, so a 15-minute TTL on quotes and index snapshots is a safe default.
- Serve subsequent user requests from your cache, and refresh in the background.
Response format
Every response — success or error — is a JSON object with a single top-level key.Success response (single object)
Success response (list)
Error response
Error codes
Quick example
Fetch the market summary with a singlecurl call: