Skip to main content

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 HTTP 429 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 429 quickly 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.
For any production, multi-user app the recommended pattern is:
  1. Call psxdata from your backend, not the browser.
  2. 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.
  3. Serve subsequent user requests from your cache, and refresh in the background.
One cached fetch on your backend can serve thousands of end users without hitting the limit. If you also need to work with the data in Python — for example to run analytics or backtests — the psxdata Python SDK talks to PSX directly and caches to disk, so it is not affected by the REST API rate limit.

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 single curl call:
A successful response looks like:
Ready to build something? Continue with the quickstart guide.

Using the API with LLM agents

The REST API is public, unauthenticated, and described by an OpenAPI 3.1 specification, so it can be exposed to any LLM that supports tool or function calling. There is no dedicated MCP server or first-party LLM integration in this repository. Point the model at the OpenAPI spec and it can call the endpoints directly.
  • OpenAPI spec: https://raw.githubusercontent.com/mtauha/psxdata-docs/master/openapi.json
  • Base URL: https://psxdata-api.fastapicloud.dev
  • Auth: none
Two common patterns:
  1. Direct tool use — generate tool or function definitions from the OpenAPI spec (for example with an OpenAPI-to-tools converter) and register them with the model. The model calls the endpoints as tools and gets JSON back in the standard envelope described above.
  2. Through an MCP client — any MCP server that wraps an OpenAPI spec (for example community openapi-mcp-server projects) can expose these endpoints to Claude Desktop or other MCP-aware clients. Configure the server with the OpenAPI URL and base URL above.
Because responses always follow the { data, meta } or { error } envelope, models can be instructed to read data on success and surface error.message on failure without extra parsing rules. The 60 req/min per-IP rate limit still applies. When many end users share one agent process, cache responses on your side as described in Using the API in a multi-user app.