Skip to main content

Overview

Real-time market data streaming via WebSocket connections for Pakistan Stock Exchange (PSX).

The Live Feed API provides WebSocket-based connections for streaming real-time market data including:

  • Snapshot ticks (price and volume updates)
  • Order book data (bid/ask levels)
  • Order details and execution information
  • Multiple access levels (L0, L1, L2)

Endpoints

Socket Endpoints

EndpointAccess LevelDescription
/2.0/market/feedL0Basic market data (indices and regular market limited)
/2.0/market/feed/fullL1Full market data access
/2.0/market/feed/l2L2Level 2 data including order book and individual orders

Connection Environments

EndpointEnvironment
wss://uat.csapis.comStaging
wss://csapis.comProduction

Authentication

  • Type: Bearer Token (passed as query parameter or header)
  • Required: Yes

Connection Limits

⚠️ Important: Only 2 concurrent connections are allowed per authentication token. Exceeding this limit will result in connection termination. Plan your backend infrastructure accordingly:

  • Use a single persistent connection per backend service
  • Implement connection pooling if multiple services need access
  • Monitor active connections to avoid hitting the limit
  • Implement proper reconnection logic to handle disconnections

Best Practices

  1. Backend Only: Always consume this endpoint from your backend services, never expose it directly to frontend clients
  2. Connection Management: Maintain a single persistent connection per authentication token and implement exponential backoff reconnection logic
  3. Connection Limits: Monitor to ensure you don't exceed the 2 concurrent connections per token limit
  4. Data Caching: Cache processed market data and distribute to frontend clients via REST/WebSocket endpoints
  5. Data Validation: Validate all incoming messages and handle partial data gracefully
  6. Performance: Process messages efficiently to avoid lag in live data streams
  7. Error Handling: Implement comprehensive error handling for network failures and graceful degradation
  8. Rate Limiting: Respect server rate limits and implement client-side throttling if needed

Use Cases

  • Real-time Trading: Feed live market data to trading platforms
  • Algorithmic Trading: Provide tick-by-tick data for automated strategies
  • Market Monitoring: Real-time dashboard for market surveillance
  • Order Execution: Support high-frequency trading systems