Sell Crypto

Information on selling a supported cryptocurrency to USD
Crypto
Sell Crypto
 last updated: 
July 18, 2022

There are 2 steps to using the Sell Crypto API:

1. Get a Quote to Sell Crypto (valid for 30 seconds)
2. Execute the Sell Crypto (within 30 seconds of the quote)

Step 1: Get a Quote to Buy Crypto

You can request for a quote by specifying the Quantity in the cryptocurrency or Amount in USD. There are 2 methods to get a Quote to Sell Crypto:

Method 1: Quote to Sell Crypto by Quantity (in cryptocurrency). Quote responds with the Price in USD.

REQUEST

  1. GET /v1/crypto/:id/sell/quote?cryptoCurrency=BTC&quantity=0.1

Where:
- :id = {{walletId}}
- cryptoCurrency = one of the cryptocurrencies supported (ex: BTC)
- quantity = quantity of the Cryptocurrency (ex: 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 sell 0.1 BTC, the Amount is USD 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: Quote to Sell Crypto by Amount (in USD). Quote responds with the Quantity in Cryptocurrency.

REQUEST

  1. GET /v1/crypto/:id/sell/quote?cryptoCurrency=BTC&amount=4601.71

Where:
- :id = {{walletId}}
- cryptoCurrency = one of the cryptocurrencies supported (ex: BTC)
- amount = amount in USD (ex: 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 sell 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 Sell Crypto

In Step 1, you get a quoteId that is valid for 30 seconds. You can execute the Sell Crypto inside the 30 seconds, else it times out and you 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/sell

REQUEST

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

RESPONSE

  1. {
  2.     "id": "cpt-7fd29184-2e12-4d11-b644-17dbf954ca8a",
  3.     "title": "Crypto Sell Transfer",
  4.     "description": "crypto sell 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": "credit",
  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. }