IPDataInfo/ipdata-bash

GitHub: IPDataInfo/ipdata-bash

ipdata.info 的官方 Bash CLI,封装 curl 和 jq,提供 IP 地理定位、ASN 查询及威胁情报查询功能,输出原始 JSON 便于在 Shell 脚本和 CI 管道中组合使用。

Stars: 3 | Forks: 0

# IPData.info Bash SDK — 免费 IP 地理位置与威胁情报 API [![Shell: Bash](https://img.shields.io/badge/shell-bash-4EAA25?logo=gnubash&logoColor=white)](./ipdata) [![CI](https://raw.githubusercontent.com/IPDataInfo/ipdata-bash/main/../../actions/workflows/ci.yml/badge.svg)](../../actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE) [**ipdata.info**](https://ipdata.info) 的官方 Bash 客户端 — 一个免费、 快速的 IP 地理位置定位、ASN 与威胁情报 API。查找任何 IPv4 或 IPv6 地址的国家、城市、 ASN、时区、货币和安全标志(代理/VPN/Tor/托管)。由 [ipdata.info](https://ipdata.info) 提供支持。 这是一个轻量级的 `curl` + `jq` 封装 CLI,而不是一个库:每个子命令 都会将原始的 API JSON 打印到 stdout,因此你可以将其直接管道传输给 `jq` 或 shell 管道中的任何其他工具。 ## 获取免费 API key 公共端点**免费 — 每分钟 50 次请求,无需注册,无需 key**。如需更高的 速率限制和批量查询,请[**在 ipdata.info/register 创建免费 API key**](https://ipdata.info/register),并在你的 [控制面板](https://ipdata.info/dashboard)中进行管理。 ## 安装 ``` curl -fsSL https://raw.githubusercontent.com/IPDataInfo/ipdata-bash/main/install.sh | sh ``` 或者从本地检出的代码克隆并安装: ``` git clone https://github.com/IPDataInfo/ipdata-bash.git cd ipdata-bash ./install.sh --prefix "$HOME/.local" ``` 需要预先安装 `bash`、`curl` 和 `jq`。 ## 快速开始 ``` # 免费层级,无需 key ipdata lookup 8.8.8.8 | jq '{ip, country, city}' ipdata lookup # your own IP ipdata geo 1.1.1.1 ipdata asn 8.8.8.8 # 使用 API key(更高限制 + 批量) export IPDATA_API_KEY="your-key-here" ipdata batch 8.8.8.8 1.1.1.1 ``` ## 方法 | 方法 | 返回内容 | |--------|-----------------| | `lookup(ip?)` | 完整的地理位置记录(省略时为本机 IP) | | `geo(ip)` | 地理位置信息子集(城市/地区/国家/纬度/经度/时区) | | `asn(ip)` | IP 的 ASN + ISP/注册机构 | | `batch(ips)` | 一次查询多个 IP(**需要 API key**) | | `asnDetail(n)` | ASN 详情,包含前缀 | | `asnWhoisHistory(n)` | ASN whois 历史 | | `asnChanges()` | ASN 变更动态 | | `threatDomain/Hash/Url(x)` | 威胁情报查询(域名 / 文件哈希 / URL) | ### CLI 命令 | 命令 | 示例 | |---------|---------| | `ipdata lookup [ip]` | `ipdata lookup 8.8.8.8` | | `ipdata geo ` | `ipdata geo 1.1.1.1` | | `ipdata asn ` | `ipdata asn 8.8.8.8` | | `ipdata batch ` | `ipdata batch 8.8.8.8 1.1.1.1` | | `ipdata asn-detail ` | `ipdata asn-detail 15169` | | `ipdata asn-whois-history ` | `ipdata asn-whois-history 15169` | | `ipdata asn-changes` | `ipdata asn-changes` | | `ipdata threat-domain ` | `ipdata threat-domain example.com` | | `ipdata threat-hash ` | `ipdata threat-hash ` | | `ipdata threat-url ` | `ipdata threat-url https://example.com` | | `ipdata help` / `ipdata version` | | 标志:`--key `(或 `IPDATA_API_KEY`),`--host `(或 `IPDATA_HOST`)。 输出始终是 stdout 上的原始 JSON;错误信息会输出到 stderr 并带有非零退出 代码,因此 `ipdata` 可以在 shell 脚本和 CI 流水线中完美组合使用。 完整响应 schema:[ipdata.info API 文档](https://ipdata.info/docs) · [SDK 契约](https://ipdata.info/docs/sdks)。 ## 速率限制 - 免费(`ipdata.info`):每分钟 50 次请求,无需 key。 - 付费(`pro.ipdata.info`):更高的限制 + `batch`,需使用 [API key](https://ipdata.info/register)。 ## 其他 SDK 12 个官方 SDK — 请在 [**ipdata.info/docs/sdks**](https://ipdata.info/docs/sdks) 查看完整列表:Python、Node.js、Go、 PHP、Java、Rust、.NET、Kotlin、Swift、Dart、Bash、Objective-C。 ## 许可证 MIT © [ipdata.info](https://ipdata.info)
标签:API SDK, ASN查询, Bash, IP地理定位, 应用安全