Trades Channel#
Retrieve the recent trades data. Data will be pushed whenever there is a trades.
Request URL
Please contact us dexapi@okx.com.
Request Parameters#
Parameter | Type | Required | Description |
---|---|---|---|
op | String | Yes | Operation, subscribe unsubscribe |
args | Array | Yes | List of subscribed channels |
channel | String | Yes | Channel name,trades |
chainIndex | String | Yes | Unique identifier for the chain. (e.g., 1 for Ethereum. See ChainIndex) |
tokenContractAddress | String | Yes | Token contract address (e.g., 0x382bb369d343125bfb2117af9c149795c6c65c50) |
Response Parameters#
Parameter | Type | Description |
---|---|---|
event | String | Event, subscribe unsubscribe error |
arg | Object | Token contract address |
channel | String | Channel name |
chainIndex | String | Unique identifier for the chain. (e.g., 1 for Ethereum. See ChainIndex) |
tokenContractAddress | String | Token contract address (e.g., 0x382bb369d343125bfb2117af9c149795c6c65c50) |
code | String | Error code |
msg | String | Error message |
Push Data Parameters#
Parameter | Type | Description |
---|---|---|
arg | Object | Successfully subscribed channel |
> channel | String | Channel name |
> chainIndex | String | Unique identifier for the chain. (e.g., 1 for Ethereum. See ChainIndex) |
> tokenContractAddress | String | Token contract address (e.g., 0x382bb369d343125bfb2117af9c149795c6c65c50) |
data | Array | Subscribed data |
> id | String | Unique trade id |
> txHashUrl | String | On-chain txhash of the transaction |
> userAddress | String | Authorizer of the transaction |
> dexName | String | Name of the dex where the trade occured |
> poolLogoUrl | String | Pool logo url |
> type | String | Trade Type buy sell |
> amountExchanged | String | Amount exchanged in this pair |
>> amount | String | Token exchanged amount in this trade |
>> tokenSymbol | String | Token symbol |
>> tokenContractAddress | String | Token contract address |
> price | String | Latest token price |
> volume | String | USD value of this trade |
> time | String | Timestamp of the trade, Unix timestamp format in milliseconds |
> isFiltered | String | If the trade is filtered for price and k-line calculation. 0 : not filtered 1 : filtered |
Request Example#
shell
{
"op": "subscribe",
"args": [
{
"channel": "trades",
"chainIndex": "501",
"tokenContractAddress": "HeLp6NuQkmYB4pYWo2zYs22mESHXPQYzXbB8n4V98jwC"
}
]
}
Response Example#
200
Successful response example
{
"event": "subscribe",
"arg": {
"channel": "trades",
"chainIndex": "501",
"tokenContractAddress": "HeLp6NuQkmYB4pYWo2zYs22mESHXPQYzXbB8n4V98jwC"
},
"connId": "a4d3ae55"
}
Failure response example
{
"event": "error",
"code": "60012",
"msg": "Invalid request: {\"op\": \"subscribe\", \"argss\":[{ \"channel\" : \"trades\", \"chainIndex\" : \"501\", \"tokenContractAddress\" : \"HeLp6NuQkmYB4pYWo2zYs22mESHXPQYzXbB8n4V98jwC\"}]}",
"connId": "a4d3ae55"
}
Push data example
{
"arg": {
"channel": "trades",
"chainIndex": "501"
"tokenContractAddress":"HeLp6NuQkmYB4pYWo2zYs22mESHXPQYzXbB8n4V98jwC"
},
"data":[
{
"id":"1739439633000!@#120!@#14731892839",
"chainIndex": "501",
"tokenContractAddress": "HeLp6NuQkmYB4pYWo2zYs22mESHXPQYzXbB8n4V98jwC",
"txHashUrl": "https://solscan.io/tx/zgDzoiVG4XuDgQcoEg9vhpRyfyk5thNUQuTeTCeF289Qec5iraeCrUzPLyiE2UCviox2ebbTcsagGvzYF7M5uqs",
"userAddress": "2kCm1RHGJjeCKL4SA3ZJCLyXqUD7nEJ7GMtVaP7c6jQ8",
"dexName": "Orca Whirlpools",
"poolLogoUrl": "https://static.okx.com/cdn/wallet/logo/dex_orcaswap.png",
"type": "sell",
"changedTokenInfo": [
{
"amount":"100.396595878",
"tokenSymbol":"ai16z",
"tokenContractAddress": "HeLp6NuQkmYB4pYWo2zYs22mESHXPQYzXbB8n4V98jwC"
},
{
"amount":"2.482831",
"tokenSymbol":"SOL",
"tokenContractAddress": "So11111111111111111111111111111111111111112"
}
]
"price": "26.458143090226812",
"volume": "519.788163",
"time": "1739439633000",
"isFiltered": "0"
}
]
}