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

# Advanced Usage

> Automatic retries, rate limiting, raw requests, health checks, and TypeScript types in the Triqai SDK

## Automatic Retries

The SDK automatically retries on transient errors (429, 500, 503, 504, and network errors) with exponential backoff.

**Retry behavior:**

* `GET` and `DELETE` requests are always retried
* `POST` requests are only retried when an `idempotencyKey` is provided
* The `Retry-After` header is respected when present
* Defaults: 3 retries, 500ms base delay, 30s max delay

Disable retries entirely:

```typescript theme={null}
const triqai = new Triqai("triq_your_api_key", { maxRetries: 0 });
```

## Rate Limiting

Rate limit information is available on successful responses. The SDK handles 429 responses automatically, but you can monitor usage:

```typescript theme={null}
// Via the debug hook
const triqai = new Triqai("triq_your_api_key", {
  onResponse: (info) => {
    // info.headers contains X-RateLimit-* values
  },
});

// Via raw requests
const resp = await triqai.rawGet("/v1/categories");
console.log(resp.rateLimitInfo.remaining);           // tokens left
console.log(resp.rateLimitInfo.limit);               // max tokens
console.log(resp.rateLimitInfo.concurrencyRemaining); // concurrent slots left
```

## Health & API Info

```typescript theme={null}
const health = await triqai.health();
console.log(health.data.status); // "healthy"

const info = await triqai.apiInfo();
console.log(info.data.version);   // "v1"
console.log(info.data.endpoints);
```

## Raw Requests

For endpoints not yet covered by a resource class, or when you need the full HTTP response (headers, rate limit info):

```typescript theme={null}
import type { HttpResponse } from "triqai";

const resp: HttpResponse<any> = await triqai.rawGet("/v1/categories");
console.log(resp.data);          // response body
console.log(resp.rateLimitInfo); // { limit, remaining, ... }
```

The client also exposes `rawPost` and `rawDelete` for other HTTP methods.

## TypeScript

The SDK is written in TypeScript and ships with complete type definitions. All request and response types are exported:

```typescript theme={null}
import type {
  EnrichRequest,
  EnrichSuccessResponse,
  EnrichedTransaction,
  MerchantData,
  LocationData,
  CategoryInfo,
  EntityResult,
  TransactionType,
  EnrichmentFieldPath,
} from "triqai";
```
