post https://api.zaffex.com/token/trades/open
Open Trade Order
This endpoint allows users to retrieve trade details using an API KEY.
Authentication
ATTENTION: You Need an API Key Token to Access This Endpoint!
Click here to learn how to create an API Key Token → (API Key Token Guide
This endpoint requires an API KEY token. The token must be sent in the api-token
header.
Example:
--header 'api-token: xxxxxxxxxx'
If the token is missing, the API will return:
{
"statusCode": 401,
"status": "error",
"timestamp": "2025-03-04T19:02:53.514Z",
"path": "/token/trades/open",
"data": {
"message": "ApiKey not provided",
"error": "Unauthorized",
"statusCode": 401
}
}
If the token is invalid, the API will return:
{
"statusCode": 401,
"status": "error",
"timestamp": "2025-03-04T19:02:53.514Z",
"path": "/token/trades/open",
"data": {
"message": "Invalid token",
"error": "Unauthorized",
"statusCode": 401
}
}
Endpoints
Open a new trade
- Method: POST
- URL:
/token/trades/open
- Authentication: Required (API KEY Token)
- Description: Opens a new trade using the provided parameters.
Request Example
POST /token/trades/open
api-token: <your_token_here>
Content-Type: application/json
{
"isDemo": true,
"closeType": "01:00",
"direction": "BUY",
"symbol": "BTCUSDT",
"amount": 20
}
Success Response (200)
{
"id": "01JNH8J8R8ZY725ZSHHHN5SZ8A",
"affiliateId": "01J16K0A77M3FH1DSARTZ2X060",
"isDemo": true,
"isInfluencer": false,
"fromBot": false,
"fromApiToken": true,
"tenantId": "01HZDQXAXT4XHT9PCXSF0DY333",
"wallets": [
{
"id": "01J16JVYFG86DZYP7BK6BYZCPS",
"type": "DEMO",
"amount": 20,
"tradePercent": 100,
"balancePercent": 0.19992272986490722,
"balance": 10003.865
}
],
"totalWalletsBalancePercent": 0.19992272986490722,
"symbolSlotName": "default",
"extraId": "01JNH8J7XHZQG2DCXJ0QJMRBN7",
"symbol": "BTCUSDT",
"userId": "01J16JVXPMZN04TTW9ZVPGSTWQ",
"payout": 63,
"amount": 20,
"fromCopy": false,
"copyCommissionRate": 0,
"copyCommissionAmount": 0,
"direction": "BUY",
"expirationType": "TIME_FIXED",
"closeType": "01:00",
"requestTime": 1741114908999,
"openTime": 1741114908999,
"openPrice": 86622.05,
"pnl": 0,
"closePrice": 0,
"closeTime": 1741114968999,
"closePriceTime": 0,
"attemptsToClose": 0,
"result": "PENDING",
"tenantFeeAmount": 0,
"createdAt": "2025-03-04T19:01:49.449Z",
"updatedAt": "2025-03-04T19:01:49.449Z"
}
Possible Errors
Status Code | Message | Description |
---|---|---|
401 | Unauthorized | Token is missing or invalid |
400 | Bad Request | Invalid request payload |
500 | Internal Server Error | Unexpected server error |
Usage Example
To open a trade using curl
:
curl -X POST "https://api.zaffex.com/token/trades/open" \
-H "api-token: <your_token_here>" \
-H "Content-Type: application/json" \
-d '{
"isDemo": true,
"closeType": "01:00",
"direction": "BUY",
"symbol": "BTCUSDT",
"amount": 20
}'
Using TypeScript with fetch
fetch
fetch('https://api.zaffex.com/token/trades/open', {
method: 'POST',
headers: {
'api-token': '<your_token_here>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
isDemo: true,
closeType: "01:00",
direction: "BUY",
symbol: "BTCUSDT",
amount: 20
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));