diff --git a/references/sdk/actions/getQuote.mdx b/references/sdk/actions/getQuote.mdx index a55715f..d867580 100644 --- a/references/sdk/actions/getQuote.mdx +++ b/references/sdk/actions/getQuote.mdx @@ -8,8 +8,12 @@ description: Get a quote for a crosschain relay (bridge, swap, call, etc) | Property | Description | Required | | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- | | **parameters** | Quote parameters defined below | ✅ | -| **includeDefaultParameters** | Setting this to true will include default parameters, which include user and recipient. These parameters are based on the wallet and fallback to the dead address if the wallet is missing. | ✅ | +| **includeDefaultParameters** | Setting this to true will include default parameters, which include user and recipient. These parameters are based on the wallet and fallback to the dead address if the wallet is missing. | ❌ | +| **headers** | Custom headers to pass along with the quote request, such as `x-api-key` for authentication. | ❌ | + +**Warning**: Never pass `x-api-key` in headers from client-side code. Only use the `headers` parameter with API keys when calling `getQuote` entirely on the server. + ### Quote Parameters @@ -96,4 +100,23 @@ const quote = await getClient()?.actions.getQuote({ }); ``` +### Server-Side Example with API Key + +```typescript +// Server-side only - pass API key via headers +const quote = await getClient()?.actions.getQuote( + { + chainId: 1, + toChainId: 10, + currency: "0x0000000000000000000000000000000000000000", + toCurrency: "0x0000000000000000000000000000000000000000", + amount: "10000000000000000", // 0.01 ETH + user: "WALLET_ADDRESS", + recipient: "RECIPIENT_ADDRESS", + }, + false, + { "x-api-key": process.env.RELAY_API_KEY } +); +``` + **Note** - Quotes are revalidated when being filled, clients should regularly fetch fresh quotes so that users are always submitting up to date quotes. See [Getting a quote](/how-it-works/the-relay-solver#getting-a-quote) for more information on how quotes work. diff --git a/references/sdk/createClient.mdx b/references/sdk/createClient.mdx index 6a4a415..b6ecf05 100644 --- a/references/sdk/createClient.mdx +++ b/references/sdk/createClient.mdx @@ -8,7 +8,8 @@ This method is used to create the Relay client globally in your application. The | Property | Description | Required | | ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -| **baseApiUrl** | The base api url to use when making requests, you can use the `MAINNET_RELAY_API` or the `TESTNET_RELAY_API` constants exported by the package. | ✅ | +| **baseApiUrl** | The base API url to use when making requests. You can use the `MAINNET_RELAY_API` or the `TESTNET_RELAY_API` constants exported by the package, or pass in your own proxy API url to protect your API key on the client. | ✅ | +| **apiKey** | A Relay API key to use when making requests. Only pass in this property when the Relay client instance is used exclusively server-side. Otherwise you'll leak your key to the client. | ❌ | | **chains** | A list of Relay Chains, by default a list of backup chains is configured | ❌ | | **source** | The source to associate your onchain activity with, should make to a domain | ❌ | | **logLevel** | The level at which to log, refer to the `LogLevel` enum exported by the package | ❌ |