{"id":50551874,"url":"https://github.com/vectifyai/pageindex-js-sdk","last_synced_at":"2026-06-04T04:02:48.779Z","repository":{"id":336598384,"uuid":"1133324466","full_name":"VectifyAI/pageindex-js-sdk","owner":"VectifyAI","description":"TypeScript SDK for PageIndex document processing. ","archived":false,"fork":false,"pushed_at":"2026-05-28T00:58:52.000Z","size":597,"stargazers_count":6,"open_issues_count":0,"forks_count":4,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-28T02:23:42.988Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pageindex-js-sdk.vercel.app/","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/VectifyAI.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2026-01-13T07:35:09.000Z","updated_at":"2026-05-28T00:58:56.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/VectifyAI/pageindex-js-sdk","commit_stats":null,"previous_names":["vectifyai/pageindex-mcp-sdk","vectifyai/pageindex-js-sdk"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/VectifyAI/pageindex-js-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VectifyAI%2Fpageindex-js-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VectifyAI%2Fpageindex-js-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VectifyAI%2Fpageindex-js-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VectifyAI%2Fpageindex-js-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VectifyAI","download_url":"https://codeload.github.com/VectifyAI/pageindex-js-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VectifyAI%2Fpageindex-js-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33888302,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-04T02:00:06.755Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-06-04T04:02:47.694Z","updated_at":"2026-06-04T04:02:48.774Z","avatar_url":"https://github.com/VectifyAI.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @pageindex/sdk\n\nTypeScript SDK for [PageIndex](https://pageindex.ai) — upload documents, retrieve tree structures, and chat with your PDFs.\n\nGet your API Key at [dash.pageindex.ai](https://dash.pageindex.ai/api-keys). Full docs at [docs.pageindex.ai/js-sdk](https://docs.pageindex.ai/js-sdk).\n\n## Installation\n\n```bash\nnpm install @pageindex/sdk\n```\n\n## Quick Start\n\n```typescript\nimport { PageIndexClient } from '@pageindex/sdk';\nimport { readFileSync } from 'fs';\n\nconst client = new PageIndexClient({ apiKey: 'YOUR_API_KEY' });\n\n// Upload a document\nconst file = readFileSync('./report.pdf');\nconst { doc_id } = await client.api.submitDocument(file, 'report.pdf');\n\n// Get tree structure\nconst tree = await client.api.getTree(doc_id);\n\n// Chat with the document\nconst response = await client.api.chatCompletions({\n  messages: [{ role: 'user', content: 'What are the key findings?' }],\n  doc_id,\n});\nconsole.log(response.choices[0].message.content);\n\n// Stream a response\nconst stream = await client.api.chatCompletions({\n  messages: [{ role: 'user', content: 'Summarize this document' }],\n  doc_id,\n  stream: true,\n});\nfor await (const chunk of stream) {\n  process.stdout.write(chunk.choices[0]?.delta?.content ?? '');\n}\n```\n\n## Configuration\n\n```typescript\nconst client = new PageIndexClient({\n  apiKey: 'YOUR_API_KEY', // Required\n  apiUrl: 'https://...', // Default: https://api.pageindex.ai\n  folderScope: 'folder-id', // Restrict all operations to a folder\n});\n```\n\n## REST API (`client.api`)\n\n| Method                                     | Description                                     |\n| ------------------------------------------ | ----------------------------------------------- |\n| `submitDocument(file, fileName, options?)` | Upload a document                               |\n| `getTree(docId, options?)`                 | Get tree structure and processing status        |\n| `getDocument(docId)`                       | Get document metadata                           |\n| `listDocuments(options?)`                  | List documents (paginated)                      |\n| `deleteDocument(docId)`                    | Delete a document                               |\n| `createFolder(options)`                    | Create a folder                                 |\n| `listFolders(options?)`                    | List folders                                    |\n| `chatCompletions(params)`                  | Chat with documents (streaming \u0026 non-streaming) |\n\n## Chat API\n\nSupports non-streaming, streaming, multi-document, metadata streaming, and citations. See [Chat API docs](https://docs.pageindex.ai/js-sdk/chat) for full reference.\n\n```typescript\n// Multi-document chat\nawait client.api.chatCompletions({\n  messages: [{ role: 'user', content: 'Compare these' }],\n  doc_id: ['doc-1', 'doc-2'],\n});\n\n// Streaming with tool call metadata\nconst stream = await client.api.chatCompletions({\n  messages,\n  doc_id,\n  stream: true,\n  stream_metadata: true,\n});\nfor await (const chunk of stream) {\n  if (chunk.block_metadata?.type === 'mcp_tool_use_start') {\n    console.log(`[Using: ${chunk.block_metadata.tool_name}]`);\n  }\n  process.stdout.write(chunk.choices[0]?.delta?.content ?? '');\n}\n```\n\n## MCP Tools (`client.tools`)\n\nTyped wrappers for PageIndex MCP — for building custom AI agent integrations. See [MCP Tools docs](https://docs.pageindex.ai/js-sdk/mcp-tools).\n\n| Method                           | Description                                                       |\n| -------------------------------- | ----------------------------------------------------------------- |\n| `browseDocuments(params?)`       | Unified discovery (time/relevance sort, folder drill-down)        |\n| `getFolderStructure(params?)`    | Folder hierarchy as a tree                                        |\n| `searchDocuments(params)`        | Keyword search with LLM re-rank (escalation path)                 |\n| `getDocument(params)`            | Get document details by name                                      |\n| `getDocumentStructure(params)`   | Extract document outline                                          |\n| `getPageContent(params)`         | Read page content                                                 |\n| `getDocumentImage(params)`       | Retrieve embedded image                                           |\n| `removeDocument(params)`         | Delete documents (batch)                                          |\n\n**Deprecated** (still callable for backward compatibility, hidden from the live MCP `tools/list`):\n\n| Method                           | Replacement                                          |\n| -------------------------------- | ---------------------------------------------------- |\n| `recentDocuments(params?)`       | `browseDocuments()` (default `sort: \"time\"`)         |\n| `findRelevantDocuments(params?)` | `browseDocuments({ sort: \"relevance\", query })` or `searchDocuments()` |\n| `listFolders(params?)`           | `getFolderStructure()`                               |\n\n## Error Handling\n\n```typescript\nimport { PageIndexError } from '@pageindex/sdk';\n\ntry {\n  await client.api.getDocument('invalid-id');\n} catch (error) {\n  if (error instanceof PageIndexError) {\n    console.log(error.code); // \"NOT_FOUND\" | \"UNAUTHORIZED\" | \"PLAN_REQUIRED\" | ...\n    console.log(error.message);\n  }\n}\n```\n\n## Examples\n\n- [examples/chat-with-tools](./examples/chat-with-tools) — Next.js + AI SDK with MCP tools\n- [examples/chat-completions](./examples/chat-completions) — Direct Chat Completions API usage\n\n## Links\n\n- [JS SDK Docs](https://docs.pageindex.ai/js-sdk) · [Python SDK](https://docs.pageindex.ai/sdk) · [MCP](https://docs.pageindex.ai/cookbook/mcp) · [REST API](https://docs.pageindex.ai/endpoints)\n- [Discord](https://discord.gg/VuXuf29EUj) · [GitHub](https://github.com/VectifyAI/pageindex-js-sdk)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvectifyai%2Fpageindex-js-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvectifyai%2Fpageindex-js-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvectifyai%2Fpageindex-js-sdk/lists"}