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

# REST SDK

> Typed server-side SDK for Para REST wallets and signing

`@getpara/rest-sdk` is Para's typed SDK for REST API wallets. Use it from trusted backend code when your server owns
API-key-backed wallet creation, lookup, signing, transfers, and transaction history.

<Warning>
  This SDK sends your partner API key as `X-API-Key`. Never import it from browser, React, mobile, wagmi, RainbowKit,
  or any user-controlled runtime.
</Warning>

## Install

```bash theme={null}
yarn add @getpara/rest-sdk
```

The core client works in Node.js 18+ or any server runtime where you inject `fetch`.

Install adapter peers only when you use those subpaths:

```bash theme={null}
yarn add ethers
yarn add viem
yarn add @solana/addresses @solana/keys @solana/signers @solana/transactions
```

## Choose the Right SDK

| Use case                                                                             | Package                                          |
| ------------------------------------------------------------------------------------ | ------------------------------------------------ |
| API-key-backed programmatic wallets, REST pregen wallets, typed REST signing         | `@getpara/rest-sdk`                              |
| Share-backed server flows, imported user sessions, `migrateWalletShare()` encryption | `@getpara/server-sdk`                            |
| User authentication, wallet UI, browser/mobile signing                               | Web, React, React Native, Swift, or Flutter SDKs |

## Core Client

```ts theme={null}
import { ParaRestClient, ParaRestError } from '@getpara/rest-sdk';

const para = new ParaRestClient({
  apiKey: process.env.PARA_API_KEY!,
  env: 'BETA',
});

const wallet = await para.createWallet(
  {
    type: 'EVM',
    userIdentifier: 'user@test.getpara.com',
    userIdentifierType: 'EMAIL',
  },
  { idempotencyKey: crypto.randomUUID() },
);

const signature = await para.signMessage(wallet.id, { message: 'hello' });
```

`env` accepts `PROD`, `BETA`, or `{ baseUrl }`. Each request sends `X-API-Key` and `X-Request-Id`.
`Idempotency-Key` is caller-supplied; the SDK does not retry requests or generate idempotency keys internally.
Pass `AbortSignal` per call when your server needs a request deadline:

```ts theme={null}
await para.getWallet(wallet.id, {
  signal: AbortSignal.timeout(10_000),
});
```

## Adapters

```ts theme={null}
import { createParaRestEthersSigner } from '@getpara/rest-sdk/ethers';
import { createParaRestViemAccount } from '@getpara/rest-sdk/viem';
import { createParaRestSolanaSigner } from '@getpara/rest-sdk/solana';

const ethersSigner = createParaRestEthersSigner({ client: para, walletId, address });
const viemAccount = createParaRestViemAccount({ client: para, walletId, address: address as `0x${string}` });
const solanaSigner = createParaRestSolanaSigner({ client: para, walletId: solanaWalletId, address: solanaAddress });
```

EVM message and typed-data signing send unhashed payloads to REST. Para hashes EIP-191 and EIP-712 payloads
server-side. EVM transaction adapters support ordinary legacy and EIP-1559 sends; they reject contract deployments,
access lists, blob transactions, authorization-list transactions, and custom viem serializers before calling REST.
With viem, string messages are treated as text. Pass `{ raw: bytes }` when a `0x...` value should be signed as bytes.

The Solana adapter implements Solana v2 signer traits by signing message bytes through `sign-raw`. For broadcasted
transactions, call `para.signTransaction(walletId, { transaction, broadcast: true })` or `para.transfer(...)`.

## Errors

`ParaRestValidationError` is thrown before `fetch` for missing local required fields or unsupported adapter inputs.
`ParaRestSerializationError` means the request body cannot be JSON serialized. HTTP errors become `ParaRestError` with
`status`, `code`, `requestId`, and parsed `body`.

```ts theme={null}
try {
  await para.getWallet(wallet.id);
} catch (error) {
  if (error instanceof ParaRestError) {
    console.error(error.status, error.code, error.requestId, error.body);
  }
}
```

## Example

The typed SDK example creates REST wallets and demonstrates core client, ethers, viem, and Solana adapters:

```bash theme={null}
cd examples-hub/server/rest-with-typed-sdk
cp .env.example .env
yarn install
yarn dev
```

Use `examples-hub/server/rest-with-node` when you want to inspect the raw HTTP baseline.

## Trust Boundary

REST signing uses the wallet ID and your partner API key. Your backend is responsible for deciding which end user or
job is allowed to request a wallet operation before calling Para. The SDK validates local required fields and normalizes
adapter inputs, but it does not independently reconstruct or audit every signed transaction returned by REST.

## Non-goals

The REST SDK does not include browser connectors, React hooks, wagmi or RainbowKit integration, mobile auth, hosted UI,
client-side sessions, automatic retries, or user-share encryption helpers. Use `@getpara/server-sdk` for
`migrateWalletShare()` and share-backed server flows.
