For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Logo
Join CommunityStart Trading
HomeOverviewDIME UtilityTradingRisk & LiquidationsVTFsParadex ChainEcosystemREST APIWebSocket APIAgentic AI HubRelease Notes
HomeOverviewDIME UtilityTradingRisk & LiquidationsVTFsParadex ChainEcosystemREST APIWebSocket APIAgentic AI HubRelease Notes
  • General Information
    • Introduction
    • Server Location
    • Authentication
    • Subscription Channels
    • Error Handling
    • Code Examples
    • Rate Limits
  • WebSocket Channels
  • Useful Resources
    • Paradex Github
    • Paradex CLI
    • Code Samples
    • Python SDK
    • CCXT Integration
Join CommunityStart Trading
On this page
  • Authentication Process
  • Authentication Request
  • Authentication Parameters
  • Authentication Response
  • Example: Authenticating a WebSocket Connection
  • Authentication Errors
General Information

Authentication

Was this page helpful?
Edit this page
Previous

Subscription Channels

Next
Built with

To access private channels in the Paradex WebSocket API, you must authenticate your connection. This page explains how to authenticate your WebSocket connection using a JWT token.

Authentication Process

Authentication is required to subscribe to private channels. The JWT (bearer) token is obtained from the POST /auth endpoint of the REST API.

Important: After the initial authentication, you do not need to re-authenticate your WebSocket connection for the lifetime of the connection.

Authentication Request

To authenticate your WebSocket connection, send an authentication message with the following format:

1{
2 "jsonrpc": "2.0",
3 "method": "auth",
4 "params": {
5 "bearer": "YOUR_JWT_TOKEN"
6 },
7 "id": 0
8}

Authentication Parameters

ParameterTypeDescriptionRequired
bearerstringJWT tokenYes

Authentication Response

Upon successful authentication, you will receive a response similar to:

1{
2 "jsonrpc": "2.0",
3 "result": {
4 "node_id": "a1b2c3d4e5f6g7h8"
5 },
6 "usIn": 1682556415569005368,
7 "usDiff": 1291796,
8 "id": 0
9}

Example: Authenticating a WebSocket Connection

Here’s a complete example of how to authenticate a WebSocket connection using Python:

1import websocket
2import json
3
4websocket_url = "wss://ws.api.testnet.paradex.trade/v1"
5
6# Define the message to send
7message = {
8 "jsonrpc": "2.0",
9 "method": "auth",
10 "params": {
11 "bearer": "JWcgwMbK0bx1uFFef0Lri35ZDwypmCG0isuBv"
12 },
13 "id": 0
14}
15
16# Define a callback to check connection success
17def on_open(ws):
18 # Send the message
19 ws.send(json.dumps(message))
20
21# Define a callback to handle the response
22def on_message(ws, message):
23 response = json.loads(message)
24 print(response)
25
26# Connect to the WebSocket server
27ws = websocket.WebSocketApp(websocket_url, on_open=on_open, on_message=on_message)
28
29# Wait for a response
30ws.run_forever()

Authentication Errors

If authentication fails, you will receive an error response. Common authentication errors include:

Error CodeDescription
40110Malformed Bearer Token
40111Invalid Bearer Token
40112Geo IP blocked

For more information on error handling, see the Error Handling section.