Why Use gRPC Streaming?
gRPC streaming offers several advantages:- Bidirectional Communication: Server can push updates without client polling
- Type Safety: Strongly-typed messages defined in Protocol Buffers
- Real-time Updates: Receive market data and order updates as they happen
REST + gRPC Hybrid Approach
Most participants use REST for requests and gRPC for streaming. This hybrid approach combines the simplicity of REST with the efficiency of gRPC streaming.
Typical Integration Pattern
-
REST API - Used for:
- Placing orders (
/v1/trading/orders) - Canceling orders (
/v1/trading/orders/cancel) - Querying account information
- One-time data requests
- Placing orders (
-
gRPC Streaming - Used for:
- Real-time market data updates
- Live order execution reports
- Continuous position monitoring
- Order book changes
Available Streaming Services
Market Data Streaming
Subscribe to real-time market data updates including:- Order book (bids and offers)
- Instrument state changes
- Trade statistics (last price, OHLC, volume)
- Open interest
MarketDataSubscriptionAPI.CreateMarketDataSubscription
Learn more about Market Data Streaming β
Order Execution Streaming
Subscribe to real-time order and execution updates:- New order confirmations
- Partial and complete fills
- Order cancellations and rejections
- Execution reports with trade details
OrderEntryAPI.CreateOrderSubscription
Learn more about Order Streaming β
Server Endpoints
Pre-Production Environment
Production Environment
Both endpoints use TLS/SSL for secure communication. All connections must be encrypted.
Testing Connectivity
From a machine with proper DNS (or after adding to/etc/hosts):
Protocol Buffer Definitions
The exchange uses Protocol Buffers (proto3) to define message structures. Proto files are available:- Upon request: Contact onboarding@polymarket.us
- Via server reflection: Use gRPC reflection to discover services at runtime
Package Structure
Quick Start
Ready to get started? Follow our Getting Started Guide to:- Install Python gRPC libraries
- Obtain and compile proto files
- Authenticate and connect
- Subscribe to your first data stream
Architecture Overview
Authentication Flow
- Obtain JWT Token: Request M2M token using client credentials
- Attach Token: Include token in gRPC metadata as
authorizationheader - Stream Data: Receive continuous updates over persistent connection
Rate Limits
| Setting | Value |
|---|---|
| Max concurrent streams per firm | 20 |
| Ingress message rate (per firm, across all streams) | 250 msg/sec |
| Egress (server to client) | Unlimited |
Key Concepts
Heartbeats
Periodic keep-alive messages ensure connection health. If heartbeats stop, the connection may be stale.Snapshots
Initial state of data (e.g., all open orders) sent when subscription starts.Updates
Incremental changes streamed continuously after the snapshot.Session IDs
Unique identifiers for each streaming session, useful for logging and debugging.Next Steps
Getting Started
Set up your first gRPC stream
Authentication
Learn how to authenticate gRPC connections
Market Data
Stream real-time market data
Order Updates
Subscribe to order execution updates