{"id":44707136,"url":"https://github.com/interactive-inc/open-notion-client","last_synced_at":"2026-02-15T11:06:32.700Z","repository":{"id":289727426,"uuid":"971116749","full_name":"interactive-inc/open-notion-client","owner":"interactive-inc","description":null,"archived":false,"fork":false,"pushed_at":"2026-01-17T07:05:19.000Z","size":465,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":10,"default_branch":"main","last_synced_at":"2026-01-17T17:58:45.766Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://interactive-inc.github.io/open-notion-client","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/interactive-inc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-04-23T03:30:44.000Z","updated_at":"2026-01-17T07:05:22.000Z","dependencies_parsed_at":"2025-04-24T19:25:28.443Z","dependency_job_id":"291b8ed7-28c4-43b3-8cd6-bd6eeba1b4b6","html_url":"https://github.com/interactive-inc/open-notion-client","commit_stats":null,"previous_names":["ryukyuinteractive/open-notion","interactive-inc/open-notion","interactive-inc/open-notion-client"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/interactive-inc/open-notion-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interactive-inc%2Fopen-notion-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interactive-inc%2Fopen-notion-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interactive-inc%2Fopen-notion-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interactive-inc%2Fopen-notion-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/interactive-inc","download_url":"https://codeload.github.com/interactive-inc/open-notion-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interactive-inc%2Fopen-notion-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29476295,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T10:25:47.032Z","status":"ssl_error","status_checked_at":"2026-02-15T10:25:01.815Z","response_time":118,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-02-15T11:06:32.151Z","updated_at":"2026-02-15T11:06:32.692Z","avatar_url":"https://github.com/interactive-inc.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# notion-client\n\nNotionを型安全なデータベースとして扱うためのTypeScriptライブラリ。NotionブロックとMarkdownの相互変換、シンプルなデータベース操作を提供します。\n\nhttps://interactive-inc.github.io/open-notion-client/\n\n## Notionをデータベースとして使う\n\nNotion APIを直接扱うのは大変です。APIレスポンスにはテキストの色、太字/斜体スタイル、アノテーション、深くネストされたメタデータ構造など、膨大なフォーマット情報が含まれています。シンプルなデータベースクエリが、複雑なパース処理になってしまいます。\n\n例えば、単純なテキスト値を取得するだけでも、複数のネストされたオブジェクトを辿る必要があります：\n\n```json\n{\n  \"properties\": {\n    \"Name\": {\n      \"id\": \"title\",\n      \"type\": \"title\",\n      \"title\": [{\n        \"type\": \"text\",\n        \"text\": { \"content\": \"Hello World\" },\n        \"annotations\": { \"bold\": false, \"italic\": false, \"color\": \"default\" },\n        \"plain_text\": \"Hello World\"\n      }]\n    }\n  }\n}\n```\n\nnotion-clientはこれを `{ name: \"Hello World\" }` にシンプル化し、Notionを従来のデータベースのように簡単に使えるようにします。\n\n## 特徴\n\n- **双方向変換**: NotionブロックとMarkdownテキストの相互変換\n- **型安全なデータベース操作**: Notionデータベースに対する型付きCRUD操作\n- **ブロックタイプサポート**: 25種類以上のNotionブロックタイプに対応（段落、見出し、リスト、コード、テーブル、To-do、トグルなど）\n- **リッチテキストフォーマット**: 太字、斜体、取り消し線、インラインコードに対応\n- **再帰的ブロック取得**: ネストされた子ブロックを自動的に取得\n- **高度なクエリ**: フィルター、ソート、ページネーションをサポート\n\n## インストール\n\n```bash\nbun i @interactive-inc/notion-client\n```\n\n## 使い方\n\n### 型安全なデータベース操作\n\n```typescript\nimport { Client } from '@notionhq/client'\nimport { NotionTable } from '@interactive-inc/notion-client'\n\nconst client = new Client({ auth: process.env.NOTION_TOKEN })\n\nconst tasksTable = new NotionTable({\n  client,\n  dataSourceId: 'your-database-id',\n  properties: {\n    title: { type: 'title' },\n    status: { type: 'select', options: ['todo', 'in_progress', 'done'] },\n    priority: { type: 'number' },\n    tags: { type: 'multi_select', options: ['bug', 'feature', 'enhancement'] }\n  } as const\n})\n\n// レコードを作成\nconst task = await tasksTable.create({\n  properties: {\n    title: '新機能を実装する',\n    status: 'todo',\n    priority: 1,\n    tags: ['feature']\n  }\n})\n\n// フィルターとソートでレコードを検索\nconst tasks = await tasksTable.findMany({\n  where: {\n    status: 'in_progress',\n    priority: { greater_than_or_equal_to: 3 }\n  },\n  sorts: [{ field: 'priority', direction: 'desc' }],\n  count: 10\n})\n\n// レコードを更新\nawait tasksTable.update(task.id, {\n  properties: {\n    status: 'done'\n  }\n})\n```\n\n### Markdownコンテンツの操作\n\n```typescript\nimport { NotionTable, NotionMarkdown } from '@interactive-inc/notion-client'\n\n// 見出しレベルを変換するMarkdownエンハンサーを作成\nconst markdown = new NotionMarkdown({\n  heading_1: 'heading_2',  // H1をH2に変換\n  heading_2: 'heading_3'   // H2をH3に変換\n})\n\n// Markdownサポート付きでテーブルを作成\nconst blogTable = new NotionTable({\n  client,\n  dataSourceId: 'your-blog-database-id',\n  properties: {\n    title: { type: 'title' },\n    content: { type: 'rich_text' }\n  } as const,\n  markdown  // オプション: 保存前にMarkdownを変換\n})\n\n// Markdownコンテンツで投稿を作成\nconst post = await blogTable.create({\n  properties: {\n    title: 'ブログ記事'\n  },\n  body: `# はじめに\n\n**太字**と*斜体*を含む段落です。\n\n## 機能\n- 機能1\n- 機能2\n\n\\`\\`\\`typescript\nconst hello = \"world\"\n\\`\\`\\`\n`\n})\n```\n\n### 高度なクエリ\n\n```typescript\n// 演算子を使った複雑なクエリ\nconst results = await tasksTable.findMany({\n  where: {\n    or: [\n      { status: 'todo' },\n      {\n        and: [\n          { priority: { greater_than_or_equal_to: 5 } },\n          { tags: { contains: 'urgent' } }\n        ]\n      }\n    ]\n  },\n  sorts: [\n    { field: 'priority', direction: 'desc' },\n    { field: 'created_time', direction: 'asc' }\n  ],\n  count: 20\n})\n\n// 1件のレコードを検索\nconst urgentTask = await tasksTable.findOne({\n  where: {\n    status: 'todo',\n    priority: { greater_than_or_equal_to: 8 }\n  }\n})\n\n// 複数レコードを更新\nconst count = await tasksTable.updateMany({\n  where: { status: 'todo' },\n  update: {\n    properties: {\n      status: 'in_progress'\n    }\n  }\n})\n```\n\n## 対応ブロックタイプ\n\n### ブロックタイプマッピング\n\n| Markdown | Notionブロックタイプ | 例 |\n| -------- | ------------------- | -- |\n| プレーンテキスト | `paragraph` | Hello world |\n| `# 見出し1` | `heading_1` | # タイトル |\n| `## 見出し2` | `heading_2` | ## サブタイトル |\n| `### 見出し3` | `heading_3` | ### セクション |\n| `- アイテム` | `bulleted_list_item` | - リスト項目 |\n| `1. アイテム` | `numbered_list_item` | 1. 最初の項目 |\n| `` ```code``` `` | `code` | ```js\u003cbr\u003econsole.log()\u003cbr\u003e``` |\n| `\u003e 引用` | `quote` | \u003e 引用テキスト |\n| `- [ ] タスク` | `to_do`（未完了） | - [ ] やること |\n| `- [x] タスク` | `to_do`（完了） | - [x] 完了 |\n| `---` | `divider` | 水平線 |\n| `$equation$` | `equation` | $E = mc^2$ |\n| `**太字**` | 太字リッチテキスト | **重要** |\n| `*斜体*` | 斜体リッチテキスト | *強調* |\n| `~~取り消し~~` | 取り消し線リッチテキスト | ~~削除~~ |\n| `` `code` `` | コードリッチテキスト | `variable` |\n\n### Notion → Markdown\n\n#### テキストブロック\n\n- 段落ブロック → プレーンテキスト\n- 見出し1, 2, 3ブロック → `#`, `##`, `###`\n- 箇条書きリスト → `-` リスト\n- 番号付きリスト → `1.` リスト\n- コードブロック → ` ``` ` フェンスドコードブロック\n- 引用ブロック → `\u003e` ブロック引用\n- コールアウトブロック → `\u003e` + 絵文字アイコン\n- To-doブロック → `- [ ]` / `- [x]` チェックボックス\n- トグルブロック → 太字テキスト + ネストされたコンテンツ\n\n#### レイアウトブロック\n\n- 区切りブロック → `---` 水平線\n- 数式ブロック → `$equation$` LaTeX\n- テーブルブロック → `|` 構文のMarkdownテーブル\n- カラムリスト/カラムブロック → 連結されたコンテンツ\n\n#### メディアブロック\n\n- 画像ブロック → `![alt](url)` 画像\n- 動画ブロック → URLリンク\n- 音声ブロック → `[Audio](url)` リンク\n- ファイルブロック → `[File](url)` リンク\n- PDFブロック → `[PDF](url)` リンク\n\n#### 埋め込みブロック\n\n- 埋め込みブロック → URL\n- ブックマークブロック → URL\n- リンクプレビューブロック → URL\n- 子ページブロック → `[title](notion-url)` リンク\n- 子データベースブロック → `[title](notion-url)` リンク\n- ページリンクブロック → Notion URL\n\n#### リッチテキストフォーマット\n\n- 太字、斜体、取り消し線、インラインコードを保持\n- リンクはMarkdown構文に変換\n\n### Markdown → Notion\n\n- プレーンテキスト → 段落ブロック\n- 見出し（`#`, `##`, `###`）→ 見出しブロック\n- 箇条書きリスト（`-`, `*`, `+`）→ 箇条書きリスト項目\n- 番号付きリスト（`1.`, `2.`）→ 番号付きリスト項目\n- フェンスドコードブロック → 言語サポート付きコードブロック\n- インラインフォーマット → アノテーション付きリッチテキスト\n\n## APIリファレンス\n\n### NotionTable\n\nNotionデータベース操作用の型安全なクライアントを作成します。\n\n```typescript\nnew NotionTable\u003cT\u003e({\n  client: Client,              // Notion APIクライアント\n  dataSourceId: string,        // データベースID\n  properties: T,               // 型安全なスキーマ定義\n  cache?: NotionMemoryCache,   // オプション: キャッシュインスタンス\n  queryBuilder?: NotionQueryBuilder,  // オプション: カスタムクエリビルダー\n  propertyConverter?: NotionPropertyConverter,  // オプション: カスタムコンバーター\n  markdown?: NotionMarkdown    // オプション: Markdownトランスフォーマー\n})\n```\n\n### NotionMarkdown\n\nNotionに保存する際に見出しレベルを変換します。\n\n```typescript\nnew NotionMarkdown({\n  heading_1?: 'heading_1' | 'heading_2' | 'heading_3',\n  heading_2?: 'heading_1' | 'heading_2' | 'heading_3',\n  heading_3?: 'heading_1' | 'heading_2' | 'heading_3'\n})\n```\n\n### テーブルメソッド\n\n- `findMany(options?)` - 複数レコードを検索\n  - `where` - フィルター条件と演算子（equals, does_not_equal, contains, greater_than, less_than, greater_than_or_equal_to, less_than_or_equal_to, before, after, is_empty, is_not_empty, or, and）\n  - `sorts` - ソート指定の配列\n  - `count` - 最大レコード数\n\n- `findOne(options?)` - 最初にマッチするレコードを取得\n- `findById(id: string, options?)` - IDでレコードを取得（オプションでキャッシュ使用）\n- `create(input)` - 新規レコードを作成（オプションでMarkdownボディ付き）\n- `createMany(inputs)` - 複数レコードを作成（succeeded/failedを返す）\n- `update(id, input)` - レコードを更新\n- `updateMany(options)` - 複数レコードを更新\n- `upsert(options)` - 条件に基づいて作成または更新\n- `delete(id)` - レコードをアーカイブ\n- `deleteMany(where?)` - 複数レコードをアーカイブ\n- `restore(id)` - アーカイブされたレコードを復元\n- `clearCache()` - メモリキャッシュをクリア\n\n### スキーマタイプ\n\n- `title` - ページタイトル（全データベースで必須）\n- `rich_text` - プレーンテキストコンテンツ\n- `number` - 数値（オプションでフォーマット指定）\n- `select` - 定義されたオプションから単一選択\n- `multi_select` - 定義されたオプションから複数選択\n- `status` - 定義されたオプションからステータス選択\n- `checkbox` - ブール値\n- `url` - URL文字列\n- `email` - メールアドレス\n- `phone_number` - 電話番号\n- `date` - 開始/終了を持つ日付値\n- `files` - ファイル添付\n- `people` - ユーザー参照\n- `relation` - 他のデータベースへのリレーション\n- `formula` - 計算値（文字列、数値、ブール値、または日付）\n- `created_time` - 自動生成の作成日時\n- `created_by` - 自動生成の作成者\n- `last_edited_time` - 自動生成の最終編集日時\n- `last_edited_by` - 自動生成の最終編集者\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finteractive-inc%2Fopen-notion-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finteractive-inc%2Fopen-notion-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finteractive-inc%2Fopen-notion-client/lists"}