NW DB
/ NW DB ドキュメント

NW DB ドキュメント

NW DB API、SDK、機能の完全ガイド

はじめに

アカウント登録、ワークスペース作成、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": {
      "command": "npx",
      "args": ["-y", "@nup-white/nwdb-mcp"],
      "env": {
        "NWDB_API_URL": "https://api.nwdb.dev",
        "NWDB_API_KEY": "nwdb_your_key_here",
        "NWDB_WORKSPACE": "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" }
  }'

AI承認パイプライン

AIの提案をプレビューし、人間またはルールで承認した変更だけを適用します。

Generate Proposals

shell
curl -X POST https://api.nwdb.dev/api/v1/pipeline/propose \
  -H "X-API-Key: nwdb_xxx" \
  -H "X-Workspace-ID: ws_abc123" \
  -H "Content-Type: application/json" \
  -d '{
    "table": "customers",
    "transform": "pii_mask",
    "columns": {
      "email": "reversible",
      "phone": "reversible"
    },
    "limit": 100
  }'

List Proposals

shell
curl "https://api.nwdb.dev/api/v1/pipeline/proposals?status=pending" \
  -H "X-API-Key: nwdb_xxx" \
  -H "X-Workspace-ID: ws_abc123"

Apply Approved Changes

shell
curl -X POST https://api.nwdb.dev/api/v1/pipeline/apply \
  -H "X-API-Key: nwdb_xxx" \
  -H "X-Workspace-ID: ws_abc123" \
  -H "Content-Type: application/json" \
  -d '{ "table": "customers", "status": "approved" }'

リアルタイム

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

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

SDK

Node.js向け公式SDKを提供しています。

Node.js

shell
npm install nwdb-sdk
javascript
import { createClient } from "nwdb-sdk";

const db = createClient("https://api.nwdb.dev", "nwdb_your_key_here", {
  workspaceId: "ws_abc123",
});

// Query records
const { data: customers, error } = await db.from("customers")
  .select("*")
  .gt("age", 25)
  .limit(10);

// Live analytics
const salesByStatus = await db.rpc(
  "SELECT status, SUM(amount) AS sales FROM orders GROUP BY status LIMIT 20"
);

料金

Hobby 月額3,500円 / Pro 7,800円 / Team 19,800円 / Scale 50,000円+従量課金。Enterprise完全ホワイトラベル再販可。

Hobby

3,500 JPY/mo

Pro

7,800 JPY/mo

Team

19,800 JPY/mo

warm-standby HA

Scale

50,000 JPY/mo

SLA 99.9%

Enterprise

110,000 JPY/mo〜 税込

custom

従量課金表 (Hobby tier — quotas scale with plan)

項目含む超過単価
Database Storage2 GB1,000 JPY / GB
File Storage500 MB15 JPY / GB
API Calls100K / month10 JPY / 1K calls
Vector Items10K / month10 JPY / 10K writes
Tokens1M / month100 JPY / 10K tokens
AI Agent RowsOpt-in metered add-on200 JPY / 1K rows

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

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