> ## 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.

# client.getQuote()

> Request a quote for a transaction.

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.

```ts Get a quote theme={null}
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](/api-reference/platform/endpoints/quotes/get) request body — see that page for the complete field reference.

| Field                    | Type     | Required | Description                                                                                                               |
| ------------------------ | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------- |
| `source`                 | `object` | ✅        | The fiat side of the quote.                                                                                               |
| `source.asset.code`      | `string` | ✅        | The fiat currency code as [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) (for example, `"USD"`).                      |
| `source.amount`          | `string` |          | The amount to spend, as a string (for example, `"100.00"`). Set the amount on either `source` or `destination`, not both. |
| `destination`            | `object` | ✅        | The crypto side of the quote.                                                                                             |
| `destination.asset.code` | `string` | ✅        | The crypto asset code the customer receives (for example, `"ETH"`, `"USDC_SOL"`).                                         |
| `destination.amount`     | `string` |          | The amount the customer receives, if known. Set the amount on either `source` or `destination`, not both.                 |
| `wallet`                 | `object` |          | Where the crypto is sent. Required for the quote to be `executable`.                                                      |
| `wallet.address`         | `string` | ✅        | The destination wallet address.                                                                                           |
| `wallet.tag`             | `string` |          | An optional memo or destination tag, used by some blockchains such as XRP or XLM.                                         |
| `paymentMethod`          | `object` |          | The payment method to quote against. Required for the quote to be `executable`.                                           |
| `paymentMethod.type`     | `string` | ✅        | The payment method type (for example, `"apple_pay"`, `"google_pay"`, `"card"`).                                           |
| `paymentMethod.id`       | `string` |          | The 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>`

| Field   | Type                              | Required | Description                      |
| ------- | --------------------------------- | -------- | -------------------------------- |
| `ok`    | `boolean`                         | ✅        | Whether the operation succeeded. |
| `value` | `{ data:` [`Quote`](#quote) `}`   |          | Present when `ok` is `true`.     |
| `error` | [`GetQuoteError`](#getquoteerror) |          | Present when `ok` is `false`.    |

### `Quote`

A quote includes a `signature` you use to execute a transaction, plus fees and limits. See the [API reference](/api-reference/platform/endpoints/quotes/get) for the full shape.

| Field         | Type      | Required | Description                                                                                                                                                                                  |
| ------------- | --------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `signature`   | `string`  | ✅        | A stringified JSON object that contains quote data and an embedded hash. Don't deserialize this value. Use it as-is to execute a transaction.                                                |
| `expiresAt`   | `string`  | ✅        | An [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp for when the quote expires.                                                                                                  |
| `source`      | `object`  | ✅        | The source (fiat) asset details.                                                                                                                                                             |
| `destination` | `object`  | ✅        | The destination (crypto) asset details.                                                                                                                                                      |
| `wallet`      | `object`  | ✅        | The destination wallet details.                                                                                                                                                              |
| `fees`        | `object`  | ✅        | Fee details for the transaction.                                                                                                                                                             |
| `executable`  | `boolean` | ✅        | Whether the quote can be used to execute a transaction. See the [API reference](/api-reference/platform/endpoints/quotes/get) for the request fields required to receive `executable: true`. |

### `GetQuoteError`

`GetQuoteError` is the standard MoonPay Platform API error shape, `DevPlatformApiError`.

| Field     | Type                          | Required | Description                                                                                                                                                                                                     |
| --------- | ----------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `code`    | `DevPlatformApiErrorCode`     | ✅        | A machine-readable error code (for example, `"invalid_request"`, `"unauthorized"`, `"unprocessable_entity"`). See the [error reference](/api-reference/platform/documentation/using-the-api) for the full list. |
| `message` | `string`                      | ✅        | A developer-friendly message.                                                                                                                                                                                   |
| `errors`  | `DevPlatformApiErrorDetail[]` |          | Optional list of field-level errors when the request fails validation. Each entry has a `field` and `message`.                                                                                                  |

<Accordion title="TS Definition">
  ```ts types.ts theme={null}
  type DevPlatformApiErrorCode =
    | "unknown_error"
    | "unauthorized"
    | "forbidden"
    | "not_found"
    | "invalid_request"
    | "not_implemented"
    | "too_many_requests"
    | "not_allowed"
    | "conflict"
    | "unprocessable_entity"
    | "sse_timeout"
    | "sse_error"
    | "service_unavailable"
    | "requirements_incomplete"
    | "verification_rejected"
    | "country_mismatch"
    | "unsupported_country";

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

  type GetQuoteError = {
    code: DevPlatformApiErrorCode;
    message: string;
    errors?: DevPlatformApiErrorDetail[];
  };
  ```
</Accordion>
