How to create a exchange
Create exchange
To create a new exchange use the following endpoint: POST | Create exchange
You can find the detailed description of all the parameters in the documentation:
Here we consider the most important ones:
- account - Merchant account ID
- payload - Request for exchange
- sourceCurrency - You sell currency
- destinationCurrency - You buy currency
- amount - Amount of the selling asset.
So, to create an exchange without additional commands, you just need to send a request:
curl --request POST \
--url https://api.calypso.finance/api/v1/exchange/create \
--header 'accept: */*' \
--header 'content-type: application/json' \
--data '
{
"account": "string",
"timestamp": 0,
"payload": {
"sourceCurrency": "string",
"destinationCurrency": "string",
"amount": 0
}
}
'
If the creation was successful you receive the response:
{
"id": 0,
"account": "string",
"sourceCurrency": "string",
"sourceAmount": 0,
"destinationCurrency": "string",
"destinationAmount": 0,
"state": "IN_PROGRESS",
"createdDate": "2024-08-22T10:48:54.980Z"
}
After that, you will be able to track the status changes until the exchange is completed using the method below.
Get exchange
To get the current status of the exchange use the following endpoint: POST | Get exchange
Here we consider the most important ones:
- account - Merchant account ID
- timestamp - Current unix UTC timestamp in milliseconds. Must not be less than 3 minutes in the past and not greater than 3 minutes in the future
- payload - Request for exchange
- id - Exchange ID
To get information about the exchange, you need to send a request:
curl --request POST \
--url https://api.calypso.finance/api/v1/exchange/get \
--header 'accept: */*' \
--header 'content-type: application/json' \
--data '
{
"account": "string",
"timestamp": 0,
"payload": {
"id": 0
}
}
'
You receive the response with exchange data and state:
{
"id": 0,
"account": "string",
"sourceCurrency": "string",
"sourceAmount": 0,
"destinationCurrency": "string",
"destinationAmount": 0,
"state": "IN_PROGRESS",
"createdDate": "2024-08-22T10:48:54.980Z"
}
{
"id": 0,
"account": "string",
"sourceCurrency": "string",
"sourceAmount": 0,
"destinationCurrency": "string",
"destinationAmount": 0,
"state": "COMPLETED",
"createdDate": "2024-08-22T10:48:54.980Z"
}
{
"id": 0,
"account": "string",
"sourceCurrency": "string",
"sourceAmount": 0,
"destinationCurrency": "string",
"destinationAmount": 0,
"state": "FAILED",
"createdDate": "2024-08-22T10:48:54.980Z"
}
You need to check the exchange details until you get the final exchange status.
Updated 3 months ago