psxdata is a free, open-source way to get Pakistan Stock Exchange (PSX) data: historical stock prices (OHLCV), live quotes, KSE-100 index constituents, sector performance, the PSX stock screener, company fundamentals, and debt market data. Use it as a Python library, a REST API, an MCP server for AI assistants, or a dbt analytics warehouse.
📖 Read the psxdata documentation · 🐍 psxdata on PyPI · 🌐 Live PSX REST API
| You want to… | Project | Get started |
|---|---|---|
| Download PSX historical stock data in Python or pandas | psxdata: Python library for PSX data | pip install psxdata |
| Get PSX stock prices over HTTP from any language | psxdata-api: PSX REST API | psxdata-api.fastapicloud.dev |
| Ask Claude, Cursor or VS Code about Pakistani stocks | psxdata-mcp: PSX MCP server | claude plugin install psxdata@psxdata-mcp |
| Run SQL analytics on modelled, tested PSX data | psx-warehouse: PSX dbt data warehouse | dbt + BigQuery or MotherDuck |
import psxdata
# Daily OHLCV history for a PSX-listed company
df = psxdata.stocks("ENGRO", start="2024-01-01", end="2024-12-31")
df.to_csv("engro_history.csv") # export PSX data to CSV / Excel
kse100 = psxdata.indices("KSE100") # KSE-100 index constituents
quote = psxdata.quote("LUCK") # live PSX stock quote
screener = psxdata.screener() # P/E, dividend yield, market capcurl "https://psxdata-api.fastapicloud.dev/stocks/ENGRO/historical?start=2024-01-01&end=2024-12-31"
curl "https://psxdata-api.fastapicloud.dev/indices/KSE100"
curl "https://psxdata-api.fastapicloud.dev/stocks/OGDC/quote"The JSON API needs no API key and works from JavaScript, R, Excel Power Query, Google Sheets or any HTTP client.
- Historical stock prices: daily open, high, low, close and volume for 1,000+ PSX tickers
- Live quotes: current price and volume for any PSX-listed stock
- Stock indices: constituents of all 18 PSX indices, including KSE-100, KSE-30, KMI-30 and KMI All Shares
- Sectors: summaries for all 37 PSX sectors, such as banking, cement, fertilizer, and oil & gas
- Stock screener: P/E ratio, dividend yield and market capitalization for about 729 symbols
- Fundamentals: financial reports filed by listed companies
- Debt market: TFCs, Sukuks and other listed debt instruments
- Margin trading: margin-eligible scrips
Pakistan Stock Exchange (dps.psx.com.pk)
│
psxdata Python library: scraping, validation, caching
┌──────────────┼─────────────────┐
psxdata-api psxdata-mcp psx-warehouse
(REST API) (AI assistants) (dbt + BigQuery)
Yes. psxdata-api is a free, public REST API for PSX data at psxdata-api.fastapicloud.dev. It's rate-limited to 60 requests per minute per IP. For heavier use you can self-host it with Docker.
Run pip install psxdata, then call psxdata.indices("KSE100") for the constituents and psxdata.stocks(symbol, start, end) for each stock's daily price history. Save the results with df.to_csv().
Yes. Every psxdata function returns a pandas DataFrame.
No. Prices are raw PKR closing prices as published by PSX. They are not adjusted for splits, bonus shares or dividends.
Yes, any assistant that supports the Model Context Protocol (MCP) can. psxdata-mcp loads PSX data into a local DuckDB database so the assistant can answer questions with SQL.
All psxdata projects are MIT-licensed open source. Issues, feature requests and pull requests are welcome in each repository. ⭐ Star the repos if they're useful to you.
psxdata is an independent open-source project. It is not affiliated with or endorsed by the Pakistan Stock Exchange Limited. Data is provided as-is and is not investment advice.