开发者

OpenAPI 规范

OpenAPI 3.1 格式的机器可读 API 定义。用于生成客户端、导入 Postman 或浏览模式。

下载

📄
openapi.yaml
YAML 格式 — 42 KB。便于人工阅读,适合编辑。

下载 YAML
📋
openapi.json
JSON 格式 — 48 KB。最适合编程使用。

下载 JSON

导入到 Postman

  1. 打开 Postman,点击左上角的 Import。
  2. 拖拽 openapi.yaml 文件,或粘贴 URL:https://api.fs.ax/openapi.yaml
  3. Postman 将生成包含所有端点、参数和示例响应的完整集合。
  4. 将 Authorization 变量设置为您的 API 密钥,然后开始测试。

生成客户端

使用 OpenAPI Generator 为 50+ 种语言创建类型化客户端:

# Install the generator
npm install -g @openapitools/openapi-generator-cli

# Generate a TypeScript client
openapi-generator-cli generate \
  -i https://api.fs.ax/openapi.yaml \
  -g typescript-fetch \
  -o ./fsax-client

# Generate a Python client
openapi-generator-cli generate \
  -i https://api.fs.ax/openapi.yaml \
  -g python \
  -o ./fsax-python-client

# Generate a Go client
openapi-generator-cli generate \
  -i https://api.fs.ax/openapi.yaml \
  -g go \
  -o ./fsax-go-client

规范预览

以下是规范的片段:

openapi: "3.1.0"
info:
  title: fs.ax API
  version: "1.0.0"
  description: URL shortener with built-in monetization
  contact:
    email: api@fs.ax
servers:
  - url: https://api.fs.ax/v1
    description: Production
paths:
  /links:
    post:
      summary: Create a short link
      operationId: createLink
      tags: [Links]
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateLinkRequest"
      responses:
        "201":
          description: Link created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Link"
始终保持最新。 该规范从我们的 Rust API 源代码自动生成,因此始终与线上 API 完全一致。

需要帮助?查阅 API 文档或发送邮件至 api@fs.ax。