Perform IP geolocation lookups using ipinfo.io API. Convert IP addresses to geographic data including city, region, country, postal code, timezone, and coordinates. Use when geolocating IPs, enriching IP data, or analyzing geographic distribution.
免费IP地理位置API。基础使用无需API密钥(每月5万次请求),可选令牌以获得更高限额。
IPINFO_TOKEN 环境变量是可选的——该技能无需令牌即可使用免费套餐。通过OpenClaw仪表盘UI配置可获得更高速率限制,或手动设置:
单个IP:
bash
curl -s https://ipinfo.io/8.8.8.8
当前IP:
bash
curl -s https://ipinfo.io/json
带令牌(可选,从环境变量获取):
bash
curl -s https://ipinfo.io/8.8.8.8?token=${IPINFO_TOKEN}
或直接传递令牌:
bash
curl -s https://ipinfo.io/8.8.8.8?token=YOUR_TOKEN
JSON响应包含:
使用 jq:
bash
curl -s https://ipinfo.io/8.8.8.8 | jq -r .city, .country, .loc
仅国家:
bash
curl -s https://ipinfo.io/8.8.8.8 | jq -r .country
解析坐标:
bash
curl -s https://ipinfo.io/8.8.8.8 | jq -r .loc | tr , \n
处理多个IP:
bash
for ip in 8.8.8.8 1.1.1.1 208.67.222.222; do
if [ -n $IPINFO_TOKEN ]; then
echo $ip: $(curl -s https://ipinfo.io/$ip?token=$IPINFO_TOKEN | jq -r .city, .country | tr \n , )
else
echo $ip: $(curl -s https://ipinfo.io/$ip | jq -r .city, .country | tr \n , )
fi
done
python
import os
import requests
从环境变量获取令牌:
python
import os
import requests
token = os.getenv(IPINFO_TOKEN)
if token:
response = requests.get(https://ipinfo.io/8.8.8.8, params={token: token})
else:
response = requests.get(https://ipinfo.io/8.8.8.8)
data = response.json()
或直接传递令牌:
python
response = requests.get(https://ipinfo.io/8.8.8.8, params={token: YOUR_TOKEN})
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 ipinfo-1776376642 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 ipinfo-1776376642 技能
skillhub install ipinfo-1776376642
文件大小: 1.91 KB | 发布时间: 2026-4-17 14:38