SuperAPI AI Directory

apifox

Coding & development

View repository

Updated 10-15 08:13

About this skill

Apifox Skill

This skill provides the ABC Healthcare Cloud API documentation query feature, invoked uniformly through apifox.py .

Environment Configuration

Required Environment Variables

The Apifox Access Token must be configured before use:

# 设置 Apifox Access Token(必需)
export APIFOX_ACCESS_TOKEN="你的 Apifox Access Token"

# 设置项目 ID(可选,默认为 4105462)
export APIFOX_PROJECT_ID="4105462"

Obtaining the Apifox Access 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 in the environment variables

Dependency Installation

# 安装 Python 依赖
pip3 install requests

How It Works

apifox calls the Apifox API directly via HTTP requests:

  1. First use: Get the OpenAPI documentation from the Apifox API
  2. Local cache: Data is saved to the cache/ folder under the plugin directory
  3. Cache persistence: The cache is permanently valid; you need to refresh manually to get the latest documentation

Configuration Example

# 在 ~/.bashrc 或 ~/.zshrc 中添加
export APIFOX_ACCESS_TOKEN="apt_xxxxxxxxxxxxxxx"
export APIFOX_PROJECT_ID="4105462"

# 重新加载配置
source ~/.bashrc  # 或 source ~/.zshrc

Usage

./scripts/apifox <command> [参数]

Description:./scripts/apifox is a shell wrapper that automatically detects and uses an available Python interpreter on the system (python3 or python).

All commands return output in JSON format by default.

API Module Description

The ABC Healthcare Cloud API documentation contains the following modules:

Module Number of Endpoints Description
api 2506 HTTP API endpoints
rpc 1338 RPC service endpoints
api-weapp 294 Mini Program API endpoints
api-device 29 Device endpoints
api-mp 17 Official Account endpoints
api-external 14 External endpoints

Command List

Documentation Management

Command Description
read_oas Read the complete OpenAPI specification (approximately 5MB JSON)
refresh_oas Refresh/update the latest documentation (shows cache status)
cache_status View cache status and version
clear_cache Clear the local cache (requires the --force parameter)

Endpoint Query

Command Description
list_paths List endpoint paths (supports module and method filtering)
search_paths Search endpoints (keyword matching)
get_path Get details of a single endpoint (automatically resolves $ref)
list_modules List all modules and endpoint statistics

Data Analysis

Command Description
stats Display statistics (total number of endpoints, module distribution)
export_summary Export endpoint summaries (JSON/Markdown)

Usage Examples

Query Endpoint Details

# 获取指定接口的完整定义
./scripts/apifox get_path \
    --path "/api/global-auth/login/sms" \
    --method POST

# 获取接口但不解析 $ref(更快)
./scripts/apifox get_path \
    --path "/api/global-auth/login/sms" \
    --method POST \
    --include_refs false

Search Endpoints

# 搜索登录相关接口
./scripts/apifox search_paths --keyword "login"

# 搜索 api 模块中的用户相关接口
./scripts/apifox search_paths --keyword "user" --module api

# 列出所有 POST 接口
./scripts/apifox list_paths --method post --limit 20

Module Query

# 列出所有模块及统计
./scripts/apifox list_modules

# 列出小程序接口(前 20 个)
./scripts/apifox list_paths --module api-weapp --limit 20

Statistics

# 查看基本统计
./scripts/apifox stats

# 查看详细统计(包含各模块详情)
./scripts/apifox stats --detail

Cache Management

# 查看缓存状态
./scripts/apifox cache_status

# 刷新文档(强制从 API 重新获取最新数据)
./scripts/apifox refresh_oas

# 清除缓存
./scripts/apifox clear_cache --force

Export Summary

# 导出所有 API 模块接口摘要到 Markdown
./scripts/apifox export_summary --module api --output api_summary.md --format markdown

# 导出为 JSON
./scripts/apifox export_summary --output full_summary.json --format json

Output Format

All commands return JSON format:

{
  "success": true,
  "data": "返回的数据"
}

On error, returns:

{
  "success": false,
  "error": "错误信息"
}

How Claude Uses It

When the user needs to query API documentation:

  1. Understand the requirement: Determine the endpoint or module to query
  2. Build the command: Select the appropriate command and parameters based on your needs
  3. Execute the script: Run it using the Bash tool
  4. Analyze the results: Parse the returned interface definition

Example workflow:

用户: "查看短信登录接口的定义"

Claude:
1. ./scripts/apifox search_paths --keyword "login sms"
2. 从结果中找到相关接口路径
3. ./scripts/apifox get_path --path "/api/global-auth/login/sms" --method POST
4. 分析返回的请求/响应结构

Performance notes

  • HTTP request: On first use or manual refresh, fetch from the Apifox API via HTTP request
  • Local cache: Data is cached in the plugin directory, so no network request is needed for subsequent use
  • Cache persistence: The cache remains valid permanently; you need to refresh manually to get the latest documentation
  • Search performance: Based on an in-memory index, with millisecond-level response

Data retrieval process

First use

# 配置环境变量后首次运行
./scripts/apifox stats

# 输出示例:
# 正在从 Apifox 获取项目 4105462 的 OpenAPI 文档...
# API 端点: https://api.apifox.com/v1/projects/4105462/export/openapi
# ✓ 成功获取 OpenAPI 文档
#   接口数量: 4274

Subsequent use

# 从本地缓存加载,秒级响应
./scripts/apifox stats
# 从本地缓存加载 OpenAPI 数据...

Manual refresh

# 强制从 API 重新获取最新文档
./scripts/apifox refresh_oas

# 输出示例:
# 正在刷新 OpenAPI 文档...
# 正在从 Apifox 获取项目 4105462 的 OpenAPI 文档...
# ✓ 成功获取 OpenAPI 文档
#   接口数量: 4274

View cache status

./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 模块分类