Agent Websocket API
The Fractrade platform provides websocket endpoints for real-time data and action streaming for every agent.
Action Websocket
The Action websocket allows you to receive real-time actions from your agents.
Endpoint
wss://api.fractrade.xyz/ws/actions/{agent_id}Authentication
Authentication is required to connect to the websocket. You can authenticate using your API key and secret:
wss://api.fractrade.xyz/ws/actions/{agent_id}?api_key={api_key}&api_secret={api_secret}Message Format
Messages are sent in JSON format. Each message contains an action object:
{
"action_id": "action-uuid",
"action_type": "EXECUTE_HYPERLIQUID_PERP_TRADE",
"agent_id": "agent-uuid",
"config": {
"position": {
"asset": "BTC",
"size": 0.1,
"side": "LONG",
"leverage": 10,
"exchange": "hyperliquid"
}
},
"created_at": "2023-01-01T00:00:00Z",
"status": "PENDING"
}Action Types
The following action types are published to the websocket:
EXECUTE_HYPERLIQUID_PERP_TRADE
Execute a trade on Hyperliquid
SET_HYPERLIQUID_PERP_STOP_LOSS
Set a stop loss on Hyperliquid
SET_HYPERLIQUID_PERP_TAKE_PROFIT
Set a take profit on Hyperliquid
Note: SEND_TELEGRAM actions are not published to the websocket as they are only used internally for sending notifications to Telegram.
Example: Connecting with Python
Example: Connecting with JavaScript
User Channel Websocket
For users who want to receive actions from all their agents, you can connect to the user channel websocket:
This endpoint requires user authentication and will stream all actions from all agents owned by the user.
Rate Limits
Maximum 10 concurrent connections per user
Maximum 100 messages per minute per connection
Error Codes
1000
Normal closure
1001
Going away
1002
Protocol error
1003
Unsupported data
1008
Policy violation
1011
Internal server error
Last updated