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

# Development Basics

> Learn the fundamentals of working with Raze.bot APIs

## API Types

Raze.bot offers two API tiers:

### Router V3 (Public API)

* No authentication required for buy/sell
* 0.001 SOL minimum tip + 0.5% swap fee (deducted from transactions)
* Endpoints: `/swap/sol/buy`, `/swap/sol/sell`

### Premium API

* Requires API key (`Authorization: Bearer sk_...` or `X-API-Key: sk_...`)
* Endpoints: `/swap/sol/quote/:mint`, `/swap/sol/instructions`, `/api/sol/*`

## Authentication

### Router V3

No authentication needed. Fees are included in transactions.

```javascript theme={null}
// No API key required
const response = await fetch('https://router.raze.bot/swap/sol/buy', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    walletAddresses: ['...'],
    tokenAddress: '...',
    solAmount: 0.1
  })
});
```

### Premium API

Pass your API key via header or query parameter:

```javascript theme={null}
// API key required — via Authorization header
const response = await fetch(
  `https://router.raze.bot/swap/sol/quote/${mint}`, {
    headers: { 'Authorization': `Bearer ${apiKey}` }
  }
);

// Or via X-API-Key header
const response2 = await fetch(
  `https://router.raze.bot/swap/sol/quote/${mint}`, {
    headers: { 'X-API-Key': apiKey }
  }
);
```

## Response Format

All APIs return JSON with a consistent structure:

```json theme={null}
{
  "success": true,
  "data": { ... }
}
```

Error responses:

```json theme={null}
{
  "success": false,
  "error": "Error message",
  "message": "Detailed description"
}
```

## HTTP Status Codes

| Code | Description                               |
| :--- | :---------------------------------------- |
| 200  | Success                                   |
| 400  | Bad Request - Invalid parameters          |
| 401  | Unauthorized - Invalid or missing API key |
| 404  | Not Found - Resource doesn't exist        |
| 429  | Rate Limited - Too many requests          |
| 500  | Server Error - Internal error             |
| 504  | Gateway Timeout - Request timed out       |

## Transaction Flow

For swap operations, the typical flow is:

<Steps>
  <Step title="Request Transaction">
    Call the buy/sell endpoint to get unsigned transaction(s)
  </Step>

  <Step title="Sign Transaction">
    Sign the transaction with your wallet's private key
  </Step>

  <Step title="Send Transaction">
    Submit via the Raze Solana RPC relay (`POST /tx`) or any standard Solana RPC endpoint
  </Step>
</Steps>

## Best Practices

<AccordionGroup>
  <Accordion title="Secure Your Keys">
    * Store API keys in environment variables
    * Never expose private keys in code
    * Use `.gitignore` for sensitive files
  </Accordion>

  <Accordion title="Handle Errors">
    * Always check `success` field in responses
    * Implement retry logic with exponential backoff
    * Log errors for debugging
  </Accordion>

  <Accordion title="Optimize Performance">
    * Use the nearest server region
    * Cache quotes when appropriate
    * Batch transactions when possible
  </Accordion>

  <Accordion title="Manage Slippage">
    * Set appropriate slippage for volatile tokens
    * Default slippage is usually sufficient for stable pairs
    * Higher slippage for low-liquidity tokens
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Portal Setup" icon="key" href="/portal/setup">
    Get your Premium API key
  </Card>

  <Card title="Rate Limits" icon="gauge" href="/portal/rate-limit">
    Understand usage limits
  </Card>
</CardGroup>
