Authentication

How to authenticate with the Lavarage API.

API Key Authentication

The Lavarage API uses API keys passed via the x-api-key HTTP header.

curl https://api.lavarage.xyz/api/v1/positions \
  -H "x-api-key: YOUR_API_KEY"

Public Endpoints (No Key Required)

These endpoints are freely accessible:

EndpointDescription
GET /healthService health check
GET /api/v1/offersBrowse liquidity pools
GET /api/v1/offers/utilizationPool utilization metrics
GET /api/v1/offers/:publicKeySingle offer details
GET /api/v1/tokensToken list with prices
GET /api/v1/tokens/:addressSingle token details
POST /api/v1/offers/matchMatch best offer for token pair
GET /api/v1/offers/topTop tokens by activity
GET /api/v1/offers/latestLatest tokens
POST /api/v1/offers/resolve-feedResolve Switchboard oracle feed
GET /api/v1/referral/*Referral read endpoints

Protected Endpoints (Key Required)

All position, order, staking, and partner management endpoints require a valid API key.

Getting an API Key

  1. Contact the team at lavarage.io to get a partner account
  2. Use the Partners API to generate additional keys:
curl -X POST https://api.lavarage.xyz/api/v1/partners/keys \
  -H "x-api-key: YOUR_EXISTING_KEY"

The raw key is only returned once — store it securely.

Key Management

  • List keys: GET /api/v1/partners/keys
  • Revoke a key: DELETE /api/v1/partners/keys/:id

Revoking a key is permanent and immediate.

Security Best Practices

  • Never expose API keys in client-side code
  • Use environment variables for key storage
  • Rotate keys periodically using the Partners API
  • Revoke compromised keys immediately

Wallet Signature Authentication

Some endpoints (orders, referral) require wallet signature authentication via 3 headers:

HeaderValue
x-wallet-addressYour Solana wallet address (base58)
x-wallet-signatureEd25519 signature of the message (base58)
x-wallet-messageThe signed message: lavarage:<wallet>:<timestamp_ms>

Message Format

```
lavarage:<wallet_address>:<timestamp_ms>
```

TypeScript Example

```typescript
import nacl from 'tweetnacl';
import bs58 from 'bs58';

const wallet = keypair; // Your Solana Keypair
const timestamp = Date.now().toString();
const message = `lavarage:${wallet.publicKey.toBase58()}:${timestamp}`;
const messageBytes = new TextEncoder().encode(message);
const signature = nacl.sign.detached(messageBytes, wallet.secretKey);

const headers = {
'x-wallet-address': wallet.publicKey.toBase58(),
'x-wallet-signature': bs58.encode(signature),
'x-wallet-message': message,
};
```