PiTrade Client APIs Overview
Welcome to the PiTrade Client APIs documentation. This comprehensive guide provides developers with everything needed to integrate with our trading platform and build powerful applications.
PiTrade offers two distinct API integration flows to suit different use cases:
Integration Flows
Flow 1: PiTrade Native APIs (Standard Flow)
Our native APIs provide a comprehensive, streamlined interface for trading and portfolio management. Ideal for clients who need essential trading, portfolio, and rebalancing functionality.
Capabilities:
- Place market orders
- Check and cancel trade orders
- Retrieve portfolio information and holdings
- View transaction history
- Rebalance portfolios with percentage-based target allocations
- Monitor trade execution status
Advantages:
- Simple, intuitive API design
- Quick integration
- Market order execution
- Portfolio rebalancing with percentage-based allocation
- Multi-portfolio support
- Full portfolio and holdings management
Flow 2: Interactive Brokers Direct API Access (Advanced Flow)
For advanced trading requirements, connect directly to Interactive Brokers APIs through our bearer token gateway. This flow unlocks full Interactive Brokers functionality while maintaining PiTrade's security standards.
Capabilities:
- Market and limit orders
- Advanced order types (stop-loss, conditional orders, etc.)
- Full Interactive Brokers API ecosystem access
- Real-time margin impact calculations
- Order preview validation
Limitations:
- Single trading portfolio per account
- Requires Interactive Brokers session management
- More complex implementation
Getting Contract IDs:
To place orders via Interactive Brokers APIs, you need contract IDs for the securities. Interactive Brokers provides a CSV file with contract IDs:
- Download: Interactive Brokers Contract IDs CSV
- Format: Symbol, Main Exchange, Description, IB Contract ID, Scheduled Ineligibility Date
- Usage: Look up the IB_CONTRACT_ID for your ticker symbol, use in order requests
Getting Started
To begin using the Client APIs:
- Obtain Credentials - Get your
clientIdandapiKeyfrom PiTrade Support - Generate IdToken - For Native APIs, create signed JWT tokens and exchange for IdToken
- Make API Calls - Use the IdToken in the Authorization header for all requests
- Handle Responses - Process responses and implement error handling
Base URLs
All API requests use the following base URLs:
Authentication Endpoint
Production:
https://api.pitrade.com/public
Development:
https://devo.api.pitrade.com/public
Used for authentication operations:
POST /auth/token- Generate or exchange tokensPOST /auth/refresh- Refresh expired IdToken
Client API Endpoint
Production:
https://api.pitrade.com/client
Development:
https://devo.api.pitrade.com/client
Used for all PiTrade Native API operations:
- Trading endpoints (Place, Check, Cancel trades)
- Portfolio endpoints (Get portfolios, holdings, transactions)
- Rebalancer endpoints (Portfolio rebalancing operations)
Authentication Flow
PiTrade Native APIs (Standard Flow)
Two-step authentication:
- Create a JWT payload with your
clientIdand expiration time - Sign the JWT with your client apiKey
- POST to
/auth/tokenwith your JWT to receive IdToken, RefreshToken, and AccessToken - Use IdToken in the
Authorization: Bearer <ID_TOKEN>header for all API requests
Interactive Brokers Direct Access (Advanced Flow)
Multi-step authentication:
- Generate IdToken using the same two-step Native flow above
- Use IdToken to call
/user/bearer-tokento get broker bearer token - Use broker bearer token for Interactive Brokers API access