apifox

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Apifox Skill

Apifox Skill

本 skill 提供 ABC 医疗云 API 文档查询功能,统一通过
apifox.py
调用。
This skill provides ABC Medical Cloud API document query functionality, which is uniformly called via
apifox.py
.

环境配置

Environment Configuration

必需的环境变量

Required Environment Variables

使用前需要配置 Apifox Access Token:
bash
undefined
You need to configure the Apifox Access Token before use:
bash
undefined

设置 Apifox Access Token(必需)

Set Apifox Access Token (required)

export APIFOX_ACCESS_TOKEN="你的 Apifox Access Token"
export APIFOX_ACCESS_TOKEN="Your Apifox Access Token"

设置项目 ID(可选,默认为 4105462)

Set Project ID (optional, default is 4105462)

export APIFOX_PROJECT_ID="4105462"
undefined
export APIFOX_PROJECT_ID="4105462"
undefined

获取 Apifox Access Token

Obtain Apifox Access Token

  1. 登录 Apifox
  2. 进入账号设置 > API 访问令牌
  3. 创建新的访问令牌
  4. 复制 Token 并配置到环境变量
  1. Log in to Apifox
  2. Go to Account Settings > API Access Tokens
  3. Create a new access token
  4. Copy the Token and configure it into the environment variable

依赖安装

Dependency Installation

bash
undefined
bash
undefined

安装 Python 依赖

Install Python dependencies

pip3 install requests
undefined
pip3 install requests
undefined

工作原理

How It Works

apifox 直接通过 HTTP 请求调用 Apifox API:
  1. 首次使用:从 Apifox API 获取 OpenAPI 文档
  2. 本地缓存:数据保存到插件目录下的
    cache/
    文件夹
  3. 缓存持久:缓存永久有效,需要手动刷新获取最新文档
apifox directly calls the Apifox API via HTTP requests:
  1. First Use: Fetch OpenAPI documents from the Apifox API
  2. Local Cache: Data is saved to the
    cache/
    folder under the plugin directory
  3. Persistent Cache: The cache is permanently valid, and manual refresh is required to get the latest documents

配置示例

Configuration Example

bash
undefined
bash
undefined

在 ~/.bashrc 或 ~/.zshrc 中添加

Add to ~/.bashrc or ~/.zshrc

export APIFOX_ACCESS_TOKEN="apt_xxxxxxxxxxxxxxx" export APIFOX_PROJECT_ID="4105462"
export APIFOX_ACCESS_TOKEN="apt_xxxxxxxxxxxxxxx" export APIFOX_PROJECT_ID="4105462"

重新加载配置

Reload configuration

source ~/.bashrc # 或 source ~/.zshrc
undefined
source ~/.bashrc # or source ~/.zshrc
undefined

使用方式

Usage

bash
./scripts/apifox <command> [参数]
说明
./scripts/apifox
是 shell wrapper,会自动检测并使用系统中可用的 Python 解释器(python3 或 python)。
所有命令默认返回 JSON 格式输出。
bash
./scripts/apifox <command> [parameters]
Note:
./scripts/apifox
is a shell wrapper that automatically detects and uses the available Python interpreter (python3 or python) in the system.
All commands return JSON format output by default.

API 模块说明

API Module Description

ABC 医疗云 API 文档包含以下模块:
模块接口数量说明
api2506HTTP API 接口
rpc1338RPC 服务接口
api-weapp294小程序 API 接口
api-device29设备接口
api-mp17公众号接口
api-external14外部接口
ABC Medical Cloud API documents include the following modules:
ModuleNumber of InterfacesDescription
api2506HTTP API interfaces
rpc1338RPC service interfaces
api-weapp294Mini Program API interfaces
api-device29Device interfaces
api-mp17Official Account interfaces
api-external14External interfaces

命令列表

Command List

文档管理

Document Management

命令说明
read_oas
读取完整 OpenAPI 规范(约 5MB JSON)
refresh_oas
刷新/更新最新文档(显示缓存状态)
cache_status
查看缓存状态和版本
clear_cache
清除本地缓存(需要
--force
参数)
CommandDescription
read_oas
Read the complete OpenAPI specification (about 5MB JSON)
refresh_oas
Refresh/update the latest documents (shows cache status)
cache_status
View cache status and version
clear_cache
Clear local cache (requires
--force
parameter)

