API 文档

在你的应用程序中使用可靠、低延迟的端点。

时间 API

以多种格式获取当前时间。

https://api.c.nf/time
格式: ISO 8601
响应类型: JSON
📅

时间戳 API

获取当前的 Unix 时间戳,以供精确计时。

https://api.c.nf/timestamp
格式: Unix Timestamp
响应类型: JSON
🌐

IP 地址 API

获取发出请求之客户端的 IP 地址。

https://api.c.nf/ip
格式: IPv4/IPv6
响应类型: Plain Text
🗺️

IP 地理定位 API

获取 IP 地址的大约位置数据。

https://api.c.nf/ip-geolocation
格式: Country Code
响应类型: JSON
💱

汇率 API

获取当前的货币汇率。基准货币可留空,默认为 USD。

https://api.c.nf/fx/rate?base=CNY
格式: Currency Pairs
响应类型: JSON
v1

DNS 管理 API(v1)

通过 Bearer 令牌身份验证及严格的用户隔离,管理 c.nf DNS 区域及记录。

https://api.c.nf/v1
格式: REST
响应类型: JSON

开始使用

时间、IP 地址及汇率等公共端点均可免费使用,无需身份验证。

位于 /v1 的 DNS 管理 API 需要来自 账户 → API 密钥 的 Bearer 令牌。令牌只能访问其拥有者已验证的区域。

公共端点

fetch('https://api.c.nf/time')
  .then(response => response.json())
  .then(data => console.log(data));

需要身份验证的 DNS v1 端点

fetch('https://api.c.nf/v1/dns/zones', {
  headers: { 'Authorization': 'Bearer cnf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' }
})
  .then(r => r.json())
  .then(data => console.log(data));