apifox
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseApifox Skill
Apifox Skill
本 skill 提供 ABC 医疗云 API 文档查询功能,统一通过 调用。
apifox.pyThis 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
undefinedYou 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"
undefinedexport APIFOX_PROJECT_ID="4105462"
undefined获取 Apifox Access Token
Obtain Apifox Access Token
- 登录 Apifox
- 进入账号设置 > API 访问令牌
- 创建新的访问令牌
- 复制 Token 并配置到环境变量
- Log in to Apifox
- Go to Account Settings > API Access Tokens
- Create a new access token
- Copy the Token and configure it into the environment variable
依赖安装
Dependency Installation
bash
undefinedbash
undefined安装 Python 依赖
Install Python dependencies
pip3 install requests
undefinedpip3 install requests
undefined工作原理
How It Works
apifox 直接通过 HTTP 请求调用 Apifox API:
- 首次使用:从 Apifox API 获取 OpenAPI 文档
- 本地缓存:数据保存到插件目录下的 文件夹
cache/ - 缓存持久:缓存永久有效,需要手动刷新获取最新文档
apifox directly calls the Apifox API via HTTP requests:
- First Use: Fetch OpenAPI documents from the Apifox API
- Local Cache: Data is saved to the folder under the plugin directory
cache/ - Persistent Cache: The cache is permanently valid, and manual refresh is required to get the latest documents
配置示例
Configuration Example
bash
undefinedbash
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
undefinedsource ~/.bashrc # or source ~/.zshrc
undefined使用方式
Usage
bash
./scripts/apifox <command> [参数]说明:是 shell wrapper,会自动检测并使用系统中可用的 Python 解释器(python3 或 python)。./scripts/apifox
所有命令默认返回 JSON 格式输出。
bash
./scripts/apifox <command> [parameters]Note:is a shell wrapper that automatically detects and uses the available Python interpreter (python3 or python) in the system../scripts/apifox
All commands return JSON format output by default.
API 模块说明
API Module Description
ABC 医疗云 API 文档包含以下模块:
| 模块 | 接口数量 | 说明 |
|---|---|---|
| api | 2506 | HTTP API 接口 |
| rpc | 1338 | RPC 服务接口 |
| api-weapp | 294 | 小程序 API 接口 |
| api-device | 29 | 设备接口 |
| api-mp | 17 | 公众号接口 |
| api-external | 14 | 外部接口 |
ABC Medical Cloud API documents include the following modules:
| Module | Number of Interfaces | Description |
|---|---|---|
| api | 2506 | HTTP API interfaces |
| rpc | 1338 | RPC service interfaces |
| api-weapp | 294 | Mini Program API interfaces |
| api-device | 29 | Device interfaces |
| api-mp | 17 | Official Account interfaces |
| api-external | 14 | External interfaces |
命令列表
Command List
文档管理
Document Management
| 命令 | 说明 |
|---|---|
| 读取完整 OpenAPI 规范(约 5MB JSON) |
| 刷新/更新最新文档(显示缓存状态) |
| 查看缓存状态和版本 |
| 清除本地缓存(需要 |
| Command | Description |
|---|---|
| Read the complete OpenAPI specification (about 5MB JSON) |
| Refresh/update the latest documents (shows cache status) |
| View cache status and version |
| Clear local cache (requires |
接口查询
Interface Query
| 命令 | 说明 |
|---|---|
| 列出接口路径(支持模块和方法过滤) |
| 搜索接口(关键词匹配) |
| 获取单个接口详情(自动解析 $ref) |
| 列出所有模块及接口统计 |
| Command | Description |
|---|---|
| List interface paths (supports module and method filtering) |
| Search interfaces (keyword matching) |
| Get details of a single interface (automatically resolves $ref) |
| List all modules and interface statistics |
数据分析
Data Analysis
| 命令 | 说明 |
|---|---|
| 显示统计信息(接口总数、模块分布) |
| 导出接口摘要(JSON/Markdown) |
| Command | Description |
|---|---|
| Display statistical information (total interfaces, module distribution) |
| Export interface summaries (JSON/Markdown) |
使用示例
Usage Examples
查询接口详情
Query Interface Details
bash
undefinedbash
undefined获取指定接口的完整定义
Get the complete definition of the specified interface
./scripts/apifox get_path
--path "/api/global-auth/login/sms"
--method POST
--path "/api/global-auth/login/sms"
--method POST
./scripts/apifox get_path
--path "/api/global-auth/login/sms"
--method POST
--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
--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
--path "/api/global-auth/login/sms"
--method POST
--include_refs false
undefined搜索接口
Search Interfaces
bash
undefinedbash
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
undefinedbash
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
undefinedbash
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
undefinedbash
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
undefinedbash
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 文档时:
- 理解需求:确定要查询的接口或模块
- 构建命令:根据需求选择合适的命令和参数
- 执行脚本:使用 Bash 工具运行
- 分析结果:解析返回的接口定义
示例工作流:
用户: "查看短信登录接口的定义"
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:
- Understand Requirements: Determine the interface or module to query
- Build Command: Select the appropriate command and parameters based on requirements
- Execute Script: Run using Bash tools
- 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
undefinedbash
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
undefinedundefined后续使用
Subsequent Uses
bash
undefinedbash
undefined从本地缓存加载,秒级响应
Load from local cache, with second-level response
./scripts/apifox stats
./scripts/apifox stats
从本地缓存加载 OpenAPI 数据...
Loading OpenAPI data from local cache...
undefinedundefined手动刷新
Manual Refresh
bash
undefinedbash
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
undefinedundefined查看缓存状态
View Cache Status
bash
./scripts/apifox cache_statusbash
./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