NW DB
/ NW DB ドキュメント

NW DB ドキュメント

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

はじめに

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

  1. 1. nw-db-webで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://nw-db-api-984843242141.asia-northeast1.run.app/api/v1/tables \
  -H "Authorization: Bearer <FIREBASE_ID_TOKEN>" \
  -H "X-Workspace-ID: <WORKSPACE_ID>"

# API key authentication
curl https://nw-db-api-984843242141.asia-northeast1.run.app/api/v1/tables \
  -H "X-API-Key: nwdb_your_key_here" \
  -H "X-Workspace-ID: <WORKSPACE_ID>"

REST API

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

List Tables

shell
curl https://nw-db-api-984843242141.asia-northeast1.run.app/api/v1/tables \
  -H "X-API-Key: nwdb_xxx" \
  -H "X-Workspace-ID: ws_abc123"

Create Table

shell
curl -X POST https://nw-db-api-984843242141.asia-northeast1.run.app/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://nw-db-api-984843242141.asia-northeast1.run.app/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://nw-db-api-984843242141.asia-northeast1.run.app/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://nw-db-api-984843242141.asia-northeast1.run.app/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" }'

GraphQL

PostGraphile経由の自動生成GraphQL API。サブスクリプション、ミューテーション、クエリ対応。

shell
curl -X POST https://nw-db-api-984843242141.asia-northeast1.run.app/api/v1/proxy/graphql \
  -H "X-API-Key: nwdb_xxx" \
  -H "X-Workspace-ID: ws_abc123" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "{ allCustomers(first: 10) { nodes { name email age } } }"
  }'

MCP (Model Context Protocol)

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

Claude Desktop Config

json
{
  "mcpServers": {
    "nwdb": {
      "url": "https://nw-db-api-984843242141.asia-northeast1.run.app/api/v1/mcp/sse",
      "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
insert_recordInsert a record
vector_searchSemantic similarity search
upload_fileUpload file to storage

Execute MCP Tool via API

shell
curl -X POST https://nw-db-api-984843242141.asia-northeast1.run.app/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エージェント

クレンジング、正規化、マスキング、ベクトル化、メタデータ抽出の自動パイプライン。

AgentDescription
cleansingDeduplicate, fill missing values, standardize formats
normalizationNormalize addresses, company names, dates, categories
maskingAuto-detect and mask PII (email, phone, address)
vectorizationAuto-generate embeddings for text columns
metadataInfer column semantics, detect relationships, build catalog

Trigger Agent

shell
curl -X POST https://nw-db-api-984843242141.asia-northeast1.run.app/api/v1/agents/run/cleansing \
  -H "X-API-Key: nwdb_xxx" \
  -H "X-Workspace-ID: ws_abc123" \
  -H "Content-Type: application/json" \
  -d '{ "reason": "Monthly data cleanup" }'

Check Agent Status

shell
curl https://nw-db-api-984843242141.asia-northeast1.run.app/api/v1/agents/status \
  -H "X-API-Key: nwdb_xxx" \
  -H "X-Workspace-ID: ws_abc123"

CSV / JSONインポート

CSVまたはJSON形式でデータを一括インポートします。

Import CSV

shell
curl -X POST https://nw-db-api-984843242141.asia-northeast1.run.app/api/v1/import/csv/customers \
  -H "X-API-Key: nwdb_xxx" \
  -H "X-Workspace-ID: ws_abc123" \
  -H "Content-Type: text/csv" \
  --data-binary @customers.csv

Import JSON

shell
curl -X POST https://nw-db-api-984843242141.asia-northeast1.run.app/api/v1/import/json/customers \
  -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 },
    { "name": "Jane", "email": "jane@example.com", "age": 25 }
  ]'

リアルタイム

WebSocketまたはServer-Sent Eventsでデータベース変更をサブスクライブします。

javascript
// WebSocket connection
const ws = new WebSocket(
  "wss://nw-db-api-984843242141.asia-northeast1.run.app/api/v1/realtime/ws"
);

ws.onopen = () => {
  ws.send(JSON.stringify({
    type: "subscribe",
    table: "customers",
    apiKey: "nwdb_your_key_here",
    workspaceId: "ws_abc123",
  }));
};

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  console.log("Change:", data);
  // { type: "INSERT", table: "customers", record: {...} }
};

SDK

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

Node.js

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

const db = new NWDBClient({
  apiKey: "nwdb_your_key_here",
  workspaceId: "ws_abc123",
});

// List tables
const tables = await db.tables.list();

// Query records
const customers = await db.from("customers")
  .select("*")
  .where("age", ">", 25)
  .limit(10);

// Vector search
const results = await db.vectors
  .collection("documents")
  .search({ query: "AI database", topK: 5 });

Python

shell
pip install nwdb
python
from nwdb import NWDBClient

db = NWDBClient(
    api_key="nwdb_your_key_here",
    workspace_id="ws_abc123",
)

# List tables
tables = db.tables.list()

# Query records
customers = db.query("SELECT * FROM customers WHERE age > 25 LIMIT 10")

# Vector search
results = db.vectors.collection("documents").search(
    query="AI database",
    top_k=5,
)

料金

Standardプラン月額5,500円+従量課金。

Standard

5,500 JPY / month

従量課金表

項目含む超過単価
Database Storage3 GB110 JPY / GB
File Storage500 MB55 JPY / GB
API Calls100K / month1.1 JPY / 1K calls
Vector Writes10K / month5.5 JPY / 1K writes
Vector Queries10K / month3.3 JPY / 1K queries
AI Agent Processing10K rows / month11 JPY / 1K rows
Background Jobs60 min / month1.1 JPY / min

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

Swagger UI
shell
# OpenAPI spec
curl https://nw-db-api-984843242141.asia-northeast1.run.app/api/v1/docs/openapi.json