This skill provides a command-line interface for GuanYuan Data (观远数据) API. It supports multiple authentication methods, automatic token management, card data retrieval, and CSV export with metadata generation.
When a user requests GuanYuan data operations:
Choose authentication method:
loginId and password in config for automatic logintoken directly in config fileguanyuan token <token> command to set token interactivelyGet card data: Use guanyuan card <cardId> to retrieve data in JSON format
Export to CSV: Use guanyuan csv <cardId> --output file.csv to export data
json
{
"baseUrl": "https://your-guanyuan-domain.com",
"domain": "your-domain",
"loginId": "your-login-id",
"password": "your-password"
}
Then run: guanyuan login
json
{
"baseUrl": "https://your-guanyuan-domain.com",
"domain": "your-domain",
"token": "your-token-here"
}
No login needed, directly use commands.
json
{
"baseUrl": "https://your-guanyuan-domain.com",
"domain": "your-domain"
}
Then run: guanyuan token <your-token> or guanyuan token (interactive)
scripts/guanyuan.js: Main CLI tool
login(): Authenticate and save tokengetCardData(cardId, options): Retrieve card dataconvertToCSV(cardData, sampleRows): Convert data to CSV formatextractMetadata(cardData): Extract field metadatasaveCSVWithMetadata(csv, filename, metadata, cardId): Save CSV and metadata filesgetValidToken(config): Auto-discover and use valid token from multiple sources~/.guanyuan/config.json: API credentials and settings
baseUrl, domainloginId + password, token, or none (use token command)~/.guanyuan/user.token: Stored authentication token (auto-managed)
CommandDescriptionExampleinitInitialize configuration (show setup instructions)guanyuan init``loginLogin with credentials from configguanyuan login``token [token]Set token (via parameter or interactive)guanyuan token eyJ0eX...``card <id>Get card data (JSON)guanyuan card abc123 --limit 50``csv <id>Export to CSVguanyuan csv abc123 --output data.csv``statusShow config and token statusguanyuan status``helpShow helpguanyuan help
OptionDescriptionDefault--view <GRAPH|GRID>Data view typeGRAPH--limit <number>Number of rows100--offset <number>Data offset0
OptionDescriptionDefault--output <filename>Output to filestdout--sample <number>Sample N rowsall rows
text
┌─────────────────────────────────────────────────────────────┐
│ User wants to access GuanYuan data │
└────────────────────┬────────────────────────────────────────┘
│
v
┌─────────────────────────────────────────────────────────────┐
│ Check ~/.guanyuan/user.token │
│ Is there a valid token? │
└────────────────────┬────────────────────────────────────────┘
│
┌────────┴────────┐
│ │
Yes │ │ No
│ │
v v
┌───────────────────┐ ┌──────────────────────────────────┐
│ Use saved token │ │ Check config.json │
└───────────────────┘ │ - Has loginId + password? │
│ - Has token? │
│ - Neither? → Use token command │
└────────────┬─────────────────────┘
│
┌──────────────┼──────────────┐
│ │ │
Has Creds Has Token Neither
│ │ │
v v v
┌───────────┐ ┌───────────┐ ┌───────────────┐
│ Auto │ │ Use │ │ Prompt user │
│ Login │ │ Config │ │ to run │
│ │ │ Token │ │ 'guanyuan │
└───────────┘ └───────────┘ │ token' │
└───────────────┘
When exporting CSV with --output, a _meta.json file is automatically generated:
json
{
"cardId": "card-id",
"cardType": "CHART",
"chartType": "PIVOT_TABLE",
"view": "GRAPH",
"exportTime": "2026-03-25T07:52:00.924Z",
"totalRows": 10,
"dataLimit": 10,
"hasMoreData": false,
"fields": [
{
"name": "字段显示名称",
"originalName": "字段原始名称",
"type": "STRING/TIMESTAMP/DOUBLE",
"metaType": "DIM/METRIC",
"fieldType": "dimension/metric",
"fieldId": "field-id"
}
]
}
~/.guanyuan/user.token - Saved token (highest priority)config.json - Token field in configloginId + password from configbash
# Via parameter
guanyuan token eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...
# Interactive mode
guanyuan token
# Then paste your token when prompted
--limit to control API response size--sample to export only N rows without fetching all data