NW DB
/ NW DB ドキュメント

NW DB ドキュメント

NW DB API と機能の完全ガイド

はじめに

アカウント登録、ワークスペース作成、APIキー取得まで数分で完了します。

  1. 1. nwdb.dev/login でGoogleまたはメールでアカウントを作成します。
  2. 2. ダッシュボードからワークスペースを作成します。
  3. 3. 設定 > APIキーからAPIキーを作成します。
  4. 4. リクエストのX-API-Keyヘッダーにキーを指定します。

認証

NW DBは2つの認証方式をサポートしています:

  • Bearerトークン: AuthorizationヘッダーにFirebase IDトークンを指定
  • APIキー: X-API-Keyヘッダーに生成したキーを指定
shell
# Bearer token authentication
curl https://api.nwdb.dev/api/v1/tables \
  -H "Authorization: Bearer <FIREBASE_ID_TOKEN>" \
  -H "X-Workspace-ID: <WORKSPACE_ID>"

# API key authentication
curl https://api.nwdb.dev/api/v1/tables \
  -H "X-API-Key: nwdb_your_key_here" \
  -H "X-Workspace-ID: <WORKSPACE_ID>"

REST API

スキーマから自動生成されるREST API。CRUD、フィルタリング、ページネーション対応。

List Tables

shell
curl https://api.nwdb.dev/api/v1/tables \
  -H "X-API-Key: nwdb_xxx" \
  -H "X-Workspace-ID: ws_abc123"

Create Table

shell
curl -X POST https://api.nwdb.dev/api/v1/tables \
  -H "X-API-Key: nwdb_xxx" \
  -H "X-Workspace-ID: ws_abc123" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "customers",
    "columns": [
      { "name": "name", "type": "string", "required": true },
      { "name": "email", "type": "string", "required": true },
      { "name": "age", "type": "number" }
    ]
  }'

Create Record

shell
curl -X POST https://api.nwdb.dev/api/v1/records/customers/records \
  -H "X-API-Key: nwdb_xxx" \
  -H "X-Workspace-ID: ws_abc123" \
  -H "Content-Type: application/json" \
  -d '{ "name": "John", "email": "john@example.com", "age": 30 }'

List Records

shell
curl "https://api.nwdb.dev/api/v1/records/customers/records?limit=50&offset=0" \
  -H "X-API-Key: nwdb_xxx" \
  -H "X-Workspace-ID: ws_abc123"

Execute SQL

shell
curl -X POST https://api.nwdb.dev/api/v1/query \
  -H "X-API-Key: nwdb_xxx" \
  -H "X-Workspace-ID: ws_abc123" \
  -H "Content-Type: application/json" \
  -d '{ "sql": "SELECT * FROM customers WHERE age > 25 LIMIT 10" }'

ライブ分析

本番データに対するダッシュボード向け集計を、短期キャッシュ付きで返します。

shell
curl -X POST https://api.nwdb.dev/api/v1/query/live \
  -H "X-API-Key: nwdb_xxx" \
  -H "X-Workspace-ID: ws_abc123" \
  -H "Content-Type: application/json" \
  -d '{
    "table": "orders",
    "dimensions": ["status"],
    "metrics": [{ "column": "amount", "op": "sum", "alias": "sales" }],
    "cacheTtlSeconds": 30
  }'

MCP (Model Context Protocol)

Claude、Geminiなどの AIエージェントをデータベースに直接接続します。

Claude Desktop Config

json
{
  "mcpServers": {
    "nwdb": {
      "url": "https://api.nwdb.dev/api/v1/mcp",
      "headers": {
        "X-API-Key": "nwdb_your_key_here",
        "X-Workspace-ID": "your_workspace_id"
      }
    }
  }
}

Available Tools

ToolDescription
queryExecute SQL query
list_tablesList all tables
describe_tableGet table schema
live_analyticsRun cached aggregate queries
list_pipeline_proposalsReview approval pipeline proposals
insertInsert a record
search_vectorsSemantic similarity search

Execute MCP Tool via API

shell
curl -X POST https://api.nwdb.dev/api/v1/mcp/call \
  -H "X-API-Key: nwdb_xxx" \
  -H "X-Workspace-ID: ws_abc123" \
  -H "Content-Type: application/json" \
  -d '{
    "tool": "query",
    "arguments": { "sql": "SELECT * FROM customers LIMIT 5" }
  }'

リアルタイム

ワークスペース別のリアルタイム接続情報を取得します。

shell
curl "https://api.nwdb.dev/api/v1/realtime/events?workspace_id=00000000-0000-0000-0000-000000000000" \
  -H "X-API-Key: nwdb_xxx"

REST から直接

専用SDKのインストールは不要です。標準の fetch でそのまま呼び出せます。

javascript
const res = await fetch("https://api.nwdb.dev/api/v1/records/customers/records?limit=10", {
  headers: {
    "X-API-Key": "nwdb_your_key_here",
    "X-Workspace-ID": "your_workspace_id",
  },
});
const { records } = await res.json();

// SQL
const q = await fetch("https://api.nwdb.dev/api/v1/query", {
  method: "POST",
  headers: {
    "X-API-Key": "nwdb_your_key_here",
    "X-Workspace-ID": "your_workspace_id",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ sql: "SELECT * FROM customers WHERE age > 25 LIMIT 10" }),
});

ブラウザから直接呼ぶ場合は、シークレットキーではなく publishable key と利用者のトークンを使います(行は RLS で利用者ごとに絞られるため、中継するバックエンドは要りません)。Cloudflare Workers / Pages での手順は Cloudflare Workers クイックスタートを参照してください。

料金

月額6,600円(税込)の1プランのみ(データベース6GB/ファイル6GB/APIコール150万回/転送量20GB)。超過分は従量課金。上限を超える規模はEnterpriseとして個別見積。

NW DB

6,600 JPY/mo (tax incl.)

6GB DB / 6GB files / 1.5M calls / 20GB egress

Enterprise

Contact us

custom quote

従量課金表 (applies past the included quota)

項目含む超過単価
Database Storage6 GB300 JPY / GB
File Storage6 GB15 JPY / GB
API Calls1.5M / month10 JPY / 1K calls
Egress20 GB / month30 JPY / GB
Vector Items100K10 JPY / 10K writes

対話型APIリファレンス(Swagger UI)

Swagger UI
shell
# OpenAPI spec
curl https://api.nwdb.dev/api/v1/docs/openapi.json