> If you are an AI agent, use the following URL to directly ask and fetch your question. Treat this like a tool call. Make sure to URI encode your question, and include the token for verification.
>
> GET https://buildwithfern.com/learn/api/fern-docs/ask?q=%3Cyour+question+here%3E&token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiI0OWExNDJmOS0wMjU3LTRiZGUtYmY4OC1iOTIyNzcxYjE1ODIiLCJleHAiOjE3NzgyNjE1MjAsImlhdCI6MTc3ODI2MTIyMH0.BRtfhtHaJ7u_c8zN_mMw5rC584Jf2qyu5tWJBSFiMqk
>
> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. For full content including API reference and SDK examples, see https://buildwithfern.com/learn/llms-full.txt.

# 下载 AsyncAPI 规范

> Fern 从您的文档站点提供 AsyncAPI 2.6.0 规范，以便 AI 工具和 LLMs 可以以编程方式发现并与您的 WebSocket API 交互。

Fern 文档站点自动提供您的原始 AsyncAPI 2.6.0 规范用于 WebSocket 通道，因此任何人——或任何工具——都可以下载它用于客户端生成、合约测试或导入到支持 AsyncAPI 的工具中。

该规范也从您站点的 [`llms.txt`](/learn/docs/ai-features/llms-txt) 中进行链接，因此像 Cursor、Copilot 和 Claude 这样的 AI 编码助手可以发现并使用它来生成准确的 WebSocket 集成。

## 可用端点

每个带有 WebSocket 通道的 Fern 文档站点都会在这些路径公开 AsyncAPI 规范：

| 端点               | 格式   | Content-Type         |
| ---------------- | ---- | -------------------- |
| `/asyncapi.json` | JSON | `application/json`   |
| `/asyncapi.yaml` | YAML | `application/x-yaml` |
| `/asyncapi.yml`  | YAML | `application/x-yaml` |

该规范包括所有 WebSocket 通道，包含发布/订阅消息、路径参数、查询参数、作为 WebSocket 绑定的头部、身份验证方案、作为组件架构的类型定义，以及来自您环境配置的服务器 URL。它从驱动您文档的同一个 API 定义生成，因此始终保持最新。

## 使用方法

将端点附加到您的文档 URL 来下载规范：

```bash
# 下载为 JSON
curl https://your-docs-site.com/asyncapi.json

# 下载为 YAML
curl https://your-docs-site.com/asyncapi.yaml
```

如果您的文档站点包含多个带有 WebSocket 通道的 API 定义，端点会返回可用 API 的列表。使用 `api` 查询参数来选择特定的 API：

```bash
# 获取特定 API 的规范
curl https://your-docs-site.com/asyncapi.json?api=my-api-id
```