# Node.js SDK — Full API Reference

> Complete @aerostack/sdk API reference — all methods for database, auth, AI, realtime, cache, queue, storage, and socket broadcast.

Complete method listing for `@aerostack/sdk`.

## sdk.db

| Method | Signature | Returns |
|--------|-----------|---------|
| `query` | `(sql: string, params?: any[]) => Promise<{ results: T[] }>` | Array of rows |
| `queryOne` | `(sql: string, params?: any[]) => Promise` | Single row or null |
| `exec` | `(sql: string) => Promise<void>` | Nothing |
| `batch` | `(stmts: { sql: string, params?: any[] }[]) => Promise<{ results: T[] }[]>` | Array of results |

## sdk.cache

| Method | Signature | Returns |
|--------|-----------|---------|
| `get` | `(key: string) => Promise` | Cached value or null |
| `set` | `(key: string, value: any, opts?: { ttl?: number, metadata?: any }) => Promise<void>` | Nothing |
| `delete` | `(key: string) => Promise<void>` | Nothing |
| `has` | `(key: string) => Promise<boolean>` | Boolean |

## sdk.storage

| Method | Signature | Returns |
|--------|-----------|---------|
| `upload` | `(opts: { file: File \| Blob, path?: string, contentType?: string }) => Promise<{ url, key, size, contentType }>` | Upload result |
| `delete` | `(key: string) => Promise<void>` | Nothing |

## sdk.ai

| Method | Signature | Returns |
|--------|-----------|---------|
| `complete` | `(opts: { prompt, model?, maxTokens?, temperature?, system?, messages? }) => Promise<{ text, usage, finishReason }>` | Completion result |
| `embed` | `(text: string) => Promise<number[]>` | Embedding vector |
| `streamCompletion` | `(opts: { prompt, model?, maxTokens? }) => Promise>` | Token stream |

## sdk.queue

| Method | Signature | Returns |
|--------|-----------|---------|
| `send` | `(type: string, payload: any, opts?: { delaySeconds?, maxRetries? }) => Promise<void>` | Nothing |

## sdk.search

| Method | Signature | Returns |
|--------|-----------|---------|
| `query` | `(vector: number[], opts: { table, limit?, threshold?, filter? }) => Promise` | Similar items |
| `upsert` | `(id: string, vector: number[], metadata?: any) => Promise<void>` | Nothing |
| `delete` | `(id: string) => Promise<void>` | Nothing |

## sdk.socket

| Method | Signature | Returns |
|--------|-----------|---------|
| `emit` | `(event: string, data: any, roomId: string) => void` | Nothing |

## sdk.secrets

| Method | Signature | Returns |
|--------|-----------|---------|
| `get` | `(key: string) => Promise<string \| null>` | Secret value or null |

## sdk.auth

| Method | Signature | Returns |
|--------|-----------|---------|
| `verifyToken` | `(token: string) => Promise` | User or null |
