How to set up trade websocket
wss://wssex.waxpeer.com
Breaking changes due to Steam API update
Now in order to go online and sell items safely you need to implement the following logic:
- Make sure that you have enabled the collection of user data on the website under the "Sell items" tab (by default it is enabled).
- Going online now requires a valid Steam access token because the API key functionality has been limited. You need to send it once an hour or immediately after a refresh (the token is active only 24 hours after refreshing in Steam).
- We categorically recommend not to make a mobile confirmation for a created trade until you send its trade id using the callback method.
- Online may be delayed until the access token is verified. The trade socket has a new user_change event, in which can_p2p indicates whether you are online.
- Custom clients must specify the source parameter on the authentification event (auth) without which the account will not be able to get online (example: "source": "myAwesomeProject").
We categorically recommend not to make a mobile confirmation for a created trade until you send its trade id using the callback . If that POST fails, do not confirm.
You can see an example of the implementation steps here.
How to set up trade websocket
- Connect to websocket via any websocket library. Such as WS, Socket.IO client for Node.js
- Send a ping command once per 25 seconds to keep the connection alive
- Send your authentication object command to let our system recognize you
- Be ready to react to the following object name events:
- send-trade (create trade)
- cancelTrade (cancel trade)
- accept_withdraw (accept incoming trade)
- Don’t forget to confirm trade on mobile
Authentification
You can now go online and sell from limited Steam accounts (Except Rust game). One from STEAM_API, WAX_API, ACCESS_TOKEN is required!
Event parameters
| Name | Type | Description |
|---|---|---|
source | string | your project name |
name | string | always “auth” |
steamid | string | steamid64 |
apiKey | string | OPTIONAL. API key of your Steam account |
waxAPI | string | OPTIONAL. API key of your Waxpeer account |
accessToken | string | OPTIONAL. Access token of your Steam account (NOT encoded) |
tradeurl | string | your tradelink |
{
"source": "myAwesomeProject",
"name": "auth",
"steamid": "76561199059254XXX",
"apiKey": "54###A171A5C7B08CA287A###228C029",
"waxApi": "####124b4bd3847e33331f0e49194b9c798f613d5e732d17c4f5823f7f9c6a##",
"accessToken": "eyAidHlwIjogIkpXVCIsICJhbGciOiAiRWREU0EiIH0.eyAiaXfsd23123123.2B9wKjf2323-S3i3ctdCg",
"tradeurl": "https://steamcommunity.com/tradeoffer/new/?partner=1234567890&token=asd1-5zF"
}Ping
Send a ping command once per 25 seconds to keep the connection alive
Event parameters
| Name | Type | Description |
|---|---|---|
name | string | always “ping” |
{
"name": "ping"
}Pong
Event notifying that a ping command has been received
Event parameters
| Name | Type | Description |
|---|---|---|
name | string | always “pong” |
msg | string | always “1” |
{
"name": "pong",
"data": {
"msg": "1"
}
}Online change event
Indicates whether you are online or not when it is changed by p2p controller
Event parameters
| Name | Type | Description |
|---|---|---|
name | string | always ”user_change” |
can_p2p | boolean | true/false |
{
"name": "user_change",
"data": {
"can_p2p": true
}
}Create trade
Event for trade creation with all necessary data
Event parameters
| Name | Type | Description |
|---|---|---|
name | string | always “send-trade” |
waxid | string | trade UUID in our system |
wax_id | string | trade ID in our system |
tradelink | string | Steam partner tradelink |
partner | string | Steam partner id64 |
send_until | string | when trade will be canceled on Waxpeer if it has not been created before that time |
{
"name": "send-trade",
"data": {
"waxid": "d25s5f63-190s-46b4-8184-b9ec3d326932",
"wax_id": "1234567",
"json_tradeoffer": {
"newversion": true,
"version": 2,
"me": {
"assets": [
{
"appid": 730,
"contextid": "2",
"amount": 1,
"assetid": "27509261111"
}
],
"currency": [],
"ready": false
},
"them": {
"assets": [
{
"appid": 730,
"contextid": "2",
"amount": 1,
"assetid": "27509261111"
}
],
"currency": [],
"ready": false
}
},
"tradelink": "https://steamcommunity.com/tradeoffer/new/?partner=1234567890&token=asd1-5zF",
"partner": "76561199059254XXX",
"created": "2022-11-02T16:00:59.921Z",
"now": "2022-11-02T16:01:16.311Z",
"send_until": "2022-11-02T16:05:59.921Z"
}
}After send-trade, POST /v1/steam-trade with the Steam trade id before mobile confirmation. Do not confirm if that POST fails.
Cancel trade
Event for canceling a trade on Waxpeer
After a recent update STEAM no longer supports trade cancellation via API, so please use https://steamcommunity.com/tradeoffer/TRADE_ID/cancel with cookies
Event parameters
| Name | Type | Description |
|---|---|---|
name | string | always “cancelTrade” |
seller_steamid | string | seller Steam id64 |
trade_id | string | Steam trade ID to be canceled |
{
"name": "cancelTrade",
"data": {
"trade_id": "5521581234",
"seller_steamid": "76561199059254XXX"
}
}Accept withdraw
Event for accepting incoming withdrawal trade from Waxpeer
Event parameters
| Name | Type | Description |
|---|---|---|
name | string | always “accept_withdraw” |
seller_steamid | string | seller Steam id64 |
trade_id | string | Steam trade ID to be canceled |
{
"name": "accept_withdraw",
"data": {
"tradeid": "5521581234",
"partner": "76561199059254XXX"
}
}Socket.IO
Socket.IO is a JavaScript library that enables real-time, bidirectional communication between the server and the client. Website events (new listings, wallet, steamTrade) use wss://waxpeer.com/socket.io/?EIO=4&transport=websocket. Trade sending uses the trade websocket above, not Socket.IO.