> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coinvoyage.io/llms.txt
> Use this file to discover all available pages before exploring further.

# ApiClient - server-side CoinVoyage REST API client

> Initialize ApiClient from @coin-voyage/paykit/server and navigate its order, wallet, swap, on-ramp, off-ramp, invoice, fee, webhook, and type references.

`ApiClient` is the server-side interface to the CoinVoyage v3 API. Import it from `@coin-voyage/paykit/server` and use it in API routes, server actions, or backend services. Every method returns an `APIResponse<T>` wrapper with either `data` or `error`.

<Warning>
  Keep your API secret on the server. The SDK can create `DEPOSIT` orders with the public API key, but `SALE`, refunds, list operations, off-ramp operations, invoices, webhooks, and fees require a server-generated authorization signature.
</Warning>

## Initialization

```typescript theme={null}
import { ApiClient, ChainId, ChainType } from "@coin-voyage/paykit/server";

const apiClient = ApiClient({
  apiKey: process.env.COIN_VOYAGE_API_KEY!,
  environment: "production",
});
```

<ParamField path="apiKey" type="string" required>
  Your organization's API key from the [CoinVoyage dashboard](https://dashboard.coinvoyage.io/developers).
</ParamField>

<ParamField path="environment" type="string" default="production">
  API environment. Accepted values are `"production"`, `"development"`, and `"local"`.
</ParamField>

| Environment   | Base URL                           |
| ------------- | ---------------------------------- |
| `production`  | `https://api.coinvoyage.io/v3`     |
| `development` | `https://acc-api.coinvoyage.io/v3` |
| `local`       | `http://localhost:8000/v3`         |

## `APIResponse<T>`

Every `ApiClient` method returns a `Promise<APIResponse<T>>`:

```typescript theme={null}
type APIResponse<T> = {
  data?: T
  error?: {
    path: string
    statusCode: number
    status: string
    message: string
    details?: unknown
  }
}
```

Check `error` before using `data`:

```typescript theme={null}
const { data, error } = await apiClient.getOrder("order_123");

if (error) {
  console.error(error.statusCode, error.message);
  return;
}

console.log(data?.status);
```

## Reference

<CardGroup cols={2}>
  <Card title="Authentication" icon="key" href="/sdk/apiclient/authentication">
    Generate server-side signatures for privileged operations.
  </Card>

  <Card title="Orders" icon="receipt" href="/sdk/apiclient/orders">
    Create orders, retrieve quotes, and generate payment instructions.
  </Card>

  <Card title="Wallet and search" icon="wallet" href="/sdk/apiclient/wallets-and-search">
    Search currencies and retrieve multi-wallet portfolios.
  </Card>

  <Card title="Swaps" icon="arrows-rotate" href="/sdk/apiclient/swaps">
    Quote and execute standalone swaps.
  </Card>

  <Card title="On-ramp" icon="credit-card" href="/sdk/apiclient/on-ramp">
    Integrate Stripe Link and embedded card-funded on-ramp flows.
  </Card>

  <Card title="Off-ramp" icon="building-columns" href="/sdk/apiclient/off-ramp">
    Manage verification, bank accounts, and fiat payout intents.
  </Card>

  <Card title="Invoices" icon="file-invoice" href="/sdk/apiclient/invoices">
    Create, publish, list, retrieve, archive, and delete invoice drafts.
  </Card>

  <Card title="Fees" icon="coins" href="/sdk/apiclient/fees">
    Retrieve and claim organization fee balances.
  </Card>

  <Card title="Webhooks and WebSockets" icon="webhook" href="/sdk/apiclient/webhooks-and-websockets">
    Manage webhook subscriptions and consume real-time order events.
  </Card>

  <Card title="Core types" icon="brackets-curly" href="/sdk/apiclient/types">
    Reference shared order, status, payment, and funding types.
  </Card>
</CardGroup>
