Skip to content

Commit 6d1e644

Browse files
CTX7-855: Context7 TS SDK docs (#1080)
* init sdk and monorepo * init sdk and monorepo * comment cleanup * remove bun.lock * cleanup: remove sdk package and deps * update tsconfigs * chore: add temp changelog * ci: update scripts * ci: update github workflows * fmt: workflows * fix: search libraries response type * ci: update pack-mcpb script * feat: init ts sdk * feat: add commands and http client * update keywords and author * update eslint config for mcp * include license and readme in build * update release.yaml * add readme symlink * include readme in mcp package * chore: add canary release workflow and update configs * chore: format files * ci: add changeset check workflow * canary release trigger * ci: login to npm before release * bump mcp version on package * remove pr trigger from canary release * ci: remove package input * finalize sdk with tests and proper types * address reviews * add client tests * feat: use env var automatically * add docs * docs: update API documentation and add SDK guides Added comprehensive TypeScript SDK documentation including getting started guide and command references for get-docs and search-library. Updated API guide and OpenAPI specification. * remove docs changes (moving to separate PR) * docs: ts sdk docs * update sdk examples * remove docs * update build config with tsup * cleanup comments * fix error hangling on http client * minor fixes * address reviews * add txt pagination feature * remove unnecessary types * update docs with new paging txt feature * update default format * cleanup * fmt * update * add mcp lint command * update format scripts * fix: update eslint and tsconfig with update * add readme * make default format json * change docType to mode * update basic usage * apply interface changes * remove changeset
1 parent 6c05158 commit 6d1e644

File tree

6 files changed

+817
-3
lines changed

6 files changed

+817
-3
lines changed

docs/api-guide.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,5 @@ const response = await fetch("https://context7.com/api/v2/docs/code/vercel/next.
194194
Authorization: "Bearer CONTEXT7_API_KEY",
195195
},
196196
});
197-
198197
const docs = await response.json();
199198
```

docs/docs.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@
3232
"dashboard/billing"
3333
]
3434
},
35+
{
36+
"group": "SDKs",
37+
"pages": [
38+
{
39+
"group": "TypeScript",
40+
"pages": [
41+
"sdks/ts/getting-started",
42+
{
43+
"group": "Commands",
44+
"pages": ["sdks/ts/commands/search-library", "sdks/ts/commands/get-docs"]
45+
}
46+
]
47+
}
48+
]
49+
},
3550
{
3651
"group": "API Reference",
3752
"openapi": "openapi.json"

docs/openapi.json

Lines changed: 95 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,57 @@
728728
]
729729
}
730730
},
731+
"headers": {
732+
"X-Context7-Page": {
733+
"description": "Current page number (1-indexed). Only returned for text/plain responses (type=txt).",
734+
"schema": {
735+
"type": "integer",
736+
"minimum": 1
737+
},
738+
"example": 1
739+
},
740+
"X-Context7-Limit": {
741+
"description": "Number of items per page. Only returned for text/plain responses (type=txt).",
742+
"schema": {
743+
"type": "integer",
744+
"minimum": 1,
745+
"maximum": 10
746+
},
747+
"example": 10
748+
},
749+
"X-Context7-Total-Pages": {
750+
"description": "Total number of pages available. Only returned for text/plain responses (type=txt).",
751+
"schema": {
752+
"type": "integer",
753+
"minimum": 0
754+
},
755+
"example": 10
756+
},
757+
"X-Context7-Has-Next": {
758+
"description": "Whether a next page exists. Only returned for text/plain responses (type=txt).",
759+
"schema": {
760+
"type": "string",
761+
"enum": ["true", "false"]
762+
},
763+
"example": "true"
764+
},
765+
"X-Context7-Has-Prev": {
766+
"description": "Whether a previous page exists. Only returned for text/plain responses (type=txt).",
767+
"schema": {
768+
"type": "string",
769+
"enum": ["true", "false"]
770+
},
771+
"example": "false"
772+
},
773+
"X-Context7-Total-Tokens": {
774+
"description": "Total token count for the current page. Only returned for text/plain responses (type=txt).",
775+
"schema": {
776+
"type": "integer",
777+
"minimum": 0
778+
},
779+
"example": 1500
780+
}
781+
},
731782
"responses": {
732783
"CodeSnippetsJsonResponse": {
733784
"description": "Successful response with code snippets",
@@ -801,10 +852,31 @@
801852
},
802853
"text/plain": {
803854
"schema": {
804-
"type": "string"
855+
"type": "string",
856+
"description": "Plain text formatted documentation. Pagination metadata is returned via response headers."
805857
},
806858
"example": "### Create and Run Next.js App with create-next-app (Quick Start)\n\nSource: https://github.com/vercel/next.js/blob/canary/docs/01-app/01-getting-started/01-installation.mdx\n\nQuickly set up and start a new Next.js application using `create-next-app` with various package managers. This command creates a new project directory, installs dependencies, and starts the development server. The `--yes` flag skips interactive prompts, enabling a default setup with TypeScript, Tailwind, ESLint, App Router, and Turbopack.\n\n```bash\npnpm create next-app@latest my-app --yes\ncd my-app\npnpm dev\n```\n\n```bash\nnpx create-next-app@latest my-app --yes\ncd my-app\nnpm run dev\n```\n\n```bash\nyarn create next-app@latest my-app --yes\ncd my-app\nyarn dev\n```\n\n```bash\nbun create next-app@latest my-app --yes\ncd my-app\nbun dev\n```"
807859
}
860+
},
861+
"headers": {
862+
"X-Context7-Page": {
863+
"$ref": "#/components/headers/X-Context7-Page"
864+
},
865+
"X-Context7-Limit": {
866+
"$ref": "#/components/headers/X-Context7-Limit"
867+
},
868+
"X-Context7-Total-Pages": {
869+
"$ref": "#/components/headers/X-Context7-Total-Pages"
870+
},
871+
"X-Context7-Has-Next": {
872+
"$ref": "#/components/headers/X-Context7-Has-Next"
873+
},
874+
"X-Context7-Has-Prev": {
875+
"$ref": "#/components/headers/X-Context7-Has-Prev"
876+
},
877+
"X-Context7-Total-Tokens": {
878+
"$ref": "#/components/headers/X-Context7-Total-Tokens"
879+
}
808880
}
809881
},
810882
"InfoSnippetsJsonResponse": {
@@ -859,10 +931,31 @@
859931
},
860932
"text/plain": {
861933
"schema": {
862-
"type": "string"
934+
"type": "string",
935+
"description": "Plain text formatted documentation. Pagination metadata is returned via response headers."
863936
},
864937
"example": "### How to Contribute > Writing MDX\n\nSource: https://github.com/vercel/next.js/blob/canary/docs/04-community/01-contribution-guide.mdx\n\nThe docs are written in [MDX](https://mdxjs.com/), a markdown format that supports JSX syntax. This allows us to embed React components in the docs. See the [GitHub Markdown Guide](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax) for a quick overview of markdown syntax."
865938
}
939+
},
940+
"headers": {
941+
"X-Context7-Page": {
942+
"$ref": "#/components/headers/X-Context7-Page"
943+
},
944+
"X-Context7-Limit": {
945+
"$ref": "#/components/headers/X-Context7-Limit"
946+
},
947+
"X-Context7-Total-Pages": {
948+
"$ref": "#/components/headers/X-Context7-Total-Pages"
949+
},
950+
"X-Context7-Has-Next": {
951+
"$ref": "#/components/headers/X-Context7-Has-Next"
952+
},
953+
"X-Context7-Has-Prev": {
954+
"$ref": "#/components/headers/X-Context7-Has-Prev"
955+
},
956+
"X-Context7-Total-Tokens": {
957+
"$ref": "#/components/headers/X-Context7-Total-Tokens"
958+
}
866959
}
867960
},
868961
"BadRequestError": {

0 commit comments

Comments
 (0)