特色栏目

ASP源码

PHP源码

.NET源码

JSP源码

游戏频道
专题合集
关闭菜单
首页> AI教程> 国家查询:适用于 AI 智能体的全球地理 API - Openclaw Skills

国家查询:适用于 AI 智能体的全球地理 API - Openclaw Skills

时间:2026-03-25 20:40:01 作者:互联网

什么是 国家查询?

国家查询技能是为在 Openclaw Skills 环境中运行的 AI 智能体设计的强大实用工具。它提供了与 REST Countries API (v3.1) 的无缝接口,使智能体能够检索详细信息,如首都、人口统计、货币和官方语言,且无需任何身份验证或 API 密钥。

通过集成此技能,开发人员可以增强智能体以高精度处理地理查询的能力。该工具处理 API 请求和数据解析的复杂性,提供结构化、易于阅读的格式,智能体可以轻松解释并呈现给用户。无论是通过字母代码查找国家,还是列出特定区域内的所有国家,此技能都可作为任何具有地理感知能力的 AI 应用的可靠参考层。

下载入口:https://github.com/openclaw/skills/tree/main/skills/jeffaf/countries

安装与下载

1. ClawHub CLI

从源直接安装技能的最快方式。

npx clawhub@latest install countries

2. 手动安装

将技能文件夹复制到以下位置之一

全局模式 ~/.openclaw/skills/ 工作区 /skills/

优先级:工作区 > 本地 > 内置

3. 提示词安装

将此提示词复制到 OpenClaw 即可自动安装。

请帮我使用 Clawhub 安装 countries。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。

国家查询 应用场景

国家查询 工作原理
  1. AI 智能体识别地理查询,并使用特定动作(搜索、信息或区域)调用国家命令。
  2. 技能脚本使用 curl 从 REST Countries API v3.1 请求数据。
  3. 原始 JSON 响应通过 jq 和 bc 处理,将人口等数值数据格式化为可读后缀(K、M、B)。
  4. 格式化后的文本(包括地图和国旗表情符号等元数据)返回给智能体。
  5. 智能体使用这些信息为人类用户制定详细的回复。

国家查询 配置指南

要在您的 Openclaw Skills 设置中使用此技能,请确保安装了以下系统依赖项:

sudo apt-get update
sudo apt-get install curl jq bc

脚本位于 {skill_folder}/countries。确保其具有执行权限:

chmod +x ./countries

国家查询 数据架构与分类体系

该技能将地理数据组织成适合 LLM 使用的结构化格式。以下是主要的数据映射:

字段 格式 描述
代码 Alpha-2 / Alpha-3 国际国家代码(例如:US, USA)
人口 数字 (后缀) 格式化的人口统计(例如:331M)
地区 字符串 主要地理区域和子区域
地图 URL 指向该位置 Google 地图的直接链接
国旗 表情符号 Unicode 国旗表示
name: countries
version: 1.0.0
description: "CLI for AI agents to lookup country info for their humans. Uses REST Countries API. No auth required."
homepage: https://restcountries.com
metadata:
  openclaw:
    emoji: "??"
    requires:
      bins: ["bash", "curl", "jq", "bc"]
    tags: ["countries", "geography", "reference", "api", "cli"]

Countries Lookup

CLI for AI agents to lookup country info for their humans. "What's the capital of Mongolia?" — now your agent can answer.

Uses REST Countries API (v3.1). No account or API key needed.

Usage

"Tell me about Japan"
"What countries are in South America?"
"Which country has Tokyo as capital?"
"Info on country code DE"

Commands

Action Command
Search by name countries search "query"
Get details countries info
List by region countries region
Search by capital countries capital "city"
List all countries all

Examples

countries search "united states"   # Find country by name
countries info US                  # Get full details by alpha-2 code
countries info USA                 # Also works with alpha-3
countries region europe            # All European countries
countries capital tokyo            # Find country by capital
countries all                      # List all countries (sorted)

Regions

Valid regions: africa, americas, asia, europe, oceania

Output

Search/list output:

[US] United States — Washington D.C., Americas, Pop: 331M, ????

Info output:

?? Japan
   Official: Japan
   Code: JP / JPN / 392
   Capital: Tokyo
   Region: Asia — Eastern Asia
   Population: 125.8M
   Area: 377930 km2
   Languages: Japanese
   Currencies: Japanese yen (JPY)
   Timezones: UTC+09:00
   Borders: None (island/isolated)
   Driving: left side
   Flag: ????

??? Map: https://goo.gl/maps/...

Notes


Agent Implementation Notes

Script location: {skill_folder}/countries (wrapper to scripts/countries)

When user asks about countries:

  1. Run ./countries search "name" to find country code
  2. Run ./countries info for full details
  3. Run ./countries region for regional lists
  4. Run ./countries capital "city" to find by capital

Common patterns:

  • "What country is X in?" → search by name
  • "Tell me about X" → search, then info with code
  • "Countries in Europe" → region europe
  • "Capital of X" → info with code, check capital field
  • "What country has capital X?" → capital search

Don't use for: Historical countries, disputed territories, non-sovereign regions.

返回顶部