{"meta":{"title":"Markdown 的 REST API 终结点","intro":"使用 REST API 渲染 markdown 文档作为 HTML 页面或原始文本。","product":"REST API","breadcrumbs":[{"href":"/zh/rest","title":"REST API"},{"href":"/zh/rest/markdown","title":"Markdown"},{"href":"/zh/rest/markdown/markdown","title":"Markdown"}],"documentType":"article"},"body":"# Markdown 的 REST API 终结点\n\n使用 REST API 渲染 markdown 文档作为 HTML 页面或原始文本。\n\n> [!NOTE]\n> Most endpoints use `Authorization: Bearer <YOUR-TOKEN>` and `Accept: application/vnd.github+json` headers, plus `X-GitHub-Api-Version: 2026-03-10`. Curl examples below omit these standard headers for brevity.\n\n## Render a Markdown document\n\n```\nPOST /markdown\n```\n\nDepending on what is rendered in the Markdown, you may need to provide additional token scopes for labels, such as issues:read or pull_requests:read.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Body parameters\n\n- **`text`** (string) (required)\n  The Markdown text to render in HTML.\n\n- **`mode`** (string)\n  The rendering mode.\n  Default: `markdown`\n  Can be one of: `markdown`, `gfm`\n\n- **`context`** (string)\n  The repository context to use when creating references in gfm mode.  For example, setting context to octo-org/octo-repo will change the text #42 into an HTML link to issue 42 in the octo-org/octo-repo repository.\n\n### HTTP response status codes\n\n- **200** - OK\n\n- **304** - Not modified\n\n### Code examples\n\n#### Rendering markdown\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X POST \\\n  https://api.github.com/markdown \\\n  -d '{\n  \"text\": \"Hello **world**\"\n}'\n```\n\n**Response schema (Status: 200):**\n\nstring\n\n## Render a Markdown document in raw mode\n\n```\nPOST /markdown/raw\n```\n\nYou must send Markdown as plain text (using a Content-Type header of text/plain or text/x-markdown) to this endpoint, rather than using JSON format. In raw mode, GitHub Flavored Markdown is not supported and Markdown will be rendered in plain format like a README.md file. Markdown content must be 400 KB or less.\n\n### HTTP response status codes\n\n- **200** - OK\n\n- **304** - Not modified\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X POST \\\n  https://api.github.com/markdown/raw \\\n  -d '{\n  \"text\": \"Hello **world**\"\n}'\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Render a Markdown document](#render-a-markdown-document).\n\n#### Rendering markdown\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X POST \\\n  https://api.github.com/markdown/raw \\\n  -d '{\n  \"text\": \"Hello **world**\"\n}'\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Render a Markdown document](#render-a-markdown-document)."}