Two steps to Buy Crypto:
1. Get a Quote to Buy Crypto (valid for 30 seconds)
2. Execute the Buy Crypto (execute in 30 seconds)
Step 1: Get a Quote to Buy Crypto
ENDPOINT
GET /v1/crypto/{{walletId}}/buy/quote?cryptocurrency={{cryptocurrency}}&quantity={{quantity}}
OR
GET /v1/crypto/{{walletId}}/buy/quote?cryptocurrency={{cryptocurrency}}&amount={{amount}}
Note: You can request for a quote by specifying the Quantity in the Cryptocurrency or Amount in USD.
where:
- cryptocurrency=one of the cryptocurrencies supported (ex: BTC)
- quantity=quantity of the Cryptocurrency (ex: 0.5)
- amount=amount in USD (ex: 24000.00)
Two methods to get a Quote to Buy Crypto:
Method 1:
BQ: Quote to Buy Crypto by Quantity (in Cryptocurrency)
Quote responds with the Price in USD.
Ex: Buy 0.1 BTC
REQUEST
- GET /v1/crypto/:id/buy/quote?cryptocurrency=BTC&quantity=0.1
RESPONSE
- {
- "id": "qtn-e1435a7c-c809-455e-a210-8a4b0242b48f",
- "cryptoCurrency": "BTC",
- "quotedCurrency": "USD",
- "quantity": "0.1",
- "amount": "4601.71",
- "price": "46017.16",
- "expires": "2022-04-01T01:05:21Z"
- }
In this example: To Buy 0.1 BTC, the Amount 4601.71.
In the quote API, you also get the market price for 1 quantity, in this example, 1 BTC = USD 46017.16
Method 2:
BA: Quote to Buy Crypto by Amount (in USD)
Quote responds with the Quantity in Cryptocurrency.
Ex: Buy USD 4601.71 worth of BTC
REQUEST
- GET /v1/crypto/:id/buy/quote?cryptocurrency=BTC&amount=4601.71
RESPONSE
- {
- "id": "qtn-e1435a7c-c809-455e-a210-8a4b0242b48f",
- "cryptoCurrency": "BTC",
- "quotedCurrency": "USD",
- "quantity": "0.1",
- "amount": "4601.71",
- "price": "46017.16",
- "expires": "2022-04-01T01:05:21Z"
- }
In this example: For the amount of USD 4601.71, you can buy 0.1 BTC.
In the quote API, you also get the market price for 1 quantity, in this example, 1 BTC = USD 46017.16
Step 2: Execute the Buy Crypto
In Step 1, you get a quoteId that is valid for 30 seconds. You can execute the Buy Crypto inside the 30 seconds, else it times out and you'd need to request a new quote. In the request object, pass the quoteId, source USD account and the description.
ENDPOINT
- POST /v1/crypto/:id/buy
REQUEST
- {
- "quoteId": "{{quoteId}}",
- "accountId": "{{accountId}}",
- "description": "buy crypto"
- }
RESPONSE
- {
- "id": "cpt-7fd29184-2e12-4d11-b644-17dbf954ca8a",
- "title": "Crypto Buy Transfer",
- "description": "crypto buy one",
- "cryptoCurrency": "BTC",
- "accountId": "acc-a575f9fb-9283-4c9d-b4fc-77e3c3a36203",
- "walletId": "",
- "quotedCurrency": "USD",
- "quotedPrice": "45839.55",
- "quoteId": "qtn-2804617f-b56f-4ebd-844d-3bfafdd7aee9",
- "quantity": "0.00218152",
- "amount": "100.00",
- "destinationCryptoAddress": "",
- "gasFee": "",
- "txnType": "debit",
- "status": "completed",
- "createdAt": "2022-04-01T01:15:26Z",
- "modifiedAt": "2022-04-01T01:15:26Z",
- "transferredAt": "2022-04-01T01:15:26Z",
- "metadata": null
- }