Skip to main content
Use this method to request a quote for fiat-to-crypto transactions. Quotes include fees and limits, and they expire after a short time window. A quote with executable: true can be used to execute a transaction.
Get a quote
import { createClient } from "@moonpay/platform-sdk-web";

const client = createClient({ sessionToken: "c3N0XzAwMQ==" });

const quoteResult = await client.getQuote({
  source: { asset: { code: "USD" }, amount: "100.00" },
  destination: { asset: { code: "ETH" } },
  wallet: { address: "0x1234567890123456789012345678901234567890" },
  paymentMethod: { type: "apple_pay" },
});

if (!quoteResult.ok) {
  // Handle error
  console.error(quoteResult.error.code, quoteResult.error.message);
  return;
}

console.log(quoteResult.value.data);

Parameters

client.getQuote() takes a single input object. The shape matches the Get quotes API request body — see that page for the complete field reference.
FieldTypeRequiredDescription
sourceobjectThe fiat side of the quote.
source.asset.codestringThe fiat currency code as ISO 4217 (for example, "USD").
source.amountstringThe amount to spend, as a string (for example, "100.00"). Set the amount on either source or destination, not both.
destinationobjectThe crypto side of the quote.
destination.asset.codestringThe crypto asset code the customer receives (for example, "ETH", "USDC_SOL").
destination.amountstringThe amount the customer receives, if known. Set the amount on either source or destination, not both.
walletobjectWhere the crypto is sent. Required for the quote to be executable.
wallet.addressstringThe destination wallet address.
wallet.tagstringAn optional memo or destination tag, used by some blockchains such as XRP or XLM.
paymentMethodobjectThe payment method to quote against. Required for the quote to be executable.
paymentMethod.typestringThe payment method type (for example, "apple_pay", "google_pay", "card").
paymentMethod.idstringThe stored payment method ID. Required when type is "card" to identify the specific card.
This method does not require a separate auth token. The client uses stored credentials from an active connection.

Result

client.getQuote() returns a Result<{ data: Quote }, GetQuoteError>.

Result envelope

Result<{ data: Quote }, GetQuoteError>
FieldTypeRequiredDescription
okbooleanWhether the operation succeeded.
value{ data: Quote }Present when ok is true.
errorGetQuoteErrorPresent when ok is false.

Quote

A quote includes a signature you use to execute a transaction, plus fees and limits. See the API reference for the full shape.
FieldTypeRequiredDescription
signaturestringA stringified JSON object that contains quote data and an embedded hash. Don’t deserialize this value. Use it as-is to execute a transaction.
expiresAtstringAn ISO 8601 timestamp for when the quote expires.
sourceobjectThe source (fiat) asset details.
destinationobjectThe destination (crypto) asset details.
walletobjectThe destination wallet details.
feesobjectFee details for the transaction.
executablebooleanWhether the quote can be used to execute a transaction. See the API reference for the request fields required to receive executable: true.

GetQuoteError

GetQuoteError is the standard MoonPay Platform API error shape, DevPlatformApiError.
FieldTypeRequiredDescription
codeDevPlatformApiErrorCodeA machine-readable error code (for example, "invalid_request", "unauthorized", "unprocessable_entity"). See the error reference for the full list.
messagestringA developer-friendly message.
errorsDevPlatformApiErrorDetail[]Optional list of field-level errors when the request fails validation. Each entry has a field and message.
types.ts
type DevPlatformApiErrorCode =
  | "unknown_error"
  | "unauthorized"
  | "forbidden"
  | "not_found"
  | "invalid_request"
  | "not_implemented"
  | "too_many_requests"
  | "not_allowed"
  | "conflict"
  | "unprocessable_entity"
  | "sse_timeout"
  | "sse_error"
  | "connection_required"
  | "connection_pending"
  | "connection_unavailable"
  | "service_unavailable"
  | "requirements_incomplete"
  | "verification_rejected"
  | "country_mismatch"
  | "unsupported_country";

type DevPlatformApiErrorDetail = {
  field?: string;
  message: string;
};

type GetQuoteError = {
  code: DevPlatformApiErrorCode;
  message: string;
  errors?: DevPlatformApiErrorDetail[];
};