Buy Crypto

Buy Crypto is buying a supported Cryptocurrency from USD.
Buy Crypto
 last updated: 
March 31, 2022

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

  1. GET /v1/crypto/:id/buy/quote?cryptocurrency=BTC&quantity=0.1

RESPONSE

  1. {
  2.     "id": "qtn-e1435a7c-c809-455e-a210-8a4b0242b48f",
  3.     "cryptoCurrency": "BTC",
  4.     "quotedCurrency": "USD",
  5.     "quantity": "0.1",
  6.     "amount": "4601.71",
  7.     "price": "46017.16",
  8.     "expires": "2022-04-01T01:05:21Z"
  9. }

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

  1. GET /v1/crypto/:id/buy/quote?cryptocurrency=BTC&amount=4601.71

RESPONSE

  1. {
  2.     "id": "qtn-e1435a7c-c809-455e-a210-8a4b0242b48f",
  3.     "cryptoCurrency": "BTC",
  4.     "quotedCurrency": "USD",
  5.     "quantity": "0.1",
  6.     "amount": "4601.71",
  7.     "price": "46017.16",
  8.     "expires": "2022-04-01T01:05:21Z"
  9. }

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

  1. POST /v1/crypto/:id/buy

REQUEST

  1. {
  2.     "quoteId": "{{quoteId}}",
  3.     "accountId": "{{accountId}}",
  4.     "description": "buy crypto"
  5. }

RESPONSE

  1. {
  2.     "id": "cpt-7fd29184-2e12-4d11-b644-17dbf954ca8a",
  3.     "title": "Crypto Buy Transfer",
  4.     "description": "crypto buy one",
  5.     "cryptoCurrency": "BTC",
  6.     "accountId": "acc-a575f9fb-9283-4c9d-b4fc-77e3c3a36203",
  7.     "walletId": "",
  8.     "quotedCurrency": "USD",
  9.     "quotedPrice": "45839.55",
  10.     "quoteId": "qtn-2804617f-b56f-4ebd-844d-3bfafdd7aee9",
  11.     "quantity": "0.00218152",
  12.     "amount": "100.00",
  13.     "destinationCryptoAddress": "",
  14.     "gasFee": "",
  15.     "txnType": "debit",
  16.     "status": "completed",
  17.     "createdAt": "2022-04-01T01:15:26Z",
  18.     "modifiedAt": "2022-04-01T01:15:26Z",
  19.     "transferredAt": "2022-04-01T01:15:26Z",
  20.     "metadata": null
  21. }