Generating Quotes
Buy Quote
The Buy Quote API provides clients with a quote based on the asset the user would like to purchase, the network they plan to purchase it on, the dollar amount of the payment, the payment currency, the payment method, and country of the user.
Limitations
The quote provided by this API is an estimate only. It does not guarantee that the user will be able to complete their purchase using the returned quote. Depending on fluctuations in network fees and exchange rates, and whether or not the user chooses the logged in or guest checkout experience, the actual fees charged may be different.
Method
POST
URL
https://api.developer.coinbase.com/onramp/v1/buy/quote
Request Parameters
The Buy Quote API is an RPC endpoint that accepts parameters as JSON in the request body.
Name | Type | Req | Description |
---|---|---|---|
purchase_currency | Y | ID of the crypto asset the user wants to purchase. Retrieved from the options API. | |
purchase_network | N | Name of the network that the purchase currency should be purchased on. Retrieved from the options API. If omitted, the default network for the crypto currency is used. | |
payment_amount | String | Y | Fiat amount the user wants to spend to purchase the crypto currency, inclusive of fees with two decimals of precision, e.g., 100.00 . |
payment_currency | String | Y | Fiat currency of the payment amount, e.g., USD . |
payment_method | Y | ID of payment method used to complete the purchase. Retrieved from the options API. | |
country | Y | ISO 3166-1 two-digit country code string representing the purchasing user’s country of residence, e.g., US . | |
subdivision | N | ISO 3166-2 two-digit country subdivision code representing the purchasing user’s subdivision of residence within their country, e.g. NY . Required if the country=“US” because certain states (e.g., NY ) have state specific asset restrictions. |
Response Fields
The Buy Options API returns a JSON response including the following fields.
Name | Description |
---|---|
payment_total | Object with amount and currency of the total fiat payment required to complete the purchase, inclusive of any fees. The currency will match the payment_currency in the request if it is supported, otherwise it falls back to USD . |
payment_subtotal | Object with amount and currency of the fiat cost of the crypto asset to be purchased, exclusive of any fees. The currency will match the payment_total currency. |
purchase_amount | Object with amount and currency of the crypto that to be purchased. The currency will match the purchase_currency in the request. The number of decimals will be based on the crypto asset. |
coinbase_fee | Object with amount and currency of the fee changed by the Coinbase exchange to complete the transaction. The currency will match the payment_total currency. |
network_fee | Object with amount and currency of the network fee required to send the purchased crypto to the user’s wallet. The currency will match the payment_total currency. |
quote_id | Reference to the quote that should be passed into the initialization parameters when launching the Coinbase Onramp widget via the SDK or URL generator. |
Example Request/Response
- Request (cURL)
- Response 200 (JSON)
curl -X POST 'https://api.developer.coinbase.com/onramp/v1/buy/quote' \
-H "Authorization: Bearer $JWT" \
-d '{"purchase_currency": "BTC", "payment_amount": "100.00", "payment_currency": "USD", "payment_method": "CARD", "country": "US", "subdivision": "NY"}'
{
"data": {
"payment_total": {
"amount": "100.00",
"currency": "USD"
},
"payment_subtotal": {
"amount": "97.00",
"currency": "USD"
},
"purchase_amount": {
"amount": "10.00000000",
"currency": "BTC"
},
"coinbase_fee": {
"amount": "1.50",
"currency": "USD"
},
"network_fee": {
"amount": "1.50",
"currency": "USD"
},
"quote_id": "46da84dc-b6d7-11ed-afa1-0242ac120002"
}
}