Paper Trading API for Python

Place orders, stream quotes, and manage portfolios using Python. Start with these minimal examples.

Authenticate & Place Order

import requests

API_KEY = 'YOUR_API_KEY'

# Get JWT token
r = requests.post('https://api.paperinvest.io/v1/auth/token', json={'apiKey': API_KEY})
access_token = r.json()['access_token']

# Place a market order
headers = {'Authorization': f'Bearer {access_token}', 'Content-Type': 'application/json'}
order = {
  'accountId': 'your-account-id',
  'portfolioId': 'your-portfolio-id',
  'symbol': 'AAPL', 'quantity': 10,
  'side': 'buy', 'type': 'market', 'timeInForce': 'day'
}
resp = requests.post('https://api.paperinvest.io/v1/orders', headers=headers, json=order)
print(resp.status_code, resp.text)

Stream Quotes (SSE)

import sseclient, requests

# Requires sseclient-py
access_token = requests.post('https://api.paperinvest.io/v1/auth/token', json={'apiKey': 'YOUR_API_KEY'}).json()['access_token']
headers = {'Authorization': f'Bearer {access_token}'}

# Example SSE portfolio stream
url = 'https://api.paperinvest.io/v1/stream/portfolio/YOUR_PORTFOLIO_ID'
r = requests.get(url, headers=headers, stream=True)
client = sseclient.SSEClient(r)
for event in client.events():
    print('snapshot:', event.data)

FAQ

Which Python version?

Python 3.9+ is recommended.

Do you have a Python SDK?

HTTP-based usage works in any environment; SDK is planned. Examples below are copy-paste ready.

How do I stream data?

Use SSE or WebSockets. See the examples and websocket guide.