apifox

Original🇨🇳 Chinese
Translated
6 scripts

ABC Medical Cloud API Document Query Tool. Reads and queries the OpenAPI specification documents of ABC API (4209 interfaces), supports searching by module, path, and method, and automatically resolves $ref references. Usage scenarios: (1) Query API interface definitions (2) Search for interfaces with specific functions (3) Export interface document summaries (4) View interface statistics

1installs
Added on

NPX Install

npx skill4agent add abcfed/claude-marketplace apifox

Tags

Translated version includes tags in frontmatter

SKILL.md Content (Chinese)

View Translation Comparison →

Apifox Skill

This skill provides ABC Medical Cloud API document query functionality, which is uniformly called via
apifox.py
.

Environment Configuration

Required Environment Variables

You need to configure the Apifox Access Token before use:
bash
# Set Apifox Access Token (required)
export APIFOX_ACCESS_TOKEN="Your Apifox Access Token"

# Set Project ID (optional, default is 4105462)
export APIFOX_PROJECT_ID="4105462"

Obtain 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 into the environment variable

Dependency Installation

bash
# Install Python dependencies
pip3 install requests

How It Works

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
# Add to ~/.bashrc or ~/.zshrc
export APIFOX_ACCESS_TOKEN="apt_xxxxxxxxxxxxxxx"
export APIFOX_PROJECT_ID="4105462"

# Reload configuration
source ~/.bashrc  # or source ~/.zshrc

Usage

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 Module Description

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

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

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

CommandDescription
stats
Display statistical information (total interfaces, module distribution)
export_summary
Export interface summaries (JSON/Markdown)

Usage Examples

Query Interface Details

bash
# Get the complete definition of the specified interface
./scripts/apifox get_path \
    --path "/api/global-auth/login/sms" \
    --method POST

# Get the interface without resolving $ref (faster)
./scripts/apifox get_path \
    --path "/api/global-auth/login/sms" \
    --method POST \
    --include_refs false

Search Interfaces

bash
# Search for login-related interfaces
./scripts/apifox search_paths --keyword "login"

# Search for user-related interfaces in the api module
./scripts/apifox search_paths --keyword "user" --module api

# List all POST interfaces
./scripts/apifox list_paths --method post --limit 20

Module Query

bash
# List all modules and statistics
./scripts/apifox list_modules

# List Mini Program interfaces (first 20)
./scripts/apifox list_paths --module api-weapp --limit 20

Statistical Information

bash
# View basic statistics
./scripts/apifox stats

# View detailed statistics (includes module details)
./scripts/apifox stats --detail

Cache Management

bash
# View cache status
./scripts/apifox cache_status

# Refresh documents (force re-fetch latest data from API)
./scripts/apifox refresh_oas

# Clear cache
./scripts/apifox clear_cache --force

Export Summary

bash
# Export interface summaries of all API modules to Markdown
./scripts/apifox export_summary --module api --output api_summary.md --format markdown

# Export as JSON
./scripts/apifox export_summary --output full_summary.json --format json

Output Format

All commands return JSON format:
json
{
  "success": true,
  "data": "Returned data"
}
In case of errors, it returns:
json
{
  "success": false,
  "error": "Error message"
}

Usage with Claude

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 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
# Run for the first time after configuring environment variables
./scripts/apifox stats

# Example output:
# Fetching OpenAPI documents for project 4105462 from Apifox...
# API endpoint: https://api.apifox.com/v1/projects/4105462/export/openapi
# ✓ Successfully obtained OpenAPI documents
#   Number of interfaces: 4274

Subsequent Uses

bash
# Load from local cache, with second-level response
./scripts/apifox stats
# Loading OpenAPI data from local cache...

Manual Refresh

bash
# Force re-fetch the latest documents from the API
./scripts/apifox refresh_oas

# Example output:
# Refreshing OpenAPI documents...
# Fetching OpenAPI documents for project 4105462 from Apifox...
# ✓ Successfully obtained OpenAPI documents
#   Number of interfaces: 4274

View Cache Status

bash
./scripts/apifox cache_status

File Structure

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