Skip to main content

Documentation Index

Fetch the complete documentation index at: https://dev.moonpay.com/llms.txt

Use this file to discover all available pages before exploring further.

Use this function to request an executable quote for fiat->crypto transactions. Quotes include fees and limits, and they expire after a short time window.
Get a quote
import { createClient } from "@moonpay/platform";

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

if (!clientResult.ok) {
  // Handle error
}

const client = clientResult.value;

const quoteResult = await client.getQuote({
  source: "USD",
  destination: "ETH",
  sourceAmount: "100.00",
  walletAddress: "0x1234567890123456789012345678901234567890",
  paymentMethod: "apple_pay",
});

if (!quoteResult.ok) {
  // Handle error
}

console.log(quoteResult.value);

Parameters

client.getQuote() takes a single input object. See the Get quotes API for full details.
FieldTypeRequiredDescription
sourcestringThe fiat asset code used for payment (e.g., "USD", "EUR").
destinationstringThe crypto asset code the customer receives (e.g., "ETH", "BTC").
sourceAmountstringThe amount to purchase, as a string (for example, "100.00").
walletAddressstringThe destination wallet address.
paymentMethodstringThe payment method type to use for the quote (e.g., "apple_pay").
This method does not require an accessToken parameter. The client uses stored credentials from an active connection.

Result

client.getQuote() returns a Result<Quote, GetQuoteError>.

Result envelope

Result<Quote, GetQuoteError>
FieldTypeRequiredDescription
okbooleanWhether the operation succeeded.
valueQuotePresent 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 details.
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.

GetQuoteError

FieldTypeRequiredDescription
kind"validationError" | "genericError"The error category.
messagestringDeveloper-friendly details.
types.ts
type GetQuoteError = {
  kind: "validationError" | "genericError";
  message: string;
};