Execute a spot trade with ESP rates, from login and requesting rates to downloading the done trade.
- Your REST API app.
- Integral API login with trading permission.
- Your organization provisioned with at least one provider who streams ESP spot prices.
Use the Login and get token endpoint.
See the related Login tutorial.
Your access token is in SSO_TOKEN of the response header. Your token is valid for limited time.
Pass the SSO_TOKEN cookie value with all of your subsequent API requests.
{ "user": "apiUserId", "pass": "This is a long password!", "org": "apiOrganizationId" }
Use the Get spot rate by symbol endpoint.
See the related Get spot prices tutorial.
const query = new URLSearchParams({symbol: 'EUR/USD'}).toString();
const resp = await fetch(
`/v2/rates/spot?${query}`,
{
method: 'GET',
headers: {
SSO_TOKEN: 'YOUR_API_KEY_HERE'
}
}
);
const data = await resp.text();
console.log(data);Use the Place order endpoint.
See the related Place an order (limit) tutorial.
To get your order status, you must query your order. After the initial success/fail response, status updates are not pushed to you.
- Place limit order (IOC)
- Place limit order (GTC)
- Place limit order w/ custom params
- Place at best order
- Place market order (IOC)
- Place stop order (GTC)
- Place previously quoted order
- Place on behalf of order
{ "coId": "8932452311944", "type": "Limit", "side": "Buy", "symbol": "EUR/USD", "currency": "EUR", "size": 1000000, "price": 1.0971678, "timeInForce": "IOC" }
To get your order status, you must query your order. After the initial success/fail response, status updates are not pushed to you.
Use the Query order (server ID) endpoint.
The diagram shows the values returned in the status field in the response.
const id = '4820276016';
const resp = await fetch(
`/v2/orders/${id}`,
{
method: 'GET',
headers: {
SSO_TOKEN: 'YOUR_API_KEY_HERE'
}
}
);
const data = await resp.text();
console.log(data);Use the Get trades endpoint.
The endpoint returns all executed trades that have not been downloaded before.
Use the orderId from the 202 response when you placed the order to get your trade from the array of returned trades.
const query = new URLSearchParams({maxCount: '20'}).toString();
const resp = await fetch(
`/v2/trades/stp/messages?${query}`,
{
method: 'GET',
headers: {
SSO_TOKEN: 'YOUR_API_KEY_HERE'
}
}
);
const data = await resp.text();
console.log(data);