Price an operation before creating the order
| Time | Status | User Agent | |
|---|---|---|---|
Retrieving recent requests… | |||
Prices an operation before it is created, so you can show your customer exactly what they will pay or receive and let them accept it.
A quote holds that price until expires_at. Pass its id as quote_id on Create Order and the order is created at the quoted price instead of the market price.
Quoting is optional: an order created without a quote_id is priced at market when it is created.
Request
POST /quotes
| Field | Type | Required | Description |
|---|---|---|---|
operation | string | Yes | buy, sell or send. |
asset | object | Yes | The crypto asset being bought, sold or sent. |
asset.currency | string | Yes | Asset currency, e.g. BTC. |
asset.amount | string | - | Amount of the asset. Send this or the amount on the operation node, never both. |
buy / sell | object | - | Carries settlement.currency and optionally settlement.amount. |
send | object | Yes for send | Carries destination and optionally network. |
send.destination.type | string | Yes for send | crypto_currency_address, lirium_customer or address_book. |
send.destination.amount | string | - | Amount that should reach the destination. |
The node key must match operation, and only one node may be sent.
Which amount to send
As on Create Order, you express the operation from either side, and exactly one side carries the amount:
buy—asset.amountto buy a fixed amount of crypto, orbuy.settlement.amountto spend a fixed amount of fiat.sell—asset.amountto sell a fixed amount of crypto, orsell.settlement.amountto receive a fixed amount of fiat.send—asset.amountto take a fixed amount out of the customer's balance, orsend.destination.amountto make a fixed amount arrive.
See Buy and Sell amounts and Send amounts for the same choice on orders.
A send quote needs no addressTo quote a
sendonlydestination.typeis required — the address itself (destination.value) is sent when the order is created. The quote prices the network and service fees for that kind of destination.
Example Requests
{
"operation": "buy",
"asset": {
"currency": "BTC",
"amount": "1"
}
}{
"operation": "buy",
"asset": {
"currency": "BTC"
},
"buy": {
"settlement": {
"currency": "USD",
"amount": "10000"
}
}
}{
"operation": "send",
"asset": {
"currency": "BTC",
"amount": "0.00119145"
},
"send": {
"destination": {
"type": "crypto_currency_address"
}
}
}Response
| Field | Type | Description |
|---|---|---|
id | string | Pass this as quote_id when creating the order. |
operation | string | The operation quoted. |
created_at | string | When the quote was created, ISO 8601. |
asset | object | The crypto side, with currency, amount and operation. |
buy / sell / send | object | The node matching operation. |
Both sides come back with an operation of credit or debit, read from the customer's point of view: on a buy the customer is credited the asset and debited the settlement, and on a sell it is the other way round.
Each node carries expires_at — the price holds until then. A send node also carries fees, the network and service fees included in the quote, in the asset currency; send.destination.amount is what actually arrives once those fees are taken off.
Example Response
{
"id": "cb2af049b9cf4642947436df461486c2",
"operation": "buy",
"created_at": "2020-11-02T22:49:02.000000+00:00",
"asset": {
"currency": "BTC",
"amount": "0.97087378",
"operation": "credit"
},
"buy": {
"expires_at": "2020-11-02T22:50:02.000000+00:00",
"settlement": {
"currency": "ARS",
"amount": "1566685.4",
"operation": "debit"
}
}
}{
"id": "52fcddd60e0140558dce3de971094950",
"operation": "send",
"created_at": "2021-12-02T18:09:39.432938+00:00",
"asset": {
"currency": "BTC",
"amount": "0.00119145",
"operation": "debit"
},
"send": {
"expires_at": "2021-12-02T18:14:39.432938+00:00",
"fees": "0.00002",
"destination": {
"type": "crypto_currency_address",
"amount": "0.00117145"
}
}
}Using the quote
{
"reference_id": "Abc123ed-F456Gh",
"quote_id": "cb2af049b9cf4642947436df461486c2",
"operation": "buy",
"asset": {
"currency": "BTC",
"amount": "0.97087378"
}
}
Quotes expireOnce
expires_athas passed the price is no longer held. Quote again rather than reusing an expiredquote_id.
Limits
swapcannot be quoted.operationonly takesbuy,sellandsend, and aswaporder carrying aquote_idis refused withQuote cannot be provided for this operation.- A quote cannot be combined with
asset.full_amounton order creation: the amount is only resolved when the order is created, so there is nothing to quote beforehand. See Create Order.
Error Responses
Error responses include error_code, error_msg, and a request_id field for tracking.
| Status | Error Code | Description |
|---|---|---|
| 400 | invalid_parameters | Missing, unknown, or malformed request fields (see error_msg for specifics) |
| 403 | forbidden | The application does not hold the write scope |
Examples of invalid_parameters conditions surfaced by error_msg:
{'operation': ['This field is required but was not found in the request.']}—operationis missing.Only one operation node is allowed— more than one ofbuy/sell/sendwas supplied.The operation node name must match the operation value (<operation>)— theoperationvalue does not match the node key in the body.asset.amount or settlement.amount is required/asset.amount or destination.amount is required— neither side carried an amount.Either asset.amount or settlement.amount can be sent, but not both/Either asset.amount or destination.amount can be sent, but not both— both sides carried an amount.
