Combee

Quickstart

Create a Cell and run your first SQL query and KV operation in minutes.

since 0.1.0-beta

Prerequisites

You need a Combee account and an API key (cmb_sk_...). See Authentication to get one.

1. Install the SDK

npm install combee-js

2. Create a client

import { Combee } from 'combee-js';

const combee = new Combee({
  baseUrl: 'https://api.combee.cloud',
  apiKey: process.env.COMBEE_API_KEY!, // cmb_sk_...
});

3. Create a Cell

curl -X POST https://api.combee.cloud/v1/databases \
  -H "x-api-key: $COMBEE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: cell:blog-prod" \
  -d '{}'
# → {"id": "2f1c4a0e-..."} 保存 id,之后用它打开 Cell

4. Run SQL

curl -X POST https://api.combee.cloud/v1/databases/2f1c4a0e-.../sql \
  -H "x-api-key: $COMBEE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"sql": "CREATE TABLE IF NOT EXISTS posts (id INTEGER PRIMARY KEY, title TEXT NOT NULL)"}'

curl -X POST https://api.combee.cloud/v1/databases/2f1c4a0e-.../sql \
  -H "x-api-key: $COMBEE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"sql": "INSERT INTO posts (title) VALUES (?)", "params": ["Hello"]}'

curl -X POST https://api.combee.cloud/v1/databases/2f1c4a0e-.../sql \
  -H "x-api-key: $COMBEE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"sql": "SELECT * FROM posts WHERE id = ?", "params": [1]}'

5. Use KV

curl -X PUT https://api.combee.cloud/v1/databases/2f1c4a0e-.../kv/session:user:1 \
  -H "x-api-key: $COMBEE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"value": "{\"name\": \"Ada\"}", "ttl_seconds": 300}'

curl https://api.combee.cloud/v1/databases/2f1c4a0e-.../kv/session:user:1 \
  -H "x-api-key: $COMBEE_API_KEY"

curl -X POST https://api.combee.cloud/v1/databases/2f1c4a0e-.../kv/ops/incr \
  -H "x-api-key: $COMBEE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"key": "pageviews"}'

What's next

On this page