Real-Time System

CLIQI uses Socket.IO for real-time communication between the backend and frontend. Users receive instant updates about trades, prices, and alerts without polling.

Connection

const socket = io('https://api.cliqi.bot', {
  auth: { token: '<jwt_token>' }
});

On connection, the user is automatically joined to their private room (user:{userId}).


Server → Client Events

trade:confirmed

Emitted when a BUY or SELL trade is successfully confirmed on-chain.

{
  "tradeId": "clx...",
  "txHash": "0x5abc...",
  "tokenSymbol": "DEGEN",
  "chain": "BASE",
  "action": "BUY",
  "amountIn": "0.005",
  "amountOut": "42000",
  "message": "Bought DEGEN for 0.005 ETH",
  "timestamp": "2026-03-01T00:00:05.000Z"
}

trade:failed

Emitted when a trade fails during execution.

trade:rejected

Emitted when a trade is blocked by safety checks before execution.

trade:pending

Emitted when a trade is submitted but not yet confirmed.

alert:low_balance

Emitted after a like-to-buy trade when wallet balance drops below the user's threshold. Premium only.

alert:daily_limit

Emitted when a free user hits their 5 trades/day limit.

auto-sell:executed

Emitted when auto-sell triggers and successfully executes. Premium only.

auto-sell:failed

Emitted when auto-sell triggers but execution fails. Premium only.

prices:update

Live token price updates pushed every 30 seconds. Includes all tokens in the user's wallet.


Frontend Integration

React Hooks

The frontend provides custom hooks for WebSocket integration:

Hook
Purpose

useWebSocket(token)

Connection lifecycle management

usePriceUpdates(callback)

Subscribe to real-time price updates

useTradeNotifications(callback)

Subscribe to trade status events

useAlerts(callback)

Subscribe to low balance + daily limit alerts


Event Summary

Event
Trigger
Premium Only?

trade:confirmed

Trade confirmed on-chain

No

trade:failed

Trade failed on-chain

No

trade:rejected

Trade blocked by safety checks

No

trade:pending

Trade submitted to chain

No

alert:low_balance

Wallet below threshold after like-to-buy

Yes

alert:daily_limit

Free user hits 5 trades/day

No

auto-sell:executed

TP/SL trigger executed

Yes

auto-sell:failed

TP/SL trigger failed

Yes

prices:update

Every 30 seconds

No

Last updated

Was this helpful?