Skip to main content

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.

NameTypeReqDescription
purchase_currencyYID of the crypto asset the user wants to purchase. Retrieved from the options API.
purchase_networkNName 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_amountStringYFiat amount the user wants to spend to purchase the crypto currency, inclusive of fees with two decimals of precision, e.g., 100.00.
payment_currencyStringYFiat currency of the payment amount, e.g., USD.
payment_methodYID of payment method used to complete the purchase. Retrieved from the options API.
countryYISO 3166-1 two-digit country code string representing the purchasing user’s country of residence, e.g., US.
subdivisionNISO 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.

NameDescription
payment_totalObject 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_subtotalObject 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_amountObject 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_feeObject 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_feeObject 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_idReference 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

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"}'

Was this helpful?