|
| 1 | +--- |
| 2 | +title: GitHub Docs API |
| 3 | +intro: 'Use the official {% data variables.product.prodname_docs %} API to programmatically list pages, search, and retrieve {% data variables.product.company_short %} documentation content.' |
| 4 | +versions: |
| 5 | + fpt: '*' |
| 6 | + ghes: '*' |
| 7 | + ghec: '*' |
| 8 | +shortTitle: GitHub Docs API |
| 9 | +category: |
| 10 | + - Explore GitHub plans and features |
| 11 | +--- |
| 12 | + |
| 13 | +<!-- markdownlint-disable search-replace --> |
| 14 | +{% data variables.product.prodname_docs %} provides several ways to access documentation content programmatically. You can retrieve individual articles as Markdown, list all available pages, search across the documentation, or point AI agents to the `llms.txt` file for content discovery. |
| 15 | + |
| 16 | +## Article endpoint |
| 17 | + |
| 18 | +The Article endpoint returns the Markdown content and metadata of any {% data variables.product.prodname_docs %} page. It supports all page types, including standard articles, REST API reference pages, GraphQL reference pages, and landing pages. |
| 19 | + |
| 20 | +The Article endpoint accepts the following query parameter: |
| 21 | + |
| 22 | +* `pathname` (required): The article path, including a language prefix such as `/en/` or `/ja/`. |
| 23 | + * For example, `/en/get-started/start-your-journey/about-github-and-git`. |
| 24 | + |
| 25 | +In addition, `GET /api/article` and `GET /api/article/body` accept the following optional query parameter: |
| 26 | + |
| 27 | +* `apiVersion`: For REST API reference pages, specifies which API version to use. Defaults to the latest version. |
| 28 | + |
| 29 | +### Getting article content |
| 30 | + |
| 31 | +`GET https://docs.github.com/api/article/body` returns the full article content as Markdown. |
| 32 | + |
| 33 | +```shell |
| 34 | +curl "https://docs.github.com/api/article/body?pathname=/en/get-started/start-your-journey/about-github-and-git" |
| 35 | +``` |
| 36 | + |
| 37 | +To access a versioned article (for example, for {% data variables.product.prodname_ghe_cloud %}), include the version in the path: |
| 38 | + |
| 39 | +```shell |
| 40 | +curl "https://docs.github.com/api/article/body?pathname=/en/enterprise-cloud@latest/admin/overview/about-github-enterprise-cloud" |
| 41 | +``` |
| 42 | + |
| 43 | +### Getting article metadata |
| 44 | + |
| 45 | +`GET https://docs.github.com/api/article/meta` returns metadata about an article as JSON, including the title, intro, product area, document type, and breadcrumbs. |
| 46 | + |
| 47 | +```shell |
| 48 | +curl "https://docs.github.com/api/article/meta?pathname=/en/get-started/start-your-journey/about-github-and-git" |
| 49 | +``` |
| 50 | + |
| 51 | +### Getting content and metadata together |
| 52 | + |
| 53 | +`GET https://docs.github.com/api/article` returns both metadata and the article body in a single JSON response, combining the results of the body and meta endpoints. |
| 54 | + |
| 55 | +```shell |
| 56 | +curl "https://docs.github.com/api/article?pathname=/en/get-started/start-your-journey/about-github-and-git" |
| 57 | +``` |
| 58 | + |
| 59 | +## Pagelist endpoint |
| 60 | + |
| 61 | +The Pagelist endpoint returns a list of every available page path for a given language and documentation version. You can use it to discover all articles, then fetch individual articles with the Article endpoint. |
| 62 | + |
| 63 | +### Listing all pages |
| 64 | + |
| 65 | +`GET https://docs.github.com/api/pagelist/:lang/:version` returns a newline-separated list of all page paths for the specified language and version. |
| 66 | + |
| 67 | +```shell |
| 68 | +curl "https://docs.github.com/api/pagelist/en/free-pro-team@latest" |
| 69 | +``` |
| 70 | + |
| 71 | +#### Languages list |
| 72 | + |
| 73 | +`GET https://docs.github.com/api/pagelist/languages` returns all available language codes as JSON. Use this to find valid values for the `:lang` parameter above. |
| 74 | + |
| 75 | +#### Versions list |
| 76 | + |
| 77 | +`GET https://docs.github.com/api/pagelist/versions` returns all available documentation versions as JSON, including {% data variables.product.prodname_ghe_server %} version numbers. Use this to find valid values for the `:version` parameter above. |
| 78 | + |
| 79 | +## Search endpoint |
| 80 | + |
| 81 | +The Search endpoint lets you search across all {% data variables.product.prodname_docs %} content. It returns results sorted by relevance, with highlights and metadata for each matching page. |
| 82 | + |
| 83 | +### Searching docs content |
| 84 | + |
| 85 | +`GET https://docs.github.com/api/search/v1` accepts the following query parameters: |
| 86 | + |
| 87 | +* `query` (required): The search term. |
| 88 | +* `client_name` (required for external clients such as `curl`): A name that identifies your client or integration. |
| 89 | +* `version` (optional): The documentation version to search. Defaults to `free-pro-team`. Valid values include `free-pro-team`, `enterprise-cloud`, and {% data variables.product.prodname_ghe_server %} version numbers like `3.19`. |
| 90 | +* `language` (optional): The language to search. Defaults to `en`. |
| 91 | +* `page` (optional): The page number for paginated results. Defaults to `1`. |
| 92 | +* `size` (optional): The number of results per page, up to a maximum of `50`. Defaults to `10`. |
| 93 | + |
| 94 | +```shell |
| 95 | +curl "https://docs.github.com/api/search/v1?query=actions&client_name=docs-api-example&version=free-pro-team&language=en" |
| 96 | +``` |
| 97 | + |
| 98 | +The response includes a `meta` object with information about the total number of matches and a `hits` array containing the matched pages with titles, URLs, breadcrumbs, and content highlights. |
| 99 | + |
| 100 | +## `llms.txt` for AI agents |
| 101 | + |
| 102 | +{% data variables.product.prodname_docs %} publishes an `llms.txt` file at `https://docs.github.com/llms.txt`, following the [`llms.txt` standard](https://llmstxt.org/). This file provides a structured overview of the documentation site designed for consumption by LLMs and AI-powered tools. |
| 103 | + |
| 104 | +If you are building an agent or tool that needs to access {% data variables.product.prodname_docs %}, `llms.txt` is the recommended starting point for discovering available content and API endpoints. |
| 105 | + |
| 106 | +{% ifversion fpt or ghec %} |
| 107 | + |
| 108 | +## Further reading |
| 109 | + |
| 110 | +* [AUTOTITLE](/copilot/how-tos/provide-context/use-mcp-in-your-ide/set-up-the-github-mcp-server) |
| 111 | + |
| 112 | +{% endif %} |
0 commit comments