IP (Plain Text)
返回访客公网出口 IP(纯文本),适用于自动化脚本与网络通道检测。
Returns the visitor public egress IP in plain text, designed for automation and network path checks.
一、功能说明 Overview
返回访客公网 IP(Public Egress IP)。
响应格式为纯文本(text/plain),不包含 JSON 包装。
支持 IPv4 IPv6。
Dual Stack 指同一入口可同时响应 IPv4 与 IPv6,请求最终返回值取决于客户端实际连通通道。
Returns the visitor public IP address.
Response format is plain text (text/plain) without JSON envelope.
Supports IPv4 and IPv6.
Dual Stack means one endpoint serves both IPv4 and IPv6; output depends on the client's active network path.
三、使用示例 Examples
curl 示例
curl ipx.ee
curl -4 ipx.ee
curl -6 ipx.ee
curl -4 ipx.ee
curl -6 ipx.ee
Linux shell 示例(变量赋值)
#!/bin/sh
ip="$(curl -fsS https://ipx.ee)"
echo "Current public IP: ${ip}"
Node.js
const res = await fetch('https://ipx.ee');
const ip = (await res.text()).trim();
console.log(ip);
Python
import requests
ip = requests.get('https://ipx.ee', timeout=5).text.strip()
print(ip)
PHP
<?php
$ip = trim(file_get_contents('https://ipx.ee'));
echo $ip;
四、注释说明 Notes
返回值是访问者当前公网出口 IP,不是内网地址。
若客户端启用 VPN Proxy,返回对应出口节点 IP。
双栈环境中,结果取决于客户端实际请求走的 IPv4 或 IPv6 通道。
不建议对结果做长期缓存,建议按业务实时获取。
五、应用场景 Use Cases
DDNS 自动更新
服务器公网 IP 检测
IPv6 连通性测试
自动防火墙白名单
CI CD 出口确认
JSON IP
返回访客公网 IP 的 JSON 格式数据,支持 JSONP 回调。
Returns visitor public IP in JSON format with optional JSONP callback support.
一、功能说明 Overview
输出结构化 JSON,适合前端脚本直接消费。
成功响应仅包含一个字段:ip。
支持 callback 参数返回 JSONP。
返回值为访问者当前公网出口 IP。
三、请求示例 Request Examples
curl "https://ipx.ee/api/jsonip"
curl "https://ipx.ee/api/jsonip?callback=getip"
五、注释说明 Notes
成功 JSON 响应固定为 {\"ip\":\"...\"},不附加其它元字段。
未传 callback 时返回 application/json。
传 callback 时返回 application/javascript。
callback 仅允许合法函数名。
GeoIP (JSON)
查询目标 IP 或域名对应的 GeoIP 与网络信息,返回结构化 JSON 数据。
Query GeoIP and network attributes for an IP or domain, returned as structured JSON.
一、功能说明 Overview
用于获取 IP 地理位置与网络归属信息。
响应格式为 JSON(application/json)。
输出结构固定为 5 个顶层字段:ip、geo、network、flags、meta。
支持 IPv4 IPv6 Domain。
传入域名时,服务会先执行 DNS 解析,再返回解析到的 IP 信息。
二、接口地址 Endpoint
GET https://ipx.ee/api/geoip/{target}
{target} 支持 IPv4、IPv6 或域名 Domain。
IPv4 示例:8.8.8.8
IPv6 示例:2001:4860:4860::8888
Domain 示例:example.com
三、请求示例 Request Examples
curl "https://ipx.ee/api/geoip/8.8.8.8"
curl "https://ipx.ee/api/geoip/2001:4860:4860::8888"
curl "https://ipx.ee/api/geoip/example.com"
curl "https://ipx.ee/api/geoip/8.8.8.8?callback=getgeoip"
四、返回示例 Response Example JSON
{
"ip": "8.8.8.8",
"geo": {
"continent": "North America",
"country": "United States",
"country_code": "US",
"region": "CA",
"region_name": "California",
"city": "Mountain View",
"zip": "94043",
"latitude": 37.38605,
"longitude": -122.08385,
"timezone": "America/Los_Angeles"
},
"network": {
"reverse": "dns.google",
"isp": "Google LLC",
"org": "Google LLC",
"as_name": "GOOGLE",
"asn": 15169,
"as_org": "Google LLC"
},
"flags": {
"hosting": true,
"proxy": false,
"mobile": false
},
"meta": {
"source": "ipapi.is",
"requested_at": "2026-02-16T08:10:00+08:00",
"cached": false,
"cache_group": "ip",
"cache_saved_at": "",
"ok": true
}
}
五、字段说明 Field Description
ip:目标 IP(由上游 query 映射而来)。
geo:地理信息分组,包含 continent/country/country_code/region/region_name/city/zip/latitude/longitude/timezone。
network:网络信息分组,包含 reverse/isp/org/as_name/asn/as_org。
flags:属性标记分组,包含 hosting/proxy/mobile。
meta:请求元信息分组,包含 source/requested_at/cached/cache_group/cache_saved_at/ok。
当 meta.ok=false 时,返回 meta.error.code 与 meta.error.message。
六、注释说明 Notes
Please note that the IP location database may not contain all information about a given IP. In this case, only the available data is displayed.
地理位置为 IP 归属地推断,不是精确定位。
域名查询会先进行 DNS 解析。
建议缓存 GeoIP 数据 7-30 天。
返回 Content-Type: application/json。
上游 status 字段不会透出,错误统一在 meta.error 返回。
Rate Limits
频率限制策略用于保证 API 服务稳定性与公平使用,避免滥用与瞬时流量冲击。
Rate limiting policy ensures API stability and fair usage while preventing abuse and burst overload.
一、概览 Overview
为保证服务稳定性与公平使用,IP 与 GeoIP REST API 实施频率限制。
To ensure service stability and fair usage, rate limits are enforced on IP and GeoIP REST APIs.
二、默认限制 Default Limits
Plain Text IP: 60 requests / minute / IP
GeoIP API: 30 requests / minute / IP
三、限制范围 Limit Scope
限流基于客户端公网 IP 计算。
Limits are enforced per client public IP.
四、超限响应 Exceeded Response
当请求超过限制时,服务返回 HTTP 429 Too Many Requests。
HTTP 429 Too Many Requests
{
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Too many requests. Please slow down."
}
}
六、说明 Notes
建议缓存结果,尤其是 GeoIP 数据。
禁止滥用、扫描与高频非正常请求。
违规访问可能触发临时或长期封禁。
Error Codes
所有错误遵循标准 HTTP 状态码,并返回统一错误结构。
All errors follow standard HTTP status codes with a unified error payload.
一、概览 Overview
错误返回采用 HTTP 状态码 + JSON 错误对象。
Error responses use HTTP status codes plus JSON error object.
三、常见 HTTP 状态码 Common HTTP Status Codes
HTTP
Error Code
说明 Description
400 INVALID_TARGET目标缺失或格式错误 / Target is missing or malformed
400 INVALID_IPV4IPv4 地址无效 / Invalid IPv4 address
400 INVALID_IPV6IPv6 地址无效 / Invalid IPv6 address
400 INVALID_DOMAIN域名格式无效 / Invalid domain format
404 NOT_FOUND接口或资源不存在 / Endpoint or resource not found
429 RATE_LIMIT_EXCEEDED超过请求频率限制 / Request rate limit exceeded
500 INTERNAL_ERROR服务器内部错误 / Internal server error
503 SERVICE_UNAVAILABLE服务暂时不可用 / Temporary service unavailable
四、错误示例 Error Examples
400 示例
400 Example
{
"error": {
"code": "INVALID_TARGET",
"message": "Target must be a valid IPv4, IPv6, or domain."
}
}
429 示例
429 Example
{
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Too many requests. Please slow down."
}
}
五、说明 Notes
Plain Text 接口发生错误时可仅返回 HTTP 状态码与纯文本。
GeoIP 接口错误返回 JSON 错误对象。
错误响应不暴露内部实现细节。
出口检测 Usage Guide
本章节说明“出口检测”页面的检测范围、结果解释与使用建议。
This section explains scope, result interpretation, and usage best practices for the Egress Inspector page.
一、功能概览 Overview
Scope includes primary IPv4/IPv6 egress, DNS resolver egress, WebRTC candidates, and site resolution distribution.
Detected routable IPs are visualized on the map.
二、检测流程 Workflow
点击“开始检测”,系统并发执行 IPv4/IPv6、DNS 与 WebRTC 探测。
收集到的 IP 会进入 GeoIP 归属解析与地图标注流程。
表格按“出口相关结果 / 站点解析结果 / WebRTC 明细”分组呈现。
Click Start to run IPv4/IPv6, DNS, and WebRTC probes in parallel.
Detected IPs are enriched with geolocation and plotted on map.
Results are grouped into egress table, site DNS table, and WebRTC details.
三、输出解释 Output
“主要出口 IPv4/IPv6”:当前浏览通道直接可见的公网出口。
“DNS出口”:通过 DNS 相关探测得到的解析路径出口,不一定等于主要出口。
“WebRTC”:浏览器 ICE 候选中的公网地址,用于辅助判断是否存在泄露风险。
“站点解析”:目标网站 DNS 解析到的 IP 分布,用于判断地域与网络归属。
四、注意事项 Notes
不同网络与浏览器策略会导致结果差异,建议多次检测交叉比对。
WebRTC 结果受浏览器权限、扩展与策略影响,不保证每次都返回候选。
DNS 出口结果可能呈现多地域节点,这是公共解析基础设施的正常表现。
DNS反查 Usage Guide
本章节说明 DNS反查 页面六种模式的用途、输入要求与 JSON 输出方式。
This section documents all lookup modes, input requirements, and JSON output format.
一、功能概览 Overview
页面入口:https://ipx.ee/lookup
查询模式:DNS Lookup、Reverse DNS Lookup、rDNS 网段扫描、IP 反查域名、rDNS 反查、CNAME 反查。
输出分为:页面结果视图 + 可选 JSON 接口输出(会员可见按钮)。
二、查询模式 Modes
模式 Mode
输入 Input
说明 Description
DNS Lookup Domain A / AAAA / MX / CNAME / NS / TXT 实时解析
Reverse DNS Lookup Single IP 查询 PTR 记录
rDNS 网段扫描 IPv4 CIDR (max /20) 批量 PTR 扫描并写入本地索引
IP 反查域名 IP or IPv4 CIDR (max /22) 基于 PTR/rDNS 能力返回绑定域名
rDNS 反查 Keyword + Match 左/中/右匹配查询本地 rDNS 索引
CNAME 反查 Keyword + Match 左/中/右匹配查询本地 CNAME 索引
四、JSON 输出 JSON Output
GET /lookup/{query}?dns_type=dns_lookup&output=json
GET /lookup/{query}?dns_type=rdns_pattern&dns_match=right&output=json
统一返回结构:ok / query / summary / data / meta。
空输入通常返回 400 INVALID_INPUT;查询失败返回 422 QUERY_FAILED。
五、注意事项 Notes
IP 反查域名与 rDNS 结果基于 PTR/本地索引,不等同于全量被动 DNS 数据。
如需更高覆盖率,建议持续运行网段扫描并定时导入被动 DNS 数据源。
DNS 结果会受权威记录 TTL 与上游网络策略影响。
Whois RDAP Usage Guide
本章节说明 Whois RDAP 页面查询目标、结果字段与使用建议。
This section explains query targets, returned fields, and best practices for Whois/RDAP page.
三、结果字段 Output Fields
注册商/联系人/Whois 服务器/创建与更新和到期时间。
状态码(如 clientTransferProhibited)与 Nameservers。
RDAP 对象类型、Handle、关联链接与原始 JSON。
年份徽章(注册年限)与目标类型徽章(Domain/IP/ASN)。
四、注意事项 Notes
Whois/RDAP 数据来自注册机构及镜像节点,更新时间可能存在延迟。
同一目标在不同区域节点可能返回字段差异,属正常现象。
建议结合历史记录与业务日志进行归属稳定性判断。
会员与非会员显示策略
首页 IP 结果采用三层结构:主要显示、折叠详细、会员高级信息。前端渲染仅依赖 normalized_profile 字段。
Home IP cards use 3 layers: primary, expandable details, and member-only advanced data. Rendering depends on normalized_profile fields only.
一、分层策略 Overview
层级 中文说明 English 显示规则
Layer 1 主要显示(12~14 行) Primary block 默认展开,首屏可见
Layer 2 查看详细信息 Expandable details 点击后展开,补充网络与风险细节
Layer 3 高级信息 Advanced member data 会员可见;非会员显示锁定提示
二、权限对比 Compare
字段组 非会员 会员
主要显示(国家/城市/时区、ASN、组织、ISP、网络类型、置信度、代理/VPN/Tor) 显示 显示
折叠详细(ASN 类型、路由、RIR、组织域名、经纬度、Crawler/Satellite/Abuser、风险分) 显示 显示
高级信息(Abuse 联系方式) 锁定 显示
高级信息(risk.reasons[] 判定理由) 锁定 显示
高级信息(ASN created/updated) 锁定 显示
高级信息(meta.sources_used) 锁定 显示
三、移动端顺序 Mobile
先显示 Layer 1 主要字段(单列)。
再显示“查看详细信息”折叠区(单列)。
最后显示“高级信息”区;非会员展示锁定卡片与登录入口。
Show Layer 1 primary fields first (single column).
Then expandable details block (single column).
Advanced block stays last; guests see lock prompt and sign-in action.
四、空值规则 Empty
字段为空统一显示 -(不渲染 null/undefined)。
会员字段对非会员不输出真实值,仅显示锁定说明。
后台可按 guest/member 分别开关字段,前端实时读取配置。
REST API V1/V2
ipx.ee 提供两个版本的 REST API:V1 免费版(无限制)和 V2 VIP版(高质量数据,需 Token)。
ipx.ee provides two REST API versions: V1 Free (unlimited) and V2 VIP (high-quality data, token required).
一、版本概览 Overview
特性 API V1 API V2
认证 无需 Token 必需
数据源 ip2region + ip-api.com ipinfo.io + ipapi.is + ip2region + abuseipdb
数据质量 基础 高精度
查询限制 无限制 100-1000 次/月
线路类型 家庭/IDC 住宅/商业/托管/移动
风险检测 基础代理 VPN/Tor/滥用/爬虫/卫星
Abuse 联系 不支持 支持
输出格式 统一嵌套格式 统一嵌套格式
数据源标识 ipx.ee v1 ipx.ee v2
二、API V1(免费)
纯免费 API,无任何限制。适合开发测试、低频查询。
端点
GET /api/v1/ - 查询访客 IP
GET /api/v1/ip/{ip} - 查询指定 IP
GET /api/v1/domain/{domain} - 查询域名
示例
curl https://ipx.ee/api/v1/ip/8.8.8.8
数据字段说明
字段 类型 说明
ok boolean 查询是否成功
ip string IP 地址
hostname string|null 反向解析主机名
ip_type string IPv4 或 IPv6
geo.continent string|null 大洲名称
geo.country string|null 国家名称
geo.country_code string|null ISO 国家代码(如 US)
geo.region string|null 省份/州
geo.city string|null 城市
geo.district string|null 区县(中国IP常有)
geo.zip string|null 邮政编码
geo.latitude number|null 纬度
geo.longitude number|null 经度
geo.timezone string|null 时区
network.asn number|null ASN 号码
network.asn_org string|null ASN 组织名称
network.isp string|null ISP 名称
risk.is_mobile boolean 是否移动网络
risk.is_proxy boolean 是否代理
risk.is_datacenter boolean 是否数据中心
meta.version string 固定值 "v1"
meta.source string 固定值 "ipx.ee"
meta.is_china_ip boolean 是否中国IP
响应示例(中国 IP)
{
"ok": true,
"ip": "223.5.5.5",
"hostname": "public1.alidns.com",
"ip_type": "IPv4",
"geo": {
"continent": "亚洲",
"continent_code": "AS",
"country": "中国",
"country_code": "CN",
"region": "浙江",
"region_code": "ZJ",
"city": "杭州",
"district": "",
"zip": "310000",
"latitude": 30.287459,
"longitude": 120.153576,
"timezone": "Asia/Shanghai"
},
"network": {
"asn": 45102,
"asn_org": "Alibaba",
"isp": "阿里"
},
"risk": {
"is_mobile": false,
"is_proxy": false,
"is_datacenter": true
},
"meta": {
"version": "v1",
"source": "ipx.ee",
"is_china_ip": true
}
}
响应示例(国际 IP)
{
"ok": true,
"ip": "8.8.8.8",
"hostname": "dns.google",
"ip_type": "IPv4",
"geo": {
"continent": "North America",
"continent_code": "NA",
"country": "United States",
"country_code": "US",
"region": "Virginia",
"city": "Ashburn",
"zip": "20149",
"latitude": 39.03,
"longitude": -77.5,
"timezone": "America/New_York"
},
"network": {
"asn": 15169,
"asn_org": "Google LLC",
"isp": "Google LLC"
},
"risk": {
"is_mobile": false,
"is_proxy": false,
"is_datacenter": true
},
"meta": {
"version": "v1",
"source": "ipx.ee",
"is_china_ip": false
}
}
三、API V2(VIP)
高质量 API,使用付费数据源,必须携带 Token。
认证方式
Authorization: Bearer YOUR_TOKEN
# 或
X-API-Key: YOUR_TOKEN
Token 配额
Token 类型 月配额 说明
free 100 次 免费用户,可看广告增加
standard 1000 次 标准注册用户
vip 自定义 付费用户
响应头信息
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 995
X-RateLimit-Reset: 2026-03-01T00:00:00+00:00
X-Token-Type: standard
端点
GET /api/v2/ - 查询访客 IP
GET /api/v2/ip/{ip} - 查询指定 IP
GET /api/v2/domain/{domain} - 查询域名
示例
curl -H "Authorization: Bearer YOUR_TOKEN" \
https://ipx.ee/api/v2/ip/8.8.8.8
数据字段说明
字段 类型 说明
ok boolean 查询是否成功
ip string IP 地址
hostname string|null 反向解析主机名
ip_type string IPv4 或 IPv6
地理位置 geo
geo.continent string|null 大洲名称
geo.continent_code string|null 大洲代码(如 NA)
geo.country string|null 国家名称
geo.country_code string|null ISO 国家代码
geo.region string|null 省份/州
geo.region_code string|null 区域代码
geo.city string|null 城市
geo.zip string|null 邮政编码
geo.latitude number|null 纬度
geo.longitude number|null 经度
geo.timezone string|null 时区
geo.local_time string|null 本地时间(ISO 8601)
geo.accuracy_radius number|null 精度半径(公里)
网络信息 network
network.asn number|null ASN 号码
network.asn_organization string|null ASN 组织名称
network.asn_domain string|null ASN 域名
network.asn_type string|null ASN 类型(isp/business 等)
network.asn_created string|null ASN 创建日期
network.asn_updated string|null ASN 更新日期
network.route string|null IP 段路由(CIDR)
network.rir string|null 注册机构(ARIN/RIPE/APNIC 等)
network.isp string|null ISP 名称
network.assigned_org string|null 分配组织
风险检测 risk
risk.is_vpn boolean 是否 VPN
risk.is_proxy boolean 是否代理
risk.is_tor boolean 是否 Tor
risk.is_datacenter boolean 是否数据中心
risk.is_mobile boolean 是否移动网络
risk.is_satellite boolean 是否卫星网络
risk.is_bogon boolean 是否 Bogon 地址
risk.is_crawler boolean 是否爬虫
risk.is_abuser boolean 是否被标记滥用
risk.abuse_score number|null 滥用评分(0-100)
联系信息 contacts
contacts.abuse_email string|null Abuse 联系邮箱
contacts.abuse_phone string|null Abuse 联系电话
元数据 meta
meta.version string 固定值 "v2"
meta.source string 固定值 "ipx.ee"
meta.tier string vip
meta.is_china_ip boolean 是否中国IP
响应示例(中国 IP - 阿里云 DNS)
{
"ok": true,
"ip": "223.5.5.5",
"hostname": "public1.alidns.com",
"ip_type": "IPv4",
"geo": {
"continent": "亚洲",
"continent_code": "AS",
"country": "中国",
"country_code": "CN",
"region": "浙江",
"region_code": "ZJ",
"city": "杭州",
"zip": "310000",
"latitude": 30.287459,
"longitude": 120.153576,
"timezone": "Asia/Shanghai",
"local_time": "2026-02-19T05:52:19+08:00"
},
"network": {
"asn": 45102,
"asn_organization": "Alibaba",
"asn_domain": "alibabacloud.com",
"asn_type": "business",
"route": "223.5.5.0/24",
"rir": "APNIC",
"assigned_org": "Aliyun Computing Co., LTD"
},
"risk": {
"is_vpn": false,
"is_proxy": false,
"is_tor": false,
"is_datacenter": true,
"is_mobile": false,
"is_satellite": false,
"is_bogon": false,
"is_crawler": false,
"is_abuser": false,
"abuse_score": 0
},
"contacts": {
"abuse_email": "didong.jc@alibaba-inc.com",
"abuse_phone": "+86-000000000"
},
"meta": {
"version": "v2",
"source": "ipx.ee",
"tier": "vip",
"is_china_ip": true
}
}
响应示例(国际 IP - Cloudflare)
{
"ok": true,
"ip": "1.1.1.1",
"hostname": "one.one.one.one",
"ip_type": "IPv4",
"geo": {
"continent": "Oceania",
"continent_code": "OC",
"country": "Australia",
"country_code": "AU",
"region": "Queensland",
"region_code": "QLD",
"city": "Brisbane",
"zip": "4000",
"latitude": -27.4679,
"longitude": 153.0281,
"timezone": "Australia/Brisbane",
"local_time": "2026-02-19T07:52:02+10:00",
"accuracy_radius": 50
},
"network": {
"asn": 13335,
"asn_organization": "Cloudflare",
"asn_domain": "cloudflare.com",
"asn_type": "business",
"route": "1.1.1.0/24",
"rir": "ARIN",
"assigned_org": "APNIC Research and Development"
},
"risk": {
"is_vpn": false,
"is_proxy": false,
"is_tor": false,
"is_datacenter": true,
"is_mobile": false,
"is_satellite": false,
"is_bogon": false,
"is_crawler": false,
"is_abuser": false,
"abuse_score": null
},
"contacts": {
"abuse_email": "helpdesk@apnic.net",
"abuse_phone": "+61-7-38583100"
},
"meta": {
"version": "v2",
"source": "ipx.ee",
"tier": "vip",
"is_china_ip": false
}
}
额度耗尽响应 (429)
{
"ok": false,
"error": "monthly quota exceeded. limit: 100, reset at: 2026-03-01...",
"quota": {
"limit": 100,
"remaining": 0,
"reset_at": "2026-03-01T00:00:00+00:00"
}
}
四、对比与选择 Compare
数据合并策略
场景 V1 策略 V2 策略
中国 IP
ip2region 优先 ip-api.com 补充缺失字段
ip2region 优先 ipinfo.io 补充 ipapi.is 补充 abuseipdb 补充
国际 IP
ip-api.com 优先 ip2region 补充
ipinfo.io 优先 ipapi.is 补充 ip2region 补充 abuseipdb 补充
何时使用 V1?
[适用] 开发测试阶段
[适用] 低频查询(< 100次/月)
[适用] 基础地理位置需求
[适用] 预算有限的项目
[适用] 中国 IP 需要详细地理信息(省市区、邮编、区号)
何时使用 V2?
[适用] 生产环境
[适用] 需要高精度数据
[适用] 需要风险检测(VPN/代理/Tor/爬虫识别)
[适用] 需要 ASN 详细信息(创建/更新时间、RIR)
[适用] 需要 Abuse 联系方式
[适用] 需要 IP 段路由信息
获取 Token
注册 ipx.ee 账号
进入「控制台」→「API Token」
生成 Token(免费用户默认 100 次/月)
观看广告可增加额度(+50 次)
输出格式统一说明
V1 和 V2 均使用统一的嵌套格式 输出
所有响应均包含 geo、network、risk 对象
V2 额外包含 contacts 对象(Abuse 联系信息)
JSON 中不暴露原始数据源名称(ip2region/ipapi/ipinfo 等)
统一标识为 meta.source: "ipx.ee" 和版本号
Umami Analytics API
配置 Umami Analytics API,在后台仪表板显示网站访问统计数据。
Configure Umami Analytics API to display website statistics on the admin dashboard.
一、功能说明 Overview
支持 Umami Cloud 和自托管版本。
自动获取过去 30 天的访问统计数据。
包含访客数、浏览量、会话数、跳出率等指标。
显示访客地区分布 Top 5。
Supports both Umami Cloud and self-hosted versions.
Automatically fetches statistics for the past 30 days.
Includes visitors, pageviews, sessions, bounce rate metrics.
Displays top 5 visitor countries/regions.
二、身份验证 Authentication
Umami 提供两种身份验证方式,取决于您使用的是 Umami Cloud 还是自托管版本。
Umami provides two authentication methods depending on whether you use Umami Cloud or self-hosted.
Authorization Header
Authorization: Bearer <token>
三、Umami Cloud
对于 Umami Cloud 用户,只需生成 API Key 即可。
登录 Umami Cloud
进入 Settings → API Keys
点击 "Create API Key"
复制生成的 API Key(格式:um_xxxxxxxxxxxxxxxx)
四、自托管 Self-hosted
以下身份验证方法仅适用于自托管的 Umami。对于 Umami Cloud,您只需生成一个 API 密钥即可。
The following authentication methods only apply to self-hosted Umami. For Umami Cloud, you only need to generate an API key.
POST /api/auth/login
首先,您需要获取一个令牌才能发起 API 请求。向 /api/auth/login 端点发送 POST 请求:
Request
POST /api/auth/login
Content-Type: application/json
{
"username": "your-username",
"password": "your-password"
}
Response
{
"token": "eyTMjU2IiwiY...4Q0JDLUhWxnIjoiUE_A",
"user": {
"id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"username": "admin",
"role": "admin",
"createdAt": "2000-00-00T00:00:00.000Z",
"isAdmin": true
}
}
保存令牌值,并在所有数据请求中添加 Authorization 请求头,值为 Bearer <token>。
curl 示例
curl https://{yourserver}/api/websites \
-H "Accept: application/json" \
-H "Authorization: Bearer <token>"
POST /api/auth/verify
您可以验证该令牌是否仍然有效。
Response
{
"id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"username": "admin",
"role": "admin",
"createdAt": "2000-00-00T00:00:00.000Z",
"isAdmin": true,
"teams": []
}
五、获取 Website ID
Website ID 是 UUID 格式的字符串,用于标识您的网站。
登录 Umami 后台
点击您要查看的网站
进入网站设置(Settings/设置)
复制 Website ID(格式:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
常用 API 端点
GET /api/websites/{id}/stats?startAt={ts}&endAt={ts}
→ 获取网站统计数据
GET /api/websites/{id}/pageviews?startAt={ts}&endAt={ts}&unit=day
→ 获取页面浏览量时间序列
GET /api/websites/{id}/metrics?startAt={ts}&endAt={ts}&type=country
→ 获取地区分布数据