Install
openclaw skills install ocr-passport-xiangyunXiangyun Platform Passport OCR Skill. Calls the Xiangyun API to perform structured recognition of passports from images, extracting fields such as passport number, name, sex, date of birth, date of issue, expiry date, issuing authority, nationality, and more. Supports both Base64 image stream and local file input. Trigger: use when the user mentions passport recognition, passport OCR, extracting passport information, or parsing passport images. On first use, guide the user to configure API credentials (key / secret), which are persisted to config.json in the skill directory.
openclaw skills install ocr-passport-xiangyunLeverages the Xiangyun Open Platform ID Document Recognition API to parse passport images structurally, supporting both Chinese and international passports. Recognized fields include: passport number, name, name (pinyin), sex, date of birth, place of birth, date of issue, expiry date, issuing authority, nationality, and more.
Product page: https://www.netocr.com/products.html
The following user expressions should trigger this skill:
Invoke scripts/config_manager.py to read the configuration:
python scripts/config_manager.py load
config.json in the skill root directorykey and secret, skip to Step 3Inform the user:
"Please sign up on the Xiangyun Platform (https://www.netocr.com), navigate to your account dashboard to obtain your ocrKey and ocrSecret, then provide them to me to complete the setup."
Once the key and secret are received:
python scripts/config_manager.py save --key YOUR_KEY --secret YOUR_SECRET
This saves the credentials to config.json in the skill root:
{
"key": "user's ocrKey",
"secret": "user's ocrSecret"
}
Supported input methods:
| Method | Description |
|---|---|
| Local file path | User provides an absolute or relative path |
| Base64 string | User pastes Base64-encoded data directly |
| URL (→ Base64) | Download image first, then convert to Base64 |
Run the recognition script:
# Local file (recommended — auto-saves results alongside the image)
python scripts/recognize.py --file /path/to/passport.jpg
# Base64 input
python scripts/recognize.py --base64 "BASE64_STRING_HERE"
# Human-readable table output
python scripts/recognize.py --file /path/to/passport.jpg --output-format table
# Disable auto-save (default: saves as {image_name}.json)
python scripts/recognize.py --file /path/to/passport.jpg --no-save
On success, results are automatically saved as {image_name}.json next to the source image, avoiding repeated API calls for later exports.
API parameters:
| Parameter | Value | Description |
|---|---|---|
typeId | 13 | Fixed value for passport recognition — do not change |
format | json | Return JSON format |
key | User credential | Loaded from config.json |
secret | User credential | Loaded from config.json |
Base64 endpoint: POST https://netocr.com/api/recogliu.do
File upload endpoint: POST https://netocr.com/api/recog.do
On success, display results as a table:
✅ Passport recognition successful
| Field | Value |
|--------------------|--------------------------|
| Passport Number | E12345678 |
| Name | ZHANG SAN |
| Pinyin | ZHANG SAN |
| Sex | Male |
| Date of Birth | 1990-01-01 |
| Place of Birth | Beijing |
| Date of Issue | 2020-06-01 |
| Expiry Date | 2030-06-01 |
| Issuing Authority | NIA |
| Nationality | China |
Only perform this step when the user explicitly requests exporting, saving, or generating a file.
Trigger examples: "export results", "save as Excel", "generate CSV", "export"
Prefer --from-dir to export directly from cached JSON results — zero API consumption.
# Recommended: read cached JSON results from image directory (no API calls)
python scripts/export.py --from-dir /path/to/images --format excel --output result.xlsx
python scripts/export.py --from-dir /path/to/images --format csv --output result.csv
# Pipe mode (recognize then export — for uncached results)
python scripts/recognize.py --file passport.jpg | python scripts/export.py --format csv --output result.csv
# Specific JSON file
python scripts/export.py --input result.json --format excel --output result.xlsx
Export priority: --from-dir > --batch-input > --input > stdin
| Error Code | Meaning | Action |
|---|---|---|
-1 | Recognition failed (poor image quality / no passport detected) | Ask user for a clearer passport image |
-2 | Parameter error | Check request parameters |
-3 | Insufficient service quota | Advise user to top up on Xiangyun Platform |
-4 | Authentication failed | Prompt user to verify key/secret and reconfigure |
-5 | Insufficient balance | Advise user to top up their Xiangyun account |
CONFIG_MISSING | Credentials not configured | Guide user through first-time setup |
On authentication failure, prompt the user to reset:
python scripts/config_manager.py reset
| Type | Recommended Specs |
|---|---|
| Photo | ~200 KB, 24-bit color depth or higher |
| Scanned | 300 DPI, file size < 3 MB |
| Format | JPG, PNG, BMP |
typeId is fixed at 13 — do not modify when calling the APIconfig.json is stored in the skill directory and contains sensitive credentials; do not commit to version control{image_name}.json alongside the source image; exports read from cache without additional API callsconfig_manager.py — Read, write, and reset configuration filesrecognize.py — Call the Xiangyun API to perform passport OCRexport.py — Export recognition results to CSV / Excel / JSONapi_docs.md — Complete Xiangyun Passport Recognition API reference (request parameters, response format, sample code)Public cloud sales hotline (server version OCR recognition software): Manager Yin [13810080484] [yinhm@sinosecu.com.cn]