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

# JavaScript SDK

> Use CubeStack with JavaScript and TypeScript.

# JavaScript SDK

Interact with the CubeStack API using JavaScript or TypeScript.

## Installation

```bash theme={null}
npm install @cubestack/sdk
```

## Quick Start

```javascript theme={null}
import { CubeStack } from '@cubestack/sdk';

const client = new CubeStack({
  apiKey: 'your-api-key',
  project: 'my-project'
});

// Fetch records
const { data, total } = await client.records.list('blog-posts', {
  page: 1,
  pageSize: 10,
  sort: 'created_at',
  order: 'desc'
});

// Create a record
const record = await client.records.create('blog-posts', {
  title: 'Hello World',
  content: 'My first post'
});

// Update a record
await client.records.update('blog-posts', record.id, {
  title: 'Updated Title'
});

// Delete a record
await client.records.delete('blog-posts', record.id);
```

## Filtering

```javascript theme={null}
const { data } = await client.records.list('blog-posts', {
  filters: {
    status: { eq: 'published' },
    views: { gt: 100 }
  }
});
```

## Error Handling

```javascript theme={null}
try {
  const record = await client.records.get('blog-posts', 999);
} catch (error) {
  if (error.status === 404) {
    console.log('Record not found');
  }
}
```