接口查询

Interface Query

命令说明
list_paths
列出接口路径(支持模块和方法过滤)
search_paths
搜索接口(关键词匹配)
get_path
获取单个接口详情(自动解析 $ref)
list_modules
列出所有模块及接口统计
CommandDescription
list_paths
List interface paths (supports module and method filtering)
search_paths
Search interfaces (keyword matching)
get_path
Get details of a single interface (automatically resolves $ref)
list_modules
List all modules and interface statistics

数据分析

Data Analysis

命令说明
stats
显示统计信息(接口总数、模块分布)
export_summary
导出接口摘要(JSON/Markdown)
CommandDescription
stats
Display statistical information (total interfaces, module distribution)
export_summary
Export interface summaries (JSON/Markdown)

使用示例

Usage Examples

查询接口详情

Query Interface Details

bash
undefined
bash
undefined

获取指定接口的完整定义

Get the complete definition of the specified interface

./scripts/apifox get_path
--path "/api/global-auth/login/sms"
--method POST
./scripts/apifox get_path
--path "/api/global-auth/login/sms"
--method POST

获取接口但不解析 $ref(更快)

Get the interface without resolving $ref (faster)

./scripts/apifox get_path
--path "/api/global-auth/login/sms"
--method POST
--include_refs false
undefined
./scripts/apifox get_path
--path "/api/global-auth/login/sms"
--method POST
--include_refs false
undefined

搜索接口

Search Interfaces

bash
undefined
bash
undefined

搜索登录相关接口

Search for login-related interfaces

./scripts/apifox search_paths --keyword "login"
./scripts/apifox search_paths --keyword "login"

搜索 api 模块中的用户相关接口

Search for user-related interfaces in the api module

./scripts/apifox search_paths --keyword "user" --module api
./scripts/apifox search_paths --keyword "user" --module api

列出所有 POST 接口

List all POST interfaces

./scripts/apifox list_paths --method post --limit 20
undefined
./scripts/apifox list_paths --method post --limit 20
undefined

模块查询

Module Query

bash
undefined
bash
undefined

列出所有模块及统计

List all modules and statistics

./scripts/apifox list_modules
./scripts/apifox list_modules

列出小程序接口(前 20 个)

List Mini Program interfaces (first 20)

./scripts/apifox list_paths --module api-weapp --limit 20
undefined
./scripts/apifox list_paths --module api-weapp --limit 20
undefined

统计信息

Statistical Information

bash
undefined
bash
undefined

查看基本统计

View basic statistics

./scripts/apifox stats
./scripts/apifox stats

查看详细统计(包含各模块详情)

View detailed statistics (includes module details)

./scripts/apifox stats --detail
undefined
./scripts/apifox stats --detail
undefined

缓存管理

Cache Management

bash
undefined
bash
undefined

查看缓存状态

View cache status

./scripts/apifox cache_status
./scripts/apifox cache_status

刷新文档(强制从 API 重新获取最新数据)

Refresh documents (force re-fetch latest data from API)

./scripts/apifox refresh_oas
./scripts/apifox refresh_oas

清除缓存

Clear cache

./scripts/apifox clear_cache --force
undefined
./scripts/apifox clear_cache --force
undefined

导出摘要

Export Summary

bash
undefined
bash
undefined

导出所有 API 模块接口摘要到 Markdown

Export interface summaries of all API modules to Markdown

./scripts/apifox export_summary --module api --output api_summary.md --format markdown
./scripts/apifox export_summary --module api --output api_summary.md --format markdown

导出为 JSON

Export as JSON

./scripts/apifox export_summary --output full_summary.json --format json
undefined
./scripts/apifox export_summary --output full_summary.json --format json
undefined

输出格式

Output Format

所有命令返回 JSON 格式:
json
{
  "success": true,
  "data": "返回的数据"
}
错误时返回:
json
{
  "success": false,
  "error": "错误信息"
}
All commands return JSON format:
json
{
  "success": true,
  "data": "Returned data"
}
In case of errors, it returns:
json
{
  "success": false,
  "error": "Error message"
}

