빌더 Quickstart (5분)
1. 설치
bash
npm install @ainote/sdk- 런타임 의존성 0 (Node ≥18의 내장
fetch사용), ESM + CJS + 타입 제공.
2. 키 발급
키 하나면 됩니다. 두 가지 방법 — 둘 다 오늘 동작합니다.
A. 계정이 없다면 — 무인증 onboarding 도구로 즉시 발급 (signup_and_get_key):
bash
curl -s https://api.ainote.dev/api/mcp \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call",
"params":{"name":"signup_and_get_key",
"arguments":{"email":"you@example.com","password":"min6chars"}}}'
# → 응답 텍스트에 새 계정 + MCP 키 포함. 이미 계정이 있으면 login_and_get_key 사용(email/password 동일).B. 이미 ainote 사용자라면 — 앱/웹 설정에서 발급: ainote 앱 → 설정 › MCP 키에서 키 생성.
apiKey로 넘기면 SDK가 REST엔 Bearer, MCP엔 McpKey 헤더로 같은 키를 보냅니다(표면별 규칙은 인증 참고).
키는 서버에 보관하세요. 계정 전체 접근 권한(비번급)이라 모바일/웹 클라이언트 번들에 넣지 마세요(유출 위험).
키가 동작하는지 1줄 확인 (REST Bearer, HTTP 200 기대):
bash
curl -s -o /dev/null -w '%{http_code}\n' \
https://api.ainote.dev/api/tasks?per_page=1 \
-H "Authorization: Bearer $AINOTE_KEY"
# 200 이면 끝. 403 이면 → User-Agent/WAF 이슈 ([인증](/build/auth#waf-403) 참고)자세한 인증 옵션은 인증 참고.
3. 첫 호출 (REST — 타입 있음)
ts
import { AiNote } from '@ainote/sdk';
const ai = new AiNote({ apiKey: process.env.AINOTE_KEY! });
// 태스크 목록 (타입 Task[])
const { data: tasks } = await ai.tasks.list({ is_important: true });
// 생성 → 수정 → 삭제
const task = await ai.tasks.create({ content: '첫 태스크', due_date: '2026-06-10' });
await ai.tasks.update(task.id, { is_important: true });
await ai.tasks.delete(task.id);
// 노트(papers)
const { data: notes } = await ai.papers.list({ include_content: false });4. 첫 호출 (MCP — vault/sync, 텍스트)
ts
const res = await ai.mcp.call('list_tasks', { limit: 1 });
console.log(res.text); // "Found 1 tasks: ⏳ ..."
await ai.vault.list();
await ai.sync.pendingConflicts();5. 에러 처리
ts
import { ValidationError, RateLimitError, AuthError } from '@ainote/sdk';
// sleep() / reauth() 는 앱에서 제공하는 헬퍼 (SDK export 아님)
try {
await ai.tasks.create({ content: '' });
} catch (e) {
if (e instanceof ValidationError) console.log(e.fieldErrors);
else if (e instanceof RateLimitError) await sleep(e.retryAfterMs ?? 1000);
else if (e instanceof AuthError) reauth();
}다음: @ainote/sdk 레퍼런스 · 동기화 백엔드로 쓰기