IPGeolocation/cli
GitHub: IPGeolocation/cli
IPGeolocation.io 官方命令行工具,提供 IP 地理定位、威胁情报、ASN、时区和 User-Agent 解析等一体化查询能力。
Stars: 7 | Forks: 1
# IPGeolocation.io CLI 工具
## 概述
官方 `ipgeolocation` **命令行接口 (CLI)** 提供了一种快速、轻量级且脚本友好的方式,可直接从终端访问 **[IPGeolocation.io](https://ipgeolocation.io)** 的 API 集合。它使开发者、DevOps 工程师、网络运维人员和安全团队能够检索 IP 情报,而无需编写任何代码或处理原始 HTTP 请求。
使用单个可执行文件,您可以查询您自己的 IP 或任何 IPv4、IPv6 地址或域名的 **IP 位置、安全情报、ASN 详情、时区、天文、滥用联系信息以及 User Agent 解析**。CLI 输出结构化、机器可读的数据,可无缝集成到 Shell 脚本、Cron 作业、CI/CD 流水线、监控系统和日志处理工作流中。
- [IP Location API](https://ipgeolocation.io/ip-location-api.html): 获取一体化解决方案,包括 **位置**(城市、地区、州/省、国家、精度半径、置信度等)、**货币**、**ASN**(AS 编号、ASN 名称、组织、ASN 类型、分配日期、路由、上游、下游、对等体)、**公司**(公司/ISP 名称、公司类型、公司域名)、**时区**、**User Agent** 字符串解析、**安全**(威胁评分、is_tor、is_bot、proxy_provider、cloud_provider、relay_provider、vpn_provider、proxy、relay、vpn)以及 **滥用联系**(路由/CIDR 网络、国家、地址、电子邮件、电话号码)信息。
- [IP Security API](https://ipgeolocation.io/ip-security-api.html): 获取安全、网络、位置、主机名、时区和 UserAgent 解析。
- [ASN API](https://ipgeolocation.io/asn-api.html): 获取 ASN 详情以及 Peers、Upstreams、Downstreams、路由和原始 WHOIS。
- [Abuse Contact API](https://ipgeolocation.io/ip-abuse-contact-api.html): 获取滥用举报电子邮件、电话号码、类型、组织、路由/CIDR 网络和国家。
- [Astronomy API](https://ipgeolocation.io/astronomy-api.html): 获取日出、日落、月出、月落、月相以及精确的晨昏时段,结合位置信息。
- [Timezone API](https://ipgeolocation.io/timezone-api.html): 获取时区名称、多种时间格式、夏令时状态及其详情,结合位置信息。
- [Timezone Convert API](https://ipgeolocation.io/timezone-api.html): 在时区名称、地理坐标、位置地址、IATA 代码、ICAO 代码或 UN/LOCODE 之间转换时间。
- [User Agent API](https://ipgeolocation.io/user-agent-api.html): 通过单个或多个 Useragent 字符串解析获取浏览器、操作系统和设备信息。
`ipgeolocation` CLI 专为速度和自动化而构建,可轻松将 IP 情报集成到 Shell 脚本、Bash 管道、Cron 作业和 CI/CD 工作流中。它可以丰富服务器日志、防火墙事件和 SIEM 数据,支持在事件响应期间进行即时查询,并实现无需特定语言依赖的自动化欺诈检测、基于地理位置的路由和访问控制。CLI 专为系统管理员、DevOps 工程师和开发者设计,可直接从终端提供一致且可靠的洞察。
基于:
- API 版本:3.0.0
**官方发布:**
- 可在 [**pkg.go.dev**](https://pkg.go.dev/github.com/IPGeolocation/cli) 和 [**GitHub Releases**](https://github.com/IPGeolocation/cli/releases) 获取
- 源代码:[**GitHub Repository**](https://github.com/IPGeolocation/cli)
## 目录
1. [环境要求](#requirements)
2. [安装](#installation)
- [Go install](#go-install)
- [下载并从源码构建](#download-and-build-from-source)
- [使用下载预编译二进制文件](#using-download-prebuilt-binaries)
- [故障排除](#troubleshooting)
3. [API 文档链接](#api-documentations)
4. [字段与命令可用性](#fields-and-commands-availability)
5. [认证设置](#authentication-setup)
- [如何获取您的 API Key](#how-to-get-your-api-key)
- [ApiKeyAuth](#apikeyauth)
6. [全局 Flags](#global-flags)
7. [命令](#commands)
- [`config` 命令](#config-command)
- [`config` 用法](#config-usage)
- [`config` 的 Flags](#flags-for-config)
- [`ipgeo` 命令](#ipgeo-command)
- [`ipgeo` 用法](#ipgeo-usage)
- [`ipgeo` 的 Flags](#flags-for-ipgeo)
- [开发者计划示例](#developer-plan-examples)
- [付费计划示例](#paid-plan-examples)
- [`bulk-ip-geo` 命令](#bulk-ip-geo-command)
- [`bulk-ip-geo` 用法](#bulk-ip-geo-usage)
- [`bulk-ip-geo` 的 Flags](#flags-for-bulk-ip-geo)
- [输出格式](#output-formats)
- [`ip-security` 命令](#ip-security-command)
- [`ip-security` 用法](#ip-security-usage)
- [`ip-security` 的 Flags](#flags-for-ip-security)
- [在 `ip-security` 中获取默认字段](#get-default-fields-in-ip-security)
- [在 `ip-security` 中使用字段过滤进行请求](#request-with-field-filtering-ip-security)
- [`bulk-ip-security` 命令](#bulk-ip-security-command)
- [`bulk-ip-security` 用法](#bulk-ip-security-usage)
- [`bulk-ip-security` 的 Flags](#flags-for-bulk-ip-security)
- [`bulk-ip-security` 示例](#bulk-ip-security-examples)
- [`asn` 命令](#asn-command)
- [`asn` 用法](#asn-usage)
- [`asn` 的 Flags](#flags-for-asn)
- [获取您 IP 的 ASN 信息](#get-asn-information-of-your-ip)
- [通过 ASN 编号获取 ASN 信息](#get-asn-information-by-asn-number)
- [使用 Include 组合所有对象](#combine-all-objects-using-include)
- [`abuse` 命令](#abuse-command)
- [`abuse` 用法](#abuse-usage)
- [`abuse` 的 Flags](#flags-for-abuse)
- [获取关于您当前 IP 的滥用信息](#get-abuse-info-about-your-current-ip)
- [查询特定 IP](#lookup-a-specific-ip)
- [排除不必要的字段](#exclude-unnecessary-fields)
- [查询特定字段的滥用联系信息](#lookup-abuse-contact-with-specific-fields)
- [`timezone` 命令](#timezone-command)
- [`timezone` 用法](#timezone-usage)
- [`timezone` 的 Flags](#flags-for-timezone)
- [获取关于您当前 IP 的时区信息](#get-timezone-info-about-your-current-ip)
- [获取特定 IP 地址的时区](#get-timezone-for-a-specific-ip-address)
- [按时区名称获取时区](#get-timezone-by-timezone-name)
- [从任意地址获取时区](#get-timezone-from-any-address)
- [从位置坐标获取时区](#get-timezone-from-location-coordinates)
- [从 IATA 代码获取时区和机场详情](#get-timezone-and-airport-details-from-iata-code)
- [从 UN/LOCODE 获取时区和城市详情](#get-timezone-and-city-details-from-unlocode)
- [`time-conversion` 命令](#time-conversion-command)
- [`time-conversion` 用法](#time-conversion-usage)
- [`time-conversion` 的 Flags](#flags-for-time-conversion)
- [将当前时间从一个时区转换到另一个时区](#convert-current-time-from-one-timezone-to-another)
- [`astronomy` 命令](#astronomy-command)
- [`astronomy` 用法](#astronomy-usage)
- [`astronomy` 的 Flags](#flags-for-astronomy)
- [通过坐标查询 Astronomy API](#lookup-astronomy-api-by-coordinates)
- [通过 IP 地址查询 Astronomy API](#lookup-astronomy-api-by-ip-address)
- [通过位置字符串查询 Astronomy API](#lookup-astronomy-api-by-location-string)
- [`astronomy-timeseries` 命令](#astronomy-timeseries-command)
- [`astronomy-timeseries` 用法](#astronomy-timeseries-usage)
- [`astronomy-timeseries` 的 Flags](#flags-for-astronomy-timeseries)
- [获取 IP 地址的天文时间序列信息](#get-astronomy-timeseries-info-for-an-ip-address)
- [获取特定纬度和经度的天文时间序列信息](#get-astronomy-timeseries-about-a-specific-lat-and-lon)
- [获取特定位置的天文时间序列信息](#get-astronomy-timeseries-about-a-specific-location)
- [`parse-user-agent` 命令](#parse-user-agent-command)
- [`parse-user-agent` 用法](#parse-user-agent-usage)
- [`parse-user-agent` 的 Flags](#flags-for-parse-user-agent)
- [解析 User Agent 字符串](#parse-a-user-agent-string)
- [`parse-bulk-user-agents` 命令](#parse-bulk-user-agents-command)
- [`parse-bulk-user-agents` 用法](#parse-bulk-user-agents-usage)
- [`parse-bulk-user-agents` 的 Flags](#flags-for-parse-bulk-user-agents)
- [解析多个 User Agent 字符串](#parse-multiple-user-agent-strings)
- [许可证](#license)
## 环境要求
- Go 1.18+
- 来自 [IPGeolocation.io](https://ipgeolocation.io) 的 API Key
## 安装
### Go 安装
要使用 `go install` 安装 `ipgeolocation`,请运行:
```
go install github.com/IPGeolocation/cli/v2/cmd/ipgeolocation@latest
```
确保 `$GOBIN` 或 `$GOPATH/bin` 位于您的 `PATH` 中,然后运行:
```
ipgeolocation --help
```
### 下载并从源码构建
```
git clone https://github.com/IPGeolocation/cli.git
cd cli
go build -o ipgeolocation ./cmd/ipgeolocation
./ipgeolocation --help
```
此处您同样需要将 `$GOBIN` 或 `$GOPATH/bin` 添加到您的 `PATH` 中。
### 使用下载预编译二进制文件
#### 概述
这些是 IPGeolocation CLI 工具的预编译二进制文件,版本 **2.0.0**。用户可以直接从 [GitHub Releases](https://github.com/IPGeolocation/cli/releases) 或下表下载这些文件,无需从源代码构建。
CLI 提供地理位置信息、时区、User-Agent 解析、批量 IP 查询等功能。
#### 预编译二进制文件
| 平台 | 架构 | 文件名 / 下载链接 |
|----------|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
| Linux | amd64 | [**ipgeolocation-2.0.1-linux-amd64.tar.gz**](https://github.com/IPGeolocation/cli/releases/download/v2.0.0/ipgeolocation-2.0.1-linux-amd64.tar.gz) |
| Linux | arm64 | [**ipgeolocation-2.0.1-linux-arm64.tar.gz**](https://github.com/IPGeolocation/cli/releases/download/v2.0.0/ipgeolocation-2.0.1-linux-arm64.tar.gz) |
| macOS | amd64 | [**ipgeolocation-2.0.1-darwin-amd64.tar.gz**](https://github.com/IPGeolocation/cli/releases/download/v2.0.0/ipgeolocation-2.0.1-darwin-amd64.tar.gz) |
| macOS | arm64 | [**ipgeolocation-2.0.1-darwin-arm64.tar.gz**](https://github.com/IPGeolocation/cli/releases/download/v2.0.0/ipgeolocation-2.0.1-darwin-arm64.tar.gz) |
| Windows | amd64 | [**ipgeolocation-2.0.1-windows-amd64.zip**](https://github.com/IPGeolocation/cli/releases/download/v2.0.0/ipgeolocation-2.0.1-windows-amd64.zip) |
#### 安装说明
**Linux:**
1. 下载适用于您架构的 `.tar.gz` 文件。
2. 将其解压到 PATH 中的文件夹,例如 `/usr/local/bin`:
tar -xzf ipgeolocation-2.0.1-linux-amd64.tar.gz -C /usr/local/bin
3. 为方便起见,重命名二进制文件:
mv /usr/local/bin/ipgeolocation-2.0.1-linux-amd64 /usr/local/bin/ipgeolocation
4. 使二进制文件可执行:
chmod +x /usr/local/bin/ipgeolocation
5. 验证安装:
ipgeolocation --help
**macOS:**
1. 下载适用于您架构的 `.tar.gz` 文件(amd64 或 arm64)。
2. 解压到 PATH 中的文件夹,例如 `/usr/local/bin`:
tar -xzf ipgeolocation-2.0.1-darwin-amd64.tar.gz -C /usr/local/bin
3. 重命名二进制文件:
mv /usr/local/bin/ipgeolocation-2.0.1-darwin-amd64 /usr/local/bin/ipgeolocation
4. 使其可执行:
chmod +x /usr/local/bin/ipgeolocation
5. 验证安装:
ipgeolocation --help
**Windows:**
1. 下载 `.zip` 文件。
2. 将 `ipgeolocation-2.0.1-windows-amd64.exe` 解压到系统 `PATH` 包含的文件夹中。
3. 为方便起见,将二进制文件重命名为 `ipgeolocation.exe`。
4. 打开命令提示符并验证:
ipgeolocation --help
### 故障排除
- **找不到命令:** 确保二进制文件位于包含在您的 `PATH` 中的文件夹内。
- **执行权限错误:** 在 Linux/macOS 上运行 `chmod +x `。
- **架构错误:** 下载与您的操作系统和 CPU 架构匹配的二进制文件。
- **Go install 问题:** 如果 Go 模块代理缓存导致问题,请使用 `GOPROXY=direct`。
## API 文档
以下文档对应可用的 API:
- [**概述**](https://ipgeolocation.io/documentation.html)
- [**IP GeoLocation API**](https://ipgeolocation.io/documentation/ip-location-api.html)
- [**IP Security API**](
```
## 全局 Flags
这些 Flags 适用于所有命令:
| Flag | 描述 |
|--------------|----------------------------|
| `-h, --help` | 显示命令的帮助信息。 |
```
ipgeolocation --version
```
## 命令
### `config` 命令
为 **[ipgeolocation.io](https://ipgeolocation.io/)** 配置您的 API Key。
#### `config` 用法
```
ipgeolocation config --apikey=
```
#### `config` 的 Flags
| Flag | 类型 | 描述 |
|------------|--------|-----------------------------------------------------------------|
| `--apikey` | string | 您来自 [ipgeolocation.io](https://ipgeolocation.io) 的 API Key。 |
### `ipgeo` 命令
从 `ipgeolocation.io` API 查询单个 IP 地址或域名的地理位置信息。
#### `ipgeo` 用法
```
ipgeolocation ipgeo [flags]
```
#### `ipgeo` 的 Flags
| Flag | 类型 | 默认值 | 描述 |
|--------------|----------|----------|---------------------------------------------------------------------------------|
| `--ip` | string | `""` | IPv4、IPv6 或域名(例如 `8.8.8.8`、`google.com`)。 |
| `--include` | string[] | `[]` | 包含额外字段(例如 `hostname,geo_accuracy,dma_code,security,abuse,user_agent`)。 |
| `--fields` | string[] | `[]` | 仅返回特定字段(例如 `location,asn.organization`)。 |
| `--excludes` | string[] | `[]` | 从输出中排除字段。 |
| `--lang` | string | `""` | 响应语言。 |
| `--output` | string | `pretty` | 输出格式:`pretty`、`raw`、`table`、`yaml`。 |
#### 开发者计划示例
获取关于您当前 IP 的信息:
```
ipgeolocation ipgeo
```
##### 在开发者计划中获取默认字段
查询特定 IP:
```
ipgeolocation ipgeo --ip 8.8.8.8
```
示例输出:
```
{
"ip": "8.8.8.8",
"asn": {
"as_number": "AS15169",
"country": "US",
"organization": "Google LLC"
},
"country_metadata": {
"calling_code": "+1",
"languages": [
"en-US",
"es-US",
"haw",
"fr"
],
"tld": ".us"
},
"currency": {
"code": "USD",
"name": "US Dollar",
"symbol": "$"
},
"location": {
"city": "Mountain View",
"continent_code": "NA",
"continent_name": "North America",
"country_capital": "Washington, D.C.",
"country_code2": "US",
"country_code3": "USA",
"country_emoji": "🇺🇸",
"country_flag": "https://ipgeolocation.io/static/flags/us_64.png",
"country_name": "United States",
"country_name_official": "United States of America",
"district": "Santa Clara",
"geoname_id": "6301403",
"is_eu": false,
"latitude": "37.42240",
"longitude": "-122.08421",
"state_code": "US-CA",
"state_prov": "California",
"zipcode": "94043-1351"
},
"time_zone": {
"current_time": "2026-03-03 03:01:15.329-0800",
"current_time_unix": 1772535675.329,
"current_tz_abbreviation": "PST",
"current_tz_full_name": "Pacific Standard Time",
"dst_end": {
"date_time_after": "2026-11-01 TIME 01:00",
"date_time_before": "2026-11-01 TIME 02:00",
"duration": "-1.00H",
"gap": false,
"overlap": true,
"utc_time": "2026-11-01 TIME 09:00"
},
"dst_exists": true,
"dst_savings": 0,
"dst_start": {
"date_time_after": "2026-03-08 TIME 03:00",
"date_time_before": "2026-03-08 TIME 02:00",
"duration": "+1.00H",
"gap": true,
"overlap": false,
"utc_time": "2026-03-08 TIME 10:00"
},
"dst_tz_abbreviation": "PDT",
"dst_tz_full_name": "Pacific Daylight Time",
"is_dst": false,
"name": "America/Los_Angeles",
"offset": -8,
"offset_with_dst": -8,
"standard_tz_abbreviation": "PST",
"standard_tz_full_name": "Pacific Standard Time"
}
}
```
使用 `--fields` 和 `--excludes` 过滤响应:
```
ipgeolocation ipgeo --ip 8.8.8.8 --fields=location --excludes location.continent_code,location.continent_name
```
示例输出:
```
{
"ip": "8.8.8.8",
"location": {
"city": "Mountain View",
"country_capital": "Washington, D.C.",
"country_code2": "US",
"country_code3": "USA",
"country_emoji": "🇺🇸",
"country_flag": "https://ipgeolocation.io/static/flags/us_64.png",
"country_name": "United States",
"country_name_official": "United States of America",
"district": "Santa Clara",
"geoname_id": "6301403",
"is_eu": false,
"latitude": "37.42240",
"longitude": "-122.08421",
"state_code": "US-CA",
"state_prov": "California",
"zipcode": "94043-1351"
}
}
```
#### 付费计划示例
##### 在付费计划中获取默认字段
使用默认字段查询域名
```
ipgeolocation ipgeo --ip google.com
```
示例输出:
```
{
"asn": {
"as_number": "AS15169",
"country": "US",
"date_allocated": "2000-03-30",
"domain": "google.com",
"organization": "Google LLC",
"rir": "ARIN",
"type": "BUSINESS"
},
"company": {
"domain": "google.com",
"name": "Google LLC",
"type": "HOSTING"
},
"country_metadata": {
"calling_code": "+65",
"languages": [
"cmn",
"en-SG",
"ms-SG",
"ta-SG",
"zh-SG"
],
"tld": ".sg"
},
"currency": {
"code": "SGD",
"name": "Singapore Dollar",
"symbol": "S$"
},
"domain": "google.com",
"ip": "142.250.4.100",
"location": {
"city": "Singapore",
"continent_code": "AS",
"continent_name": "Asia",
"country_capital": "Singapore",
"country_code2": "SG",
"country_code3": "SGP",
"country_emoji": "🇸🇬",
"country_flag": "https://ipgeolocation.io/static/flags/sg_64.png",
"country_name": "Singapore",
"country_name_official": "Republic of Singapore",
"district": "Singapore",
"geoname_id": "6951474",
"is_eu": false,
"latitude": "1.29041",
"longitude": "103.85211",
"state_code": "SG-01",
"state_prov": "Central Singapore Community Development Council",
"zipcode": "17"
},
"network": {
"connection_type": "",
"is_anycast": false,
"route": "142.250.4.0/24"
},
"time_zone": {
"current_time": "2026-03-03 19:03:29.994+0800",
"current_time_unix": 1772535809.994,
"current_tz_abbreviation": "SGT",
"current_tz_full_name": "Singapore Standard Time",
"dst_end": {},
"dst_exists": false,
"dst_savings": 0,
"dst_start": {},
"dst_tz_abbreviation": "",
"dst_tz_full_name": "",
"is_dst": false,
"name": "Asia/Singapore",
"offset": 8,
"offset_with_dst": 8,
"standard_tz_abbreviation": "SGT",
"standard_tz_full_name": "Singapore Standard Time"
}
}
```
##### 以多种语言检索地理位置数据
以下是一个获取 IP 地址 '2001:4230:4890::1' 法语 `fr` 地理位置数据的示例:
```
ipgeolocation ipgeo --ip 2001:4230:4890::1 --lang fr
```
示例输出:
```
{
"asn": {
"as_number": "AS0",
"country": "",
"date_allocated": "",
"domain": "",
"organization": "",
"rir": "",
"type": ""
},
"company": {
"domain": "afrinic.net",
"name": "African Network Information Center AfriNIC Ltd",
"type": "BUSINESS"
},
"country_metadata": {
"calling_code": "+230",
"languages": [
"en-MU",
"bho",
"fr"
],
"tld": ".mu"
},
"currency": {
"code": "MUR",
"name": "Mauritius Rupee",
"symbol": "₨"
},
"ip": "2001:4230:4890:0:0:0:0:1",
"location": {
"city": "Quatre Bornes",
"continent_code": "AF",
"continent_name": "Afrique",
"country_capital": "Port Louis",
"country_code2": "MU",
"country_code3": "MUS",
"country_emoji": "🇲🇺",
"country_flag": "https://ipgeolocation.io/static/flags/mu_64.png",
"country_name": "Maurice",
"country_name_official": "",
"district": "Quatre Bornes",
"geoname_id": "1106777",
"is_eu": false,
"latitude": "-20.24304",
"longitude": "57.49631",
"state_code": "MU-PW",
"state_prov": "Wilhems des plaines",
"zipcode": "72201"
},
"network": {
"connection_type": "",
"is_anycast": false,
"route": ""
},
"time_zone": {
"current_time": "2026-03-03 15:04:29.479+0400",
"current_time_unix": 1772535869.479,
"current_tz_abbreviation": "MUT",
"current_tz_full_name": "Mauritius Standard Time",
"dst_end": {},
"dst_exists": false,
"dst_savings": 0,
"dst_start": {},
"dst_tz_abbreviation": "",
"dst_tz_full_name": "",
"is_dst": false,
"name": "Indian/Mauritius",
"offset": 4,
"offset_with_dst": 4,
"standard_tz_abbreviation": "MUT",
"standard_tz_full_name": "Mauritius Standard Time"
}
}
```
##### 包含主机名和 User-Agent
```
ipgeolocation ipgeo --ip 219.100.37.207 --include hostname,user_agent
```
示例输出:
```
{
"asn": {
"as_number": "AS36599",
"country": "US",
"date_allocated": "2017-01-25",
"domain": "rt.open.ad.jp",
"organization": "SoftEther Telecommunication Research Institute, LLC",
"rir": "ARIN",
"type": "ISP"
},
"company": {
"domain": "softether.co.jp",
"name": "SoftEther Corporation",
"type": "BUSINESS"
},
"country_metadata": {
"calling_code": "+81",
"languages": [
"ja"
],
"tld": ".jp"
},
"currency": {
"code": "JPY",
"name": "Yen",
"symbol": "¥"
},
"hostname": "public-vpn-13-15.vpngate.v4.open.ad.jp",
"ip": "219.100.37.207",
"location": {
"city": "Tokyo",
"continent_code": "AS",
"continent_name": "Asia",
"country_capital": "Tokyo",
"country_code2": "JP",
"country_code3": "JPN",
"country_emoji": "🇯🇵",
"country_flag": "https://ipgeolocation.io/static/flags/jp_64.png",
"country_name": "Japan",
"country_name_official": "Japan",
"district": "Koto",
"geoname_id": "12149683",
"is_eu": false,
"latitude": "35.68467",
"longitude": "139.80881",
"state_code": "JP-13",
"state_prov": "Tokyo Metropolis",
"zipcode": "135-0022"
},
"network": {
"connection_type": "",
"is_anycast": false,
"route": "219.100.37.0/24"
},
"time_zone": {
"current_time": "2026-03-03 20:05:37.058+0900",
"current_time_unix": 1772535937.058,
"current_tz_abbreviation": "JST",
"current_tz_full_name": "Japan Standard Time",
"dst_end": {},
"dst_exists": false,
"dst_savings": 0,
"dst_start": {},
"dst_tz_abbreviation": "",
"dst_tz_full_name": "",
"is_dst": false,
"name": "Asia/Tokyo",
"offset": 9,
"offset_with_dst": 9,
"standard_tz_abbreviation": "JST",
"standard_tz_full_name": "Japan Standard Time"
},
"user_agent": {
"device": {
"brand": "GO",
"cpu": "Unknown",
"name": "GO Http Client",
"type": "Robot"
},
"engine": {
"name": "Go-http-client",
"type": "Robot",
"version": "2.0",
"version_major": "2"
},
"name": "Go-http-client",
"operating_system": {
"build": "??",
"name": "Cloud",
"type": "Cloud",
"version": "??",
"version_major": "??"
},
"type": "Robot",
"user_agent_string": "Go-http-client/2.0",
"version": "2.0",
"version_major": "2"
}
}
```
##### 包含 DMA、滥用和安全
```
ipgeolocation ipgeo --ip 8.8.8.8 --include dma_code,abuse,security
```
示例输出:
```
{
"abuse": {
"address": "1600 Amphitheatre Parkway\nMountain View\nCA\n94043\nUnited States",
"country": "",
"emails": [
"network-abuse@google.com"
],
"kind": "group",
"name": "Abuse",
"organization": "Abuse",
"phone_numbers": [
"+1-650-253-0000"
],
"route": "8.8.8.0/24"
},
"asn": {
"as_number": "AS15169",
"country": "US",
"date_allocated": "2000-03-30",
"domain": "google.com",
"organization": "Google LLC",
"rir": "ARIN",
"type": "BUSINESS"
},
"company": {
"domain": "google.com",
"name": "Google LLC",
"type": "HOSTING"
},
"country_metadata": {
"calling_code": "+1",
"languages": [
"en-US",
"es-US",
"haw",
"fr"
],
"tld": ".us"
},
"currency": {
"code": "USD",
"name": "US Dollar",
"symbol": "$"
},
"ip": "8.8.8.8",
"location": {
"city": "Mountain View",
"continent_code": "NA",
"continent_name": "North America",
"country_capital": "Washington, D.C.",
"country_code2": "US",
"country_code3": "USA",
"country_emoji": "🇺🇸",
"country_flag": "https://ipgeolocation.io/static/flags/us_64.png",
"country_name": "United States",
"country_name_official": "United States of America",
"district": "Santa Clara",
"dma_code": "807",
"geoname_id": "6301403",
"is_eu": false,
"latitude": "37.42240",
"longitude": "-122.08421",
"state_code": "US-CA",
"state_prov": "California",
"zipcode": "94043-1351"
},
"network": {
"connection_type": "",
"is_anycast": true,
"route": "8.8.8.0/24"
},
"security": {
"cloud_provider_name": "",
"is_anonymous": false,
"is_bot": false,
"is_cloud_provider": false,
"is_known_attacker": false,
"is_proxy": false,
"is_relay": false,
"is_residential_proxy": false,
"is_spam": false,
"is_tor": false,
"is_vpn": false,
"proxy_confidence_score": 0,
"proxy_last_seen": "",
"proxy_provider_names": [],
"relay_provider_name": "",
"threat_score": 0,
"vpn_confidence_score": 0,
"vpn_last_seen": "",
"vpn_provider_names": []
},
"time_zone": {
"current_time": "2026-03-03 03:06:38.417-0800",
"current_time_unix": 1772535998.417,
"current_tz_abbreviation": "PST",
"current_tz_full_name": "Pacific Standard Time",
"dst_end": {
"date_time_after": "2026-11-01 TIME 01:00",
"date_time_before": "2026-11-01 TIME 02:00",
"duration": "-1.00H",
"gap": false,
"overlap": true,
"utc_time": "2026-11-01 TIME 09:00"
},
"dst_exists": true,
"dst_savings": 0,
"dst_start": {
"date_time_after": "2026-03-08 TIME 03:00",
"date_time_before": "2026-03-08 TIME 02:00",
"duration": "+1.00H",
"gap": true,
"overlap": false,
"utc_time": "2026-03-08 TIME 10:00"
},
"dst_tz_abbreviation": "PDT",
"dst_tz_full_name": "Pacific Daylight Time",
"is_dst": false,
"name": "America/Los_Angeles",
"offset": -8,
"offset_with_dst": -8,
"standard_tz_abbreviation": "PST",
"standard_tz_full_name": "Pacific Standard Time"
}
}
```
##### 仅以 YAML 格式获取特定字段:
```
ipgeolocation ipgeo --ip 1.1.1.1 --fields location --include dma_code,geo_accuracy --output yaml
```
示例响应:
```
ip: 1.1.1.1
location:
accuracy_radius: "27.276"
city: South Brisbane
confidence: low
continent_code: OC
continent_name: Oceania
country_capital: Canberra
country_code2: AU
country_code3: AUS
country_emoji: "\U0001F1E6\U0001F1FA"
country_flag: https://ipgeolocation.io/static/flags/au_64.png
country_name: Australia
country_name_official: Commonwealth of Australia
district: Brisbane
dma_code: ""
geoname_id: "10113228"
is_eu: false
latitude: "-27.47306"
locality: South Brisbane
longitude: "153.01421"
state_code: AU-QLD
state_prov: Queensland
zipcode: "4101"
```
同样,也支持 `raw`、`table` 和 `pretty` 格式。或者可以使用 `| jq` 解析简单的响应。
### `bulk-ip-geo` 命令
在一个请求中查询多个 IP 地址的地理位置信息。
#### `bulk-ip-geo` 用法
```
ipgeolocation bulk-ip-geo [flags]
```
#### `bulk-ip-geo` 的 Flags
| Flag | 类型 | 默认值 | 描述 |
|-----------------|----------|----------|---------------------------------------------------------------|
| `--ips` | string[] | `[]` | 逗号分隔的 IP 列表。示例:`--ips 8.8.8.8,1.1.1.1` |
| `--file` | string | `""` | 包含 IP 的文本文件路径(每行一个)。 |
| `--include` | string[] | `[]` | 包含额外字段(例如 `location,time_zone`)。 |
| `--excludes` | string[] | `[]` | 排除字段(例如 `currency`)。 |
| `--fields` | string[] | `[]` | 仅返回特定字段(例如 `location`)。 |
| `--lang` | string | `""` | 响应语言(如果支持)。 |
| `--output` | string | `pretty` | 输出格式:`pretty`、`raw`、`table`、`yaml`。 |
| `--output-file` | string | `""` | 将输出保存到 JSON 文件。示例:`--output-file results` |
有关更多信息,请访问 [IP Geolocation API 文档](https://ipgeolocation.io/documentation/ip-location-api.html)。
查询 3 个 IP 地址:
```
ipgeolocation bulk-ip-geo --ips 8.8.8.8,1.1.1.1,192.30.253.112
```
从文件查询:
```
ipgeolocation bulk-ip-geo --file=ips.txt --output-file results
```
结果将写入 `results.json` 文件。
输出为 YAML:
```
ipgeolocation bulk-ip-geo --ips=8.8.8.8 --output=yaml
```
将结果保存到 JSON 文件:
```
ipgeolocation bulk-ip-geo --ips=8.8.8.8,1.1.1.1 --output-file=output.json
```
#### 输出格式
- **pretty**(默认):人类可读的格式化 JSON。
- **raw**:原始 API 响应。
- **table**:常用字段的表格显示。
- **yaml**:YAML 格式的输出。
- **json file**:如果提供了 `--output-file`,结果将保存到 `.json` 文件。
### `ip-security` 命令
使用 `ipgeolocation.io` API 查询 IP 安全信息。
#### `ip-security` 用法
```
ipgeolocation ip-security [flags]
```
#### `ip-security` 的 Flags
| Flag | 类型 | 默认值 | 描述 |
|--------------|----------|----------|----------------------------------------------------------------|
| `--ip` | string | `""` | IPv4 或 IPv6 地址。 |
| `--excludes` | string[] | `[]` | 从输出中排除字段。 |
| `--fields` | string[] | `[]` | 仅返回特定字段(例如 `security.threat_score`)。 |
| `--output` | string | `pretty` | 输出格式:`pretty`、`raw`、`table`、`yaml`。 |
#### 在 `ip-security` 中获取默认字段
获取关于您当前 IP 的信息:
```
ipgeolocation ip-security
```
查询特定 IP:
```
ipgeolocation ip-security --ip 2.56.188.34
```
示例输出:
```
{
"ip": "2.56.188.34",
"security": {
"cloud_provider_name": "Packethub S.A.",
"is_anonymous": true,
"is_bot": false,
"is_cloud_provider": true,
"is_known_attacker": true,
"is_proxy": true,
"is_relay": false,
"is_residential_proxy": true,
"is_spam": false,
"is_tor": false,
"is_vpn": true,
"proxy_confidence_score": 80,
"proxy_last_seen": "2025-12-12",
"proxy_provider_names": [
"Zyte Proxy"
],
"relay_provider_name": "",
"threat_score": 80,
"vpn_confidence_score": 80,
"vpn_last_seen": "2026-01-19",
"vpn_provider_names": [
"Nord VPN"
]
}
}
```
有关完整的 API 规范,请参阅 [官方 IP Security API 文档](https://ipgeolocation.io/documentation/ip-security-api.html)。
#### 在 `ip-security` 中使用字段过滤进行请求
```
ipgeolocation ip-security --ip 195.154.221.54 --fields security.is_tor,security.is_proxy,security.is_bot,security.is_spam
```
示例输出:
```
{
"ip": "195.154.221.54",
"security": {
"is_bot": false,
"is_proxy": false,
"is_spam": false,
"is_tor": false
}
}
```
### `bulk-ip-security` 命令
在一个请求中查询多个 IP 地址的 IP 安全信息。
#### `bulk-ip-security` 用法
```
ipgeolocation bulk-ip-security [flags]
```
#### `bulk-ip-security` 的 Flags
| Flag | 类型 | 默认值 | 描述 |
|-----------------|----------|----------|----------------------------------------------------------------|
| `--ips` | string[] | `[]` | 逗号分隔的 IP 列表。示例:`--ips 8.8.8.8,1.1.1.1` |
| `--file` | string | `""` | 包含 IP 的文本文件路径(每行一个)。 |
| `--excludes` | string[] | `[]` | 排除字段(例如 `currency`)。 |
| `--fields` | string[] | `[]` | 仅返回特定字段(例如 `location`)。 |
| `--output` | string | `pretty` | 输出格式:`pretty`、`raw`、`table`、`yaml`。 |
| `--output-file` | string | `""` | 将输出保存到 JSON 文件。示例:`--output-file results` |
#### `bulk-ip-security` 示例
查询 3 个 IP 地址:
```
ipgeolocation bulk-ip-security --ips 8.8.8.8,1.1.1.1,192.30.253.112
```
从文件查询:
```
ipgeolocation bulk-ip-security --file=ips.txt --output-file=output
```
包含位置和时区:
```
ipgeolocation bulk-ip-security --file=ips.txt --include=location,network,time_zone
```
输出为 YAML:
```
ipgeolocation bulk-ip-security --ips=8.8.8.8 --output=yaml
```
将结果保存到 JSON 文件:
```
ipgeolocation bulk-ip-security --ips=8.8.8.8,1.1.1.1 --output-file=output
```
有关更多信息,请访问 [Bulk IP Security API 文档](https://ipgeolocation.io/documentation/ip-security-api.html#bulk-ip-security-lookup-endpoint)。
### `asn` 命令
使用 `ipgeolocation.io` API 查询 ASN(自治系统号)信息。
#### `asn` 用法
```
ipgeolocation asn [flags]
```
#### `asn` 的 Flags
| Flag | 类型 | 默认值 | 描述 |
|--------------|----------|----------|-----------------------------------------------------------------------------------------|
| `--ip` | string | `""` | IPv4 或 IPv6 地址。 |
| `--include` | string[] | `[]` | 在输出中包含额外字段。(例如 `peers, downstreams, upstreams, routes, whois_response`) |
| `--excludes` | string[] | `[]` | 从输出中排除字段。 |
| `--fields` | string[] | `[]` | 仅返回特定字段(例如 `ip,organization`)。 |
| `--output` | string | `pretty` | 输出格式:`pretty`、`raw`、`table`、`yaml`。 |
#### 获取您 IP 的 ASN 信息
获取关于您当前 IP 地址的 ASN 信息:
```
ipgeolocation asn
```
#### 通过 ASN 编号获取 ASN 信息
查询特定的 ASN。AS 编号可以加 'AS' 或 'as' 前缀:
```
ipgeolocation asn --asn 15169
```
示例输出:
```
{
"asn": {
"as_number": "AS15169",
"organization": "Google LLC",
"country": "US",
"asn_name": "GOOGLE",
"type": "BUSINESS",
"domain": "google.com",
"date_allocated": "",
"allocation_status": "",
"num_of_ipv4_routes": "1026",
"num_of_ipv6_routes": "106",
"rir": "ARIN"
}
}
```
#### 使用 Include 组合所有对象
查询特定 IP 并包含额外:
```
ipgeolocation asn --asn 12 --include routes,peers,upstreams,downstreams,whois_response
```
示例输出:
```
{
"asn": {
"as_number": "AS12",
"organization": "New York University",
"country": "US",
"asn_name": "NYU-DOMAIN",
"type": "EDUCATION",
"domain": "nyu.edu",
"date_allocated": "",
"allocation_status": "",
"num_of_ipv4_routes": "11",
"num_of_ipv6_routes": "1",
"rir": "ARIN",
"routes": [
"192.76.177.0/24",
"...",
"216.165.103.0/24"
],
"upstreams": [
{
"as_number": "AS3269",
"description": "Telecom Italia S.p.A.",
"country": "IT"
},
"...",
{
"as_number": "AS137",
"description": "Consortium GARR",
"country": "IT"
}
],
"downstreams": [
{
"as_number": "AS394666",
"description": "NYU Langone Health",
"country": "US"
},
{
"as_number": "AS54965",
"description": "Polytechnic Institute of NYU",
"country": "US"
}
],
"peers": [
{
"as_number": "AS3269",
"description": "Telecom Italia S.p.A.",
"country": "IT"
},
"...",
{
"as_number": "AS54965",
"description": "Polytechnic Institute of NYU",
"country": "US"
}
],
"whois_response": ""
}
}
```
排除不必要的字段:
```
ipgeolocation asn --ip 8.8.8.8 --exclude asn.date_allocated,asn.allocation_status
```
示例输出:
```
{
"asn": {
"as_number": "AS15169",
"asn_name": "GOOGLE",
"country": "US",
"domain": "google.com",
"num_of_ipv4_routes": "1024",
"num_of_ipv6_routes": "135",
"organization": "Google LLC",
"rir": "ARIN",
"type": "BUSINESS"
},
"ip": "8.8.8.8"
}
```
仅以表格格式获取特定字段:
```
ipgeolocation asn --ip 8.8.8.8 --fields asn.organization,asn.country,asn.downstreams --output table
```
输出为 YAML:
```
ipgeolocation asn --ip 8.8.8.8 --output=yaml
```
有关更多信息,请访问 [ASN API 文档](https://ipgeolocation.io/documentation/asn-api.html)。
### `abuse` 命令
使用 `ipgeolocation.io` API 查询 IP 滥用联系信息。
#### `abuse` 用法
```
ipgeolocation abuse [flags]
```
#### `abuse` 的 Flags
| Flag | 类型 | 默认值 | 描述 |
|--------------|----------|----------|-------------------------------------------------------|
| `--ip` | string | `""` | IPv4 或 IPv6 地址。 |
| `--excludes` | string[] | `[]` | 从输出中排除字段。 |
| `--fields` | string[] | `[]` | 仅返回特定字段(例如 `ip,organization`)。 |
| `--output` | string | `pretty` | 输出格式:`pretty`、`raw`、`table`、`yaml`。 |
#### 获取关于您当前 IP 的滥用信息
```
ipgeolocation abuse
```
#### 查询特定 IP
```
ipgeolocation abuse --ip 8.8.8.8
```
#### 排除不必要的字段
```
ipgeolocation abuse --ip 8.8.8.8 --exclude abuse.emails
```
#### 查询特定字段的滥用联系信息
```
ipgeolocation abuse --ip 8.8.8.8 --fields abuse.emails --output table
```
示例输出:
```
Ip : 8.8.8.8
Abuse:
Emails:
[0]:
network-abuse@google.com
```
获取 YAML 格式输出:
```
ipgeolocation abuse --ip 8.8.8.8 --output=yaml
```
示例输出:
```
abuse:
address: |-
1600 Amphitheatre Parkway
Mountain View
CA
94043
United States
country: ""
emails:
- network-abuse@google.com
kind: group
name: Abuse
organization: Abuse
phone_numbers:
- +1-650-253-0000
route: 8.8.8.0/24
ip: 8.8.8.8
```
有关更多信息,请访问 [Abuse API 文档](https://ipgeolocation.io/documentation/ip-abuse-contact-api.html)。
### `timezone` 命令
使用 `ipgeolocation.io` API 通过 IP 地址、纬度/经度和时区 ID 等不同查询类型查询时区信息。
有关完整的 API 规范,请参阅 [Timezone API 文档](https://ipgeolocation.io/documentation/timezone-api.html)。
#### `timezone` 用法
```
ipgeolocation timezone [flags]
```
#### `timezone` 的 Flags
| Flag | 类型 | 默认值 | 描述 |
|---------------|---------|----------|--------------------------------------------------|
| `--ip` | string | `""` | IPv4 或 IPv6 地址。 |
| `--tz` | string | `""` | IANA 时区标识符。 |
| `--location` | string | `""` | 位置名称(例如 New York) |
| `--latitude` | float64 | `0` | 纬度(例如 37.7749)。 |
| `--longitude` | float64 | `0` | 经度(例如 -122.4194)。 |
| `--lang` | string | `""` | 响应语言(如果支持)。 |
| `--iata` | string | `""` | IATA 代码(例如 DXB)。 |
| `--icao` | string | `""` | ICAO 代码(例如 KATL)。 |
| `--lo` | string | `""` | LO 代码(例如 DEBER)。 |
| `--output` | string | `pretty` | 输出格式:`pretty`、`raw`、`table`、`yaml`。 |
#### 获取关于您当前 IP 的时区信息
```
ipgeolocation timezone
```
#### 获取特定 IP 地址的时区
```
ipgeolocation timezone --ip 8.8.8.8
```
示例输出:
```
{
"ip": "8.8.8.8",
"location": {
"city": "Mountain View",
"continent_code": "NA",
"continent_name": "North America",
"country_code2": "US",
"country_code3": "USA",
"country_name": "United States",
"country_name_official": "United States of America",
"district": "Santa Clara",
"is_eu": false,
"latitude": "37.42240",
"longitude": "-122.08421",
"state_code": "US-CA",
"state_prov": "California",
"zipcode": "94043-1351"
},
"time_zone": {
"current_time": "2026-03-03 03:22:55.618-0800",
"current_time_unix": 1772536975.618,
"current_tz_abbreviation": "PST",
"current_tz_full_name": "Pacific Standard Time",
"date": "2026-03-03",
"date_time": "2026-03-03 03:22:55",
"date_time_txt": "Tuesday, March 03, 2026 03:22:55",
"date_time_wti": "Tue, 03 Mar 2026 03:22:55 -0800",
"date_time_ymd": "2026-03-03T03:22:55-0800",
"dst_end": {
"date_time_after": "2026-11-01 TIME 01:00",
"date_time_before": "2026-11-01 TIME 02:00",
"duration": "-1.00H",
"gap": false,
"overlap": true,
"utc_time": "2026-11-01 TIME 09:00"
},
"dst_exists": true,
"dst_savings": 0,
"dst_start": {
"date_time_after": "2026-03-08 TIME 03:00",
"date_time_before": "2026-03-08 TIME 02:00",
"duration": "+1.00H",
"gap": true,
"overlap": false,
"utc_time": "2026-03-08 TIME 10:00"
},
"dst_tz_abbreviation": "PDT",
"dst_tz_full_name": "Pacific Daylight Time",
"is_dst": false,
"month": 3,
"name": "America/Los_Angeles",
"offset": -8,
"offset_with_dst": -8,
"standard_tz_abbreviation": "PST",
"standard_tz_full_name": "Pacific Standard Time",
"time_12": "03:22:55 AM",
"time_24": "03:22:55",
"week": 10,
"year": 2026,
"year_abbr": "26"
}
}
```
#### 按时区名称获取时区
```
ipgeolocation timezone --tz America/New_York
```
示例输出:
```
{
"time_zone": {
"current_time": "2026-03-03 06:23:30.451-0500",
"current_time_unix": 1772537010.451,
"current_tz_abbreviation": "EST",
"current_tz_full_name": "Eastern Standard Time",
"date": "2026-03-03",
"date_time": "2026-03-03 06:23:30",
"date_time_txt": "Tuesday, March 03, 2026 06:23:30",
"date_time_wti": "Tue, 03 Mar 2026 06:23:30 -0500",
"date_time_ymd": "2026-03-03T06:23:30-0500",
"dst_end": {
"date_time_after": "2026-11-01 TIME 01:00",
"date_time_before": "2026-11-01 TIME 02:00",
"duration": "-1.00H",
"gap": false,
"overlap": true,
"utc_time": "2026-11-01 TIME 06:00"
},
"dst_exists": true,
"dst_savings": 0,
"dst_start": {
"date_time_after": "2026-03-08 TIME 03:00",
"date_time_before": "2026-03-08 TIME 02:00",
"duration": "+1.00H",
"gap": true,
"overlap": false,
"utc_time": "2026-03-08 TIME 07:00"
},
"dst_tz_abbreviation": "EDT",
"dst_tz_full_name": "Eastern Daylight Time",
"is_dst": false,
"month": 3,
"name": "America/New_York",
"offset": -5,
"offset_with_dst": -5,
"standard_tz_abbreviation": "EST",
"standard_tz_full_name": "Eastern Standard Time",
"time_12": "06:23:30 AM",
"time_24": "06:23:30",
"week": 10,
"year": 2026,
"year_abbr": "26"
}
}
```
#### 从任意地址获取时区
```
ipgeolocation timezone --location "New York, USA"
```
示例输出:
```
{
"location": {
"city": "Syracuse",
"country_name": "United States",
"latitude": "43.06923",
"locality": "Destiny USA Mall",
"location_string": "New York, USA",
"longitude": "-76.17249",
"state_prov": "New York"
},
"time_zone": {
"current_time": "2026-03-03 06:24:17.824-0500",
"current_time_unix": 1772537057.824,
"current_tz_abbreviation": "EST",
"current_tz_full_name": "Eastern Standard Time",
"date": "2026-03-03",
"date_time": "2026-03-03 06:24:17",
"date_time_txt": "Tuesday, March 03, 2026 06:24:17",
"date_time_wti": "Tue, 03 Mar 2026 06:24:17 -0500",
"date_time_ymd": "2026-03-03T06:24:17-0500",
"dst_end": {
"date_time_after": "2026-11-01 TIME 01:00",
"date_time_before": "2026-11-01 TIME 02:00",
"duration": "-1.00H",
"gap": false,
"overlap": true,
"utc_time": "2026-11-01 TIME 06:00"
},
"dst_exists": true,
"dst_savings": 0,
"dst_start": {
"date_time_after": "2026-03-08 TIME 03:00",
"date_time_before": "2026-03-08 TIME 02:00",
"duration": "+1.00H",
"gap": true,
"overlap": false,
"utc_time": "2026-03-08 TIME 07:00"
},
"dst_tz_abbreviation": "EDT",
"dst_tz_full_name": "Eastern Daylight Time",
"is_dst": false,
"month": 3,
"name": "America/New_York",
"offset": -5,
"offset_with_dst": -5,
"standard_tz_abbreviation": "EST",
"standard_tz_full_name": "Eastern Standard Time",
"time_12": "06:24:17 AM",
"time_24": "06:24:17",
"week": 10,
"year": 2026,
"year_abbr": "26"
}
}
```
#### 从位置坐标获取时区
```
ipgeolocation timezone --latitude 37.7749 --longitude -122.4194
```
示例输出:
```
{
"time_zone": {
"current_time": "2026-03-03 03:25:00.249-0800",
"current_time_unix": 1772537100.249,
"current_tz_abbreviation": "PST",
"current_tz_full_name": "Pacific Standard Time",
"date": "2026-03-03",
"date_time": "2026-03-03 03:25:00",
"date_time_txt": "Tuesday, March 03, 2026 03:25:00",
"date_time_wti": "Tue, 03 Mar 2026 03:25:00 -0800",
"date_time_ymd": "2026-03-03T03:25:00-0800",
"dst_end": {
"date_time_after": "2026-11-01 TIME 01:00",
"date_time_before": "2026-11-01 TIME 02:00",
"duration": "-1.00H",
"gap": false,
"overlap": true,
"utc_time": "2026-11-01 TIME 09:00"
},
"dst_exists": true,
"dst_savings": 0,
"dst_start": {
"date_time_after": "2026-03-08 TIME 03:00",
"date_time_before": "2026-03-08 TIME 02:00",
"duration": "+1.00H",
"gap": true,
"overlap": false,
"utc_time": "2026-03-08 TIME 10:00"
},
"dst_tz_abbreviation": "PDT",
"dst_tz_full_name": "Pacific Daylight Time",
"is_dst": false,
"month": 3,
"name": "America/Los_Angeles",
"offset": -8,
"offset_with_dst": -8,
"standard_tz_abbreviation": "PST",
"standard_tz_full_name": "Pacific Standard Time",
"time_12": "03:25:00 AM",
"time_24": "03:25:00",
"week": 10,
"year": 2026,
"year_abbr": "26"
}
}
```
#### 从 IATA 代码获取时区和机场详情
```
ipgeolocation timezone --iata DXB
```
示例输出:
```
{
"airport_details": {
"city": "Dubai",
"continent_code": "AS",
"country_code": "AE",
"elevation_ft": 62,
"faa_code": "",
"iata_code": "DXB",
"icao_code": "OMDB",
"latitude": "25.25280",
"longitude": "55.36440",
"name": "Dubai International Airport",
"state_code": "AE-DU",
"type": "large_airport"
},
"time_zone": {
"current_time": "2026-03-03 15:26:04.634+0400",
"current_time_unix": 1772537164.634,
"current_tz_abbreviation": "GST",
"current_tz_full_name": "Gulf Standard Time",
"date": "2026-03-03",
"date_time": "2026-03-03 15:26:04",
"date_time_txt": "Tuesday, March 03, 2026 15:26:04",
"date_time_wti": "Tue, 03 Mar 2026 15:26:04 +0400",
"date_time_ymd": "2026-03-03T15:26:04+0400",
"dst_end": {},
"dst_exists": false,
"dst_savings": 0,
"dst_start": {},
"dst_tz_abbreviation": "",
"dst_tz_full_name": "",
"is_dst": false,
"month": 3,
"name": "Asia/Dubai",
"offset": 4,
"offset_with_dst": 4,
"standard_tz_abbreviation": "GST",
"standard_tz_full_name": "Gulf Standard Time",
"time_12": "03:26:04 PM",
"time_24": "15:26:04",
"week": 10,
"year": 2026,
"year_abbr": "26"
}
}
```
#### 从 UN/LOCODE 获取时区和城市详情
```
ipgeolocation timezone --lo DEBER
```
示例输出:
```
{
"lo_code_details": {
"city": "Berlin",
"country_code": "DE",
"country_name": "",
"latitude": "52.51667",
"lo_code": "DEBER",
"location_type": "Port, Rail Terminal, Road Terminal, Airport, Postal Exchange",
"longitude": "13.38333",
"state_code": "BE"
},
"time_zone": {
"current_time": "2026-03-03 12:26:32.849+0100",
"current_time_unix": 1772537192.849,
"current_tz_abbreviation": "CET",
"current_tz_full_name": "Central European Standard Time",
"date": "2026-03-03",
"date_time": "2026-03-03 12:26:32",
"date_time_txt": "Tuesday, March 03, 2026 12:26:32",
"date_time_wti": "Tue, 03 Mar 2026 12:26:32 +0100",
"date_time_ymd": "2026-03-03T12:26:32+0100",
"dst_end": {
"date_time_after": "2026-10-25 TIME 02:00",
"date_time_before": "2026-10-25 TIME 03:00",
"duration": "-1.00H",
"gap": false,
"overlap": true,
"utc_time": "2026-10-25 TIME 01:00"
},
"dst_exists": true,
"dst_savings": 0,
"dst_start": {
"date_time_after": "2026-03-29 TIME 03:00",
"date_time_before": "2026-03-29 TIME 02:00",
"duration": "+1.00H",
"gap": true,
"overlap": false,
"utc_time": "2026-03-29 TIME 01:00"
},
"dst_tz_abbreviation": "CEST",
"dst_tz_full_name": "Central European Summer Time",
"is_dst": false,
"month": 3,
"name": "Europe/Berlin",
"offset": 1,
"offset_with_dst": 1,
"standard_tz_abbreviation": "CET",
"standard_tz_full_name": "Central European Standard Time",
"time_12": "12:26:32 PM",
"time_24": "12:26:32",
"week": 10,
"year": 2026,
"year_abbr": "26"
}
}
```
输出为 YAML:
```
ipgeolocation timezone --ip 8.8.8.8 --output=yaml
```
### `time-conversion` 命令
使用 `ipgeolocation.io` API 在时区之间进行转换,使用时区标识符和可选的日期/时间输入将特定时间从一个时区转换为另一个时区。
有关更多详细信息,请参阅官方文档:[Timezone Converter API](https://ipgeolocation.io/documentation/timezone-api.html#convert-time-between-time-zones)。
#### `time-conversion` 用法
```
ipgeolocation time-conversion [flags]
```
#### `time-conversion` 的 Flags
| Flag | 类型 | 默认值 | 描述 |
|-------------------|---------|----------|--------------------------------------------------|
| `--tz_from` | string | `""` | 源时区。 |
| `--tz_to` | string | `""` | 目标时区。 |
| `--location_from` | string | `""` | 源位置。 |
| `--location_to` | string | `""` | 目标位置。 |
| `--lat_from` | float64 | `0` | 源纬度。 |
| `--long_from` | float64 | `0` | 源经度。 |
| `--lat_to` | float64 | `0` | 目标纬度。 |
| `--long_to` | float64 | `0` | 目标经度。 |
| `--iata_from` | string | `""` | 源 IATA 代码。 |
| `--iata_to` | string | `""` | 目标 IATA 代码。 |
| `--icao_from` | string | `""` | 源 ICAO 代码。 |
| `--icao_to` | string | `""` | 目标 ICAO 代码。 |
| `--lo_from` | string | `""` | 源 LO 代码。 |
| `--lo_to` | string | `""` | 目标 LO 代码。 |
| `--time` | string | `""` | 要转换的时间。 |
| `--output` | string | `pretty` | 输出格式:`pretty`、`raw`、`table`、`yaml`。 |
#### 将当前时间从一个时区转换到另一个时区
```
ipgeolocation time-conversion --tz_from America/New_York --tz_to Europe/London
```
示例输出:
```
{
"original_time": "2026-01-13 07:22:43",
"converted_time": "2026-01-13 12:22:43",
"diff_hour": 5,
"diff_min": 300
}
```
从一个位置转换到另一个位置:
```
ipgeolocation time-conversion --location_from New York --location_to London
```
从一个纬度和经度转换到另一个:
```
ipgeolocation time-conversion --lat_from 37.7749 --long_from -122.4194 --lat_to 51.509865 --long_to -0.118092
```
从一个 IATA 代码转换到另一个:
```
ipgeolocation time-conversion --iata_from DXB --iata_to JFK
```
从一个 ICAO 代码转换到另一个:
```
ipgeolocation time-conversion --icao_from KATL --icao_to EWR
```
从一个 LO 代码转换到另一个:
```
ipgeolocation time-conversion --lo_from DEBER --lo_to JFK
```
输出为 YAML:
```
ipgeolocation time-conversion --tz_from America/New_York --tz_to Europe/London --output=yaml
```
### `astronomy` 命令
`astronomy` 命令使用 ipgeolocation.io Astronomy API 获取天文相关数据,例如:
- 日出和日落
- 日中天
- 月出和月落
- 月相
- 日照时长
- 基于时区或坐标的位置支持
您可以使用 IP、城市名称、坐标或时区指定位置。
有关更多信息,请访问 [Astronomy API 文档](https://ipgeolocation.io/documentation/astronomy-api.html)。
#### `astronomy` 用法
```
ipgeolocation astronomy [flags]
```
#### `astronomy` 的 Flags
| Flag | 类型 | 默认值 | 描述 |
|---------------|---------|----------|--------------------------------------------------|
| `--ip` | string | `""` | IPv4 或 IPv6 地址。 |
| `--location` | string | `""` | 城市名称。 |
| `--latitude` | float64 | `0` | 纬度。 |
| `--longitude` | float64 | `0` | 经度。 |
| `--lang` | string | `""` | 响应语言(如果支持)。 |
| `--tz` | string | `""` | 时区。 |
| `--elevation` | float64 | `0` | 海拔。 |
| `--output` | string | `pretty` | 输出格式:`pretty`、`raw`、`table`、`yaml`。 |
#### 通过坐标查询 Astronomy API
获取特定纬度和经度的天文信息:
```
ipgeolocation astronomy --latitude 37.7749 --longitude -122.4194
```
示例输出:
```
{
"astronomy": {
"current_time": "05:07:18.340",
"date": "2026-01-13",
"day_length": "09:50",
"evening": {
"astronomical_twilight_begin": "18:14",
"astronomical_twilight_end": "18:45",
"blue_hour_begin": "17:30",
"blue_hour_end": "17:52",
"civil_twilight_begin": "17:13",
"civil_twilight_end": "17:41",
"golden_hour_begin": "16:33",
"golden_hour_end": "17:30",
"nautical_twilight_begin": "17:41",
"nautical_twilight_end": "18:14"
},
"mid_night": "00:18",
"moon_altitude": 16.07194223979877,
"moon_angle": 301.4632703453228,
"moon_azimuth": 138.83883667429063,
"moon_distance": 405270.18931629026,
"moon_illumination_percentage": "-23.90",
"moon_parallactic_angle": -34.64165014870525,
"moon_phase": "WANING_CRESCENT",
"moon_status": "-",
"moonrise": "03:17",
"moonset": "12:53",
"morning": {
"astronomical_twilight_begin": "05:51",
"astronomical_twilight_end": "06:23",
"blue_hour_begin": "06:44",
"blue_hour_end": "07:06",
"civil_twilight_begin": "06:55",
"civil_twilight_end": "07:23",
"golden_hour_begin": "07:06",
"golden_hour_end": "08:04",
"nautical_twilight_begin": "06:23",
"nautical_twilight_end": "06:55"
},
"night_begin": "18:45",
"night_end": "05:51",
"solar_noon": "12:18",
"sun_altitude": -26.63562944381545,
"sun_azimuth": 97.35878744233418,
"sun_distance": 147120665.60394213,
"sun_status": "-",
"sunrise": "07:23",
"sunset": "17:13"
},
"location": {
"city": "San Francisco",
"country_name": "United States",
"elevation": "16",
"latitude": "37.77490",
"locality": "South of Market",
"longitude": "-122.41940",
"state_prov": "California"
}
}
```
#### 通过 IP 地址查询 Astronomy API
获取关于您当前 IP 的天文信息:
```
ipgeolocation astronomy
```
获取特定 IP 地址的天文信息:
```
ipgeolocation astronomy --ip 8.8.8.8
```
示例输出:
```
{
"astronomy": {
"current_time": "05:09:04.314",
"date": "2026-01-13",
"day_length": "09:50",
"evening": {
"astronomical_twilight_begin": "18:13",
"astronomical_twilight_end": "18:44",
"blue_hour_begin": "17:30",
"blue_hour_end": "17:51",
"civil_twilight_begin": "17:12",
"civil_twilight_end": "17:41",
"golden_hour_begin": "16:33",
"golden_hour_end": "17:30",
"nautical_twilight_begin": "17:41",
"nautical_twilight_end": "18:13"
},
"mid_night": "00:16",
"moon_altitude": 16.728478792843955,
"moon_angle": 301.47655895571256,
"moon_azimuth": 139.37283119065324,
"moon_distance": 405270.54014008155,
"moon_illumination_percentage": "-23.89",
"moon_parallactic_angle": -34.405427656780056,
"moon_phase": "WANING_CRESCENT",
"moon_status": "-",
"moonrise": "03:15",
"moonset": "12:53",
"morning": {
"astronomical_twilight_begin": "05:50",
"astronomical_twilight_end": "06:21",
"blue_hour_begin": "06:42",
"blue_hour_end": "07:04",
"civil_twilight_begin": "06:53",
"civil_twilight_end": "07:21",
"golden_hour_begin": "07:04",
"golden_hour_end": "08:01",
"nautical_twilight_begin": "06:21",
"nautical_twilight_end": "06:53"
},
"night_begin": "18:44",
"night_end": "05:50",
"solar_noon": "12:17",
"sun_altitude": -25.978681889301882,
"sun_azimuth": 97.96459578152059,
"sun_distance": 147120665.60394216,
"sun_status": "-",
"sunrise": "07:21",
"sunset": "17:12"
},
"ip": "8.8.8.8",
"location": {
"city": "Mountain View",
"continent_code": "NA",
"continent_name": "North America",
"country_code2": "US",
"country_code3": "USA",
"country_name": "United States",
"country_name_official": "United States of America",
"district": "Santa Clara",
"elevation": "3",
"is_eu": false,
"latitude": "37.42240",
"locality": "Charleston Terrace",
"longitude": "-122.08421",
"state_code": "US-CA",
"state_prov": "California",
"zipcode": "94043-1351"
}
}
```
#### 通过位置字符串查询 Astronomy API
```
ipgeolocation astronomy --location "New York, USA"
```
示例输出:
```
{
"astronomy": {
"current_time": "08:10:53.180",
"date": "2026-01-13",
"day_length": "09:23",
"evening": {
"astronomical_twilight_begin": "17:59",
"astronomical_twilight_end": "18:34",
"blue_hour_begin": "17:12",
"blue_hour_end": "17:36",
"civil_twilight_begin": "16:55",
"civil_twilight_end": "17:24",
"golden_hour_begin": "16:08",
"golden_hour_end": "17:12",
"nautical_twilight_begin": "17:24",
"nautical_twilight_end": "17:59"
},
"mid_night": "00:13",
"moon_altitude": 23.12401867639373,
"moon_angle": 301.4902102354391,
"moon_azimuth": 183.36677049153406,
"moon_distance": 405270.8986986421,
"moon_illumination_percentage": "-23.88",
"moon_parallactic_angle": 2.6870094296532643,
"moon_phase": "WANING_CRESCENT",
"moon_status": "-",
"moonrise": "03:20",
"moonset": "12:27",
"morning": {
"astronomical_twilight_begin": "05:53",
"astronomical_twilight_end": "06:27",
"blue_hour_begin": "06:50",
"blue_hour_end": "07:14",
"civil_twilight_begin": "07:02",
"civil_twilight_end": "07:32",
"golden_hour_begin": "07:14",
"golden_hour_end": "08:18",
"nautical_twilight_begin": "06:27",
"nautical_twilight_end": "07:02"
},
"night_begin": "18:34",
"night_end": "05:53",
"solar_noon": "12:13",
"sun_altitude": 4.828766240317727,
"sun_azimuth": 125.48815354581939,
"sun_distance": 147120665.60394213,
"sun_status": "-",
"sunrise": "07:32",
"sunset": "16:55"
},
"location": {
"city": "Syracuse",
"country_name": "United States",
"elevation": "128",
"latitude": "43.06923",
"locality": "Destiny USA Mall",
"location_string": "New York, USA",
"longitude": "-76.17249",
"state_prov": "New York"
}
}
```
### `astronomy-timeseries` 命令
`astronomy-timeseries` 命令使用 ipgeolocation.io Astronomy API 获取天文相关数据,例如:
- 日出和日落
- 日中天
- 月出和月落
- 月相
- 日照时长
- 基于时区或坐标的位置支持
有关更多信息,请访问 [Astronomy Timeseries API 文档](https://ipgeolocation.io/documentation/astronomy-api.html#time-series-lookup)。
#### `astronomy-timeseries` 用法
```
ipgeolocation astronomy-timeseries [flags]
```
#### `astronomy-timeseries` 的 Flags
| Flag | 类型 | 默认值 | 描述 |
|----------------|---------|----------|--------------------------------------------------|
| `--ip` | string | `""` | IPv4 或 IPv6 地址。 |
| `--location` | string | `""` | 城市名称。 |
| `--latitude` | float64 | `0` | 纬度。 |
| `--longitude` | float64 | `0` | 经度。 |
| `--lang` | string | `""` | 响应语言(如果支持)。 |
| `--start-date` | string | `""` | 开始日期(例如 2023-01-01)仅 YYYY-MM-DD。 |
| `--end-date` | string | `""` | 结束日期(例如 2023-12-31)仅 YYYY-MM-DD |
| `--output` | string | `pretty` | 输出格式:`pretty`、`raw`、`table`、`yaml`。 |
#### 获取 IP 地址的天文时间序列信息
针对您自己的 IP 地址
```
ipgeolocation astronomy-timeseries --start-date 2023-01-01 --end-date 2023-01-02
```
#### 获取特定纬度和经度的天文时间序列信息
```
ipgeolocation astronomy-timeseries --latitude 37.7749 --longitude -122.4194 --start-date 2023-01-01 --end-date 2023-01-02
```
#### 获取特定位置的天文时间序列信息
```
ipgeolocation astronomy-timeseries --location "New York, USA" --start-date 2023-01-01 --end-date 2023-01-02
```
示例输出:
```
{
"astronomy": [
{
"date": "2023-01-01",
"day_length": "09:08",
"evening": {
"astronomical_twilight_begin": "17:48",
"astronomical_twilight_end": "18:23",
"blue_hour_begin": "17:00",
"blue_hour_end": "17:24",
"civil_twilight_begin": "16:42",
"civil_twilight_end": "17:12",
"golden_hour_begin": "15:54",
"golden_hour_end": "17:00",
"nautical_twilight_begin": "17:12",
"nautical_twilight_end": "17:48"
},
"mid_night": "00:08",
"moon_phase": "WAXING_GIBBOUS",
"moon_status": "-",
"moonrise": "12:59",
"moonset": "02:38",
"morning": {
"astronomical_twilight_begin": "05:53",
"astronomical_twilight_end": "06:28",
"blue_hour_begin": "06:51",
"blue_hour_end": "07:16",
"civil_twilight_begin": "07:04",
"civil_twilight_end": "07:34",
"golden_hour_begin": "07:16",
"golden_hour_end": "08:22",
"nautical_twilight_begin": "06:28",
"nautical_twilight_end": "07:04"
},
"night_begin": "18:23",
"night_end": "05:53",
"solar_noon": "12:08",
"sun_status": "-",
"sunrise": "07:34",
"sunset": "16:42"
},
{
"date": "2023-01-02",
"day_length": "09:09",
"evening": {
"astronomical_twilight_begin": "17:49",
"astronomical_twilight_end": "18:23",
"blue_hour_begin": "17:01",
"blue_hour_end": "17:25",
"civil_twilight_begin": "16:43",
"civil_twilight_end": "17:13",
"golden_hour_begin": "15:55",
"golden_hour_end": "17:01",
"nautical_twilight_begin": "17:13",
"nautical_twilight_end": "17:49"
},
"mid_night": "00:08",
"moon_phase": "WAXING_GIBBOUS",
"moon_status": "-",
"moonrise": "13:25",
"moonset": "03:45",
"morning": {
"astronomical_twilight_begin": "05:53",
"astronomical_twilight_end": "06:28",
"blue_hour_begin": "06:52",
"blue_hour_end": "07:16",
"civil_twilight_begin": "07:04",
"civil_twilight_end": "07:34",
"golden_hour_begin": "07:16",
"golden_hour_end": "08:22",
"nautical_twilight_begin": "06:28",
"nautical_twilight_end": "07:04"
},
"night_begin": "18:23",
"night_end": "05:53",
"solar_noon": "12:08",
"sun_status": "-",
"sunrise": "07:34",
"sunset": "16:43"
}
],
"location": {
"city": "Syracuse",
"country_name": "United States",
"elevation": "128",
"latitude": "43.06923",
"locality": "Destiny USA Mall",
"location_string": "New York, USA",
"longitude": "-76.17249",
"state_prov": "New York"
}
}
```
### `parse-user-agent` 命令
`parse-user-agent` 命令使用 ipgeolocation.io User Agent Parser API 解析 User Agent 字符串并提取相关信息,例如:
- 设备类型
- 操作系统
- 浏览器
- 浏览器版本
- 设备厂商
- 设备型号
#### `parse-user-agent` 用法
```
ipgeolocation parse-user-agent [flags]
```
#### `parse-user-agent` 的 Flags
| Flag | 类型 | 默认值 | 描述 |
|----------------|--------|----------|--------------------------------------------------|
| `--user-agent` | string | `""` | User Agent 字符串。 |
| `--output` | string | `pretty` | 输出格式:`pretty`、`raw`、`table`、`yaml`。 |
有关更多信息,请访问 [User Agent Parser API 文档](https://ipgeolocation.io/documentation/user-agent-api.html)。
#### 解析 User Agent 字符串
```
ipgeolocation parse-user-agent --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
```
示例输出:
```
{
"device": {
"brand": "Unknown",
"cpu": "Intel x86_64",
"name": "Desktop",
"type": "Desktop"
},
"engine": {
"name": "Blink",
"type": "Browser",
"version": "58.0",
"version_major": "58"
},
"name": "Chrome",
"operating_system": {
"build": "??",
"name": "Windows NT",
"type": "Desktop",
"version": "10.0",
"version_major": "10"
},
"type": "Browser",
"user_agent_string": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36",
"version": "58.0.3029.110",
"version_major": "58"
}
```
### `parse-bulk-user-agents` 命令
`parse-bulk-user-agents` 命令使用 ipgeolocation.io Bulk User-Agent Parser API 解析多个 User Agent 字符串并提取相关信息,例如:
- 设备类型
- 操作系统
- 浏览器
- 浏览器版本
- 设备厂商
- 设备型号
#### `parse-bulk-user-agents` 用法
```
ipgeolocation parse-bulk-user-agents [flags]
```
#### `parse-bulk-user-agents` 的 Flags
| Flag | 类型 | 默认值 | 描述 |
|-----------------|----------|----------|--------------------------------------------------|
| `--user-agents` | string[] | `[]` | User Agent 字符串。 |
| `--output` | string | `pretty` | 输出格式:`pretty`、`raw`、`table`、`yaml`。 |
有关更多信息,请访问 [Bulk User Agent Parser API 文档](https://ipgeolocation.io/documentation/user-agent-api.html#parse-bulk-user-agent-strings)。
#### 解析多个 User Agent 字符串
```
ipgeolocation parse-bulk-user-agents --user-agents "Mozilla/5.0 (Windows NT 10.0; Win64; x64)","curl/7.64.1"
```
示例输出:
```
[
{
"device": {
"brand": "Unknown",
"cpu": "Intel x86_64",
"name": "Desktop",
"type": "Desktop"
},
"engine": {
"name": "Mozilla",
"type": "Browser",
"version": "5.0",
"version_major": "5"
},
"name": "Windows NT",
"operating_system": {
"build": "??",
"name": "Windows NT",
"type": "Desktop",
"version": "10.0",
"version_major": "10"
},
"type": "Browser",
"user_agent_string": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
"version": "10.0",
"version_major": "10"
},
{
"device": {
"brand": "Curl",
"cpu": "Unknown",
"name": "Curl",
"type": "Robot"
},
"engine": {
"name": "curl",
"type": "Robot",
"version": "7.64.1",
"version_major": "7"
},
"name": "Curl",
"operating_system": {
"build": "??",
"name": "Cloud",
"type": "Cloud",
"version": "??",
"version_major": "??"
},
"type": "Robot",
"user_agent_string": "curl/7.64.1",
"version": "7.64.1",
"version_major": "7"
}
]
```
## 许可证
本项目基于 [MIT 许可证](https://github.com/IPGeolocation/cli/blob/main/LICENSE) 发布。
标签:API客户端, ASN信息, CLI, EVTX分析, GitHub, IPGeolocation, IP地理位置, IP安全, IP查询, Linux安全, Mr. Robot, WiFi技术, 代码示例, 协作平台, 后渗透, 天文学API, 威胁情报, 开发者工具, 数据分析, 文档结构分析, 日志审计, 时区数据, 滥用联系人, 用户代理解析, 网络安全, 网络调试, 脚本工具, 自动化, 运维工具, 隐私保护