This tutorial shows you how to execute a quote previously received from the Liquidity Hub API to trade digital assets. You will learn about the requests and responses your integration must handle to execute a quote that specifies the price of selling 1 Bitcoin (BTC) in exchange for US Dollars (USD).
/quotes/executeendpoint is protected by Bearer authentication. To successfully call this endpoint, you must include a valid Bearer authentication token in the request header. For more information, see the Get an authentication token tutorial.
- You must have the quote ID of the quote you want to execute. Your integration should process the response received from the
/quotes/requestendpoint and get the value of the
quoteIdfield. For more information, see the Request a quote tutorial.
- The quote you want to execute must be valid. That is, the current time must be earlier than the time specified by the expiresAt field in the quote you received from the
POST /quotes/executeoperation accepts a body parameter containing the
quoteIdof the quote you want to execute and an optional
side. Let's take a closer look at these fields. Click to expand each section:
Quote IDEach quote is identified is by its unique
quoteId. This field is part of the
Quoteobject returned by the
/quotes/requestendpoint.To execute a quote, your integration should first process the response received from the
/quotes/requestendpoint and get the
sidefield indicates whether you want to buy or sell the
baseAssetin the trade.You must specify this field only if you are executing a two-way quote, that is, if the value of the
TWO_WAYin the quote you received. You do not need to specify the
sidefield if you are executing a quote where the value of the
SELL.In this example you are executing a quote with
SELL, so you do not need to specify the
quoteIdin the request body:
- "quoteId": "fd5dbe64-a96e-4e1c-9843-75cd6b0cdb60"
Tradeobject in the response confirms that your request to execute a quote was successful.Let's take a closer look at some of the
|The unique ID that identifies the trade. You can use this ID to retrieve this trade later for reconciliation purposes using the Retrieve a specific trade operation.|
|The price at which you traded one unit of |
|The quantity of the |
|The quantity of the |
|The time at which this trade was executed.|
|The unique ID of the quote that you executed to complete this trade.|
- "tradeId": "065e2c46-be89-4fe2-9d16-ce9afeca50b7",
- "price": "51345.76",
- "baseAsset": "BTC",
- "quoteAsset": "USD",
- "baseAssetQty": "1.00000000",
- "quoteAssetQty": "51345.76",
- "side": "SELL",
- "endUserGuid": "669ce446-22d0-11ec-9621-0242ac130002",
- "timestamp": "2021-01-01T01:05:30.000Z",
- "quoteId": "fd5dbe64-a96e-4e1c-9843-75cd6b0cdb60",
- "fundSource": "FUNDED"
500error code from the Liquidity Hub API.
Here are some recommendations for error handling:
|Error code||Name||Recommended error handling|
|Your request may be missing required header or body parameters. Inspect your request and retry the request.|
|Your Bearer authentication token may be invalid or expired. Verify that the authentication token is not truncated or past the token expiry period. Retry the request again with a valid authentication token.|
|The base URL in your request could be incorrect. Retry the request with the correct base URL.|
|No handler found for POST|
|The service is temporarily unavailable. Retry the request later.|