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

# Errors

> API error codes and handling.

The API returns standard HTTP status codes along with JSON error bodies.

***

## Error Response Format

```json theme={"dark"}
{
  "detail": "Error message describing what went wrong"
}
```

For validation errors:

```json theme={"dark"}
{
  "detail": [
    {
      "loc": ["query", "limit"],
      "msg": "value is not a valid integer",
      "type": "type_error.integer"
    }
  ]
}
```

***

## HTTP Status Codes

| Code | Meaning | When It Occurs |
| - | - | - |
| `200` | Success | Request completed successfully |
| `400` | Bad Request | Invalid parameters or request body |
| `404` | Not Found | Resource does not exist |
| `422` | Unprocessable Entity | Validation error |
| `429` | Too Many Requests | Rate limit exceeded |
| `500` | Internal Server Error | Unexpected server error |
| `503` | Service Unavailable | Server is temporarily down |

***

## Common Errors

> [accordion] Market not found
>
> ```json theme={"dark"}
> {
>   "detail": "Market not found"
> }
> ```
>
> **Cause**: The market address doesn't exist in the database.
>
> **Solution**: Verify the market address is correct and that the market has been indexed.

> [accordion] Invalid address format
>
> ```json theme={"dark"}
> {
>   "detail": "Invalid market address format"
> }
> ```
>
> **Cause**: The provided address is not a valid Solana public key.
>
> **Solution**: Ensure addresses are valid base58-encoded Solana public keys.

> [accordion] Rate limit exceeded
>
> ```json theme={"dark"}
> {
>   "detail": "Rate limit exceeded. Try again in 60 seconds."
> }
> ```
>
> **Cause**: Too many requests from your IP address.
>
> **Solution**: Implement exponential backoff and respect the `Retry-After` header.

> [accordion] Validation error
>
> ```json theme={"dark"}
> {
>   "detail": [
>     {
>       "loc": ["query", "limit"],
>       "msg": "ensure this value is less than or equal to 1000",
>       "type": "value_error.number.not_le"
>     }
>   ]
> }
> ```
>
> **Cause**: Query parameter out of valid range.
>
> **Solution**: Check parameter limits in the API documentation.

***

## WebSocket Errors

WebSocket connections may be closed with specific codes:

| Code | Reason | Description |
| - | - | - |
| `1008` | Policy Violation | Rate limit or connection limit exceeded |
| `4000` | Invalid Filter | Activity WebSocket filter not provided or invalid |
| `4004` | Market Not Found | Market address doesn't exist |

***

## Handling Errors

> [tab] TypeScript
>
> ```typescript theme={"dark"}
> async function fetchMarket(address: string) {
>   const response = await fetch(`https://api.orica.markets/markets/${address}`);
>
>   if (!response.ok) {
>     const error = await response.json();
>
>     if (response.status === 404) {
>       throw new Error(`Market not found: ${address}`);
>     }
>
>     if (response.status === 429) {
>       const retryAfter = response.headers.get('Retry-After') || '60';
>       throw new Error(`Rate limited. Retry after ${retryAfter}s`);
>     }
>
>     throw new Error(error.detail || 'Unknown error');
>   }
>
>   return response.json();
> }
> ```

> [tab] Python
>
> ```python theme={"dark"}
> import httpx
>
> async def fetch_market(address: str):
>     async with httpx.AsyncClient() as client:
>         response = await client.get(f"https://api.orica.markets/markets/{address}")
>
>         if response.status_code == 404:
>             raise ValueError(f"Market not found: {address}")
>
>         if response.status_code == 429:
>             retry_after = response.headers.get("retry-after", "60")
>             raise Exception(f"Rate limited. Retry after {retry_after}s")
>
>         response.raise_for_status()
>         return response.json()
> ```

***

## Retry Strategy

For transient errors (429, 500, 503), implement exponential backoff:

```typescript theme={"dark"}
async function fetchWithRetry(url: string, maxRetries = 3): Promise<any> {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    try {
      const response = await fetch(url);
      
      if (response.status === 429 || response.status >= 500) {
        const delay = Math.pow(2, attempt) * 1000; // 1s, 2s, 4s
        await new Promise(r => setTimeout(r, delay));
        continue;
      }
      
      return response.json();
    } catch (error) {
      if (attempt === maxRetries - 1) throw error;
    }
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.