Claude 使用方式

Usage with Claude

当用户需要查询 API 文档时:
  1. 理解需求:确定要查询的接口或模块
  2. 构建命令:根据需求选择合适的命令和参数
  3. 执行脚本:使用 Bash 工具运行
  4. 分析结果:解析返回的接口定义
示例工作流:
用户: "查看短信登录接口的定义"

Claude:
1. ./scripts/apifox search_paths --keyword "login sms"
2. 从结果中找到相关接口路径
3. ./scripts/apifox get_path --path "/api/global-auth/login/sms" --method POST
4. 分析返回的请求/响应结构
When users need to query API documents:
  1. Understand Requirements: Determine the interface or module to query
  2. Build Command: Select the appropriate command and parameters based on requirements
  3. Execute Script: Run using Bash tools
  4. Analyze Results: Parse the returned interface definitions
Example workflow:
User: "View the definition of the SMS login interface"

Claude:
1. ./scripts/apifox search_paths --keyword "login sms"
2. Find the relevant interface path from the results
3. ./scripts/apifox get_path --path "/api/global-auth/login/sms" --method POST
4. Analyze the returned request/response structure

性能说明

Performance Notes

  • HTTP 请求:首次使用或手动刷新时,通过 HTTP 请求从 Apifox API 获取
  • 本地缓存:数据缓存到插件目录,后续使用无需网络请求
  • 缓存持久:缓存永久有效,需要手动刷新获取最新文档
  • 搜索性能:基于内存索引,毫秒级响应
  • HTTP Requests: When used for the first time or manually refreshed, data is fetched from the Apifox API via HTTP requests
  • Local Cache: Data is cached in the plugin directory, no network requests are required for subsequent use
  • Persistent Cache: The cache is permanently valid, and manual refresh is required to get the latest documents
  • Search Performance: Based on in-memory indexing, with millisecond-level response

数据获取流程

Data Acquisition Process

首次使用

First Use

bash
undefined
bash
undefined

配置环境变量后首次运行

Run for the first time after configuring environment variables

./scripts/apifox stats
./scripts/apifox stats

输出示例:

Example output:

正在从 Apifox 获取项目 4105462 的 OpenAPI 文档...

Fetching OpenAPI documents for project 4105462 from Apifox...

✓ 成功获取 OpenAPI 文档

✓ Successfully obtained OpenAPI documents

接口数量: 4274

Number of interfaces: 4274

undefined
undefined

后续使用

Subsequent Uses

bash
undefined
bash
undefined

从本地缓存加载,秒级响应

Load from local cache, with second-level response

./scripts/apifox stats
./scripts/apifox stats

从本地缓存加载 OpenAPI 数据...

Loading OpenAPI data from local cache...

undefined
undefined

手动刷新

Manual Refresh

bash
undefined
bash
undefined

强制从 API 重新获取最新文档

Force re-fetch the latest documents from the API

./scripts/apifox refresh_oas
./scripts/apifox refresh_oas

输出示例:

Example output:

正在刷新 OpenAPI 文档...

Refreshing OpenAPI documents...

正在从 Apifox 获取项目 4105462 的 OpenAPI 文档...

Fetching OpenAPI documents for project 4105462 from Apifox...

✓ 成功获取 OpenAPI 文档

✓ Successfully obtained OpenAPI documents

接口数量: 4274

Number of interfaces: 4274

undefined
undefined

查看缓存状态

View Cache Status

bash
./scripts/apifox cache_status
bash
./scripts/apifox cache_status

文件结构

File Structure

scripts/
├── apifox.py           # 统一入口脚本
├── apifox_client.py    # API 文档客户端
├── cache_manager.py    # 缓存管理器
└── requirements.txt    # Python 依赖

references/
├── openapi-structure.md    # OpenAPI 结构说明
├── common-queries.md       # 常见查询示例
└── api-modules.md          # API 模块分类
scripts/
├── apifox.py           # Unified entry script
├── apifox_client.py    # API document client
├── cache_manager.py    # Cache manager
└── requirements.txt    # Python dependencies

references/
├── openapi-structure.md    # OpenAPI structure description
├── common-queries.md       # Common query examples
└── api-modules.md          # API module classification