> ## Documentation Index
> Fetch the complete documentation index at: https://anypay-docs-update-resources-2026-06-29.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Trails API SDK

> TypeScript/JavaScript client for the Trails API

## Installation

Install the Trails API client SDK:

<CodeGroup>
  ```shell pnpm theme={null}
  pnpm install @0xtrails/api
  ```

  ```shell npm theme={null}
  npm install @0xtrails/api
  ```

  ```shell yarn theme={null}
  yarn add @0xtrails/api
  ```

  ```shell bun theme={null}
  bun add @0xtrails/api
  ```
</CodeGroup>

## Quick Start

Import and initialize the client with your API key:

```typescript theme={null}
import { TrailsApi } from '@0xtrails/api'

const trailsApi = new TrailsApi('YOUR_API_KEY')
```

<Note>
  **Get an API key**: Sign up and create an API key on the [Trails Dashboard](https://dashboard.trails.build/landing)
</Note>

## Usage Example

The SDK provides fully typed methods for all Trails API endpoints:

```typescript theme={null}
import { TradeType, TrailsApi, RouteProvider } from '@0xtrails/api'

// Request a quote
const quoteResponse = await trailsApi.quoteIntent({
    ownerAddress: '0x0709CF2d5D4f3D38f5948d697fE64d7FB3639Eb1',
    originChainId: 42161, // Arbitrum One
    originTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', // USDC
    originTokenAmount: 100000000n, // 100 USDC
    destinationChainId: 8453, // Base
    destinationTokenAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
    destinationToAddress: '0x0709CF2d5D4f3D38f5948d697fE64d7FB3639Eb1',
    tradeType: TradeType.EXACT_INPUT,
    options: {
        slippageTolerance: 0.005,
        bridgeProvider: RouteProvider.RELAY
    }
})

// Commit the intent
const { intentId } = await trailsApi.commitIntent({
  intent: quoteResponse.intent
})

// Execute the intent
await trailsApi.executeIntent({
  intentId
})

// Monitor completion
const receipt = await trailsApi.waitIntentReceipt({ intentId })
```

## TypeScript Support

The SDK is written in TypeScript and includes complete type definitions for all methods, request parameters, and response objects. You'll get full autocomplete and type checking in your IDE.

## API Reference

All SDK methods correspond directly to the Trails API endpoints. For detailed information about request parameters, response formats, and advanced options, refer to the endpoint documentation:

* [QuoteIntent](/api-reference/endpoints/quote-intent) - Get quotes for cross-chain transactions
* [CommitIntent](/api-reference/endpoints/commit-intent) - Lock in rates
* [ExecuteIntent](/api-reference/endpoints/execute-intent) - Execute transactions
* [WaitIntentReceipt](/api-reference/endpoints/wait-intent-receipt) - Monitor completion
* [GetIntent](/api-reference/endpoints/get-intent) - Retrieve intent details
* [GetIntentReceipt](/api-reference/endpoints/get-intent-receipt) - Get transaction receipt
* [SearchIntents](/api-reference/endpoints/search-intents) - Search and filter intents
* [GetIntentHistory](/api-reference/endpoints/get-intent-history) - Get transaction history with receipts
* [GetTokenPrices](/api-reference/endpoints/get-token-prices) - Get current token prices
