开发者参考

重定向链 API 文档

重定向链 API 文档: 跟随 URL 重定向链以检测 HTTPS 升级、域名更改和最终登陆页面。对于 SEO 分析、安全审计和理解 URL 路由很有用。跟踪所有 3xx 重定向,包括 301、302、303、307 和 308。

重定向链

跟随 URL 重定向链以检测 HTTPS 升级、域名更改和最终登陆页面。对于 SEO 分析、安全审计和理解 URL 路由很有用。跟踪所有 3xx 重定向,包括 301、302、303、307 和 308。

GET /v1/redirects

查询参数

参数类型说明
url 必需 string 要跟随的起始 URL(例如 "http://example.com")
max_redirects 可选 number 要跟随的最大重定向数(默认值:10,最大值:20)

响应字段

字段类型说明
original_urlstring提供的起始 URL
final_urlstring所有重定向后的最终 URL
redirect_countnumber跟随的总重定向数
https_upgradebooleanHTTP 是否升级到 HTTPS
chainarray每个重定向的 URL、状态代码、位置

请求示例

curl "https://domscan.net/v1/redirects?url=http://github.com"
const response = await fetch(
  "https://domscan.net/v1/redirects?url=" + encodeURIComponent("http://github.com")
);
const data = await response.json();

console.log(`Final URL: ${data.final_url}`);
console.log(`Redirects: ${data.redirect_count}`);
console.log(`HTTPS upgrade: ${data.https_upgrade}`);

data.chain.forEach((hop, i) => {
  console.log(`${i + 1}. ${hop.status} ${hop.url} → ${hop.location}`);
});
import requests
from urllib.parse import quote

url = quote("http://github.com", safe='')
response = requests.get(f"https://domscan.net/v1/redirects?url={url}")
data = response.json()

print(f"Final URL: {data['final_url']}")
print(f"HTTPS upgrade: {data['https_upgrade']}")
for i, hop in enumerate(data['chain']):
    print(f"{i+1}. [{hop['status']}] {hop['url']}")

响应示例

{
  "original_url": "http://github.com",
  "final_url": "https://github.com/",
  "redirect_count": 1,
  "chain": [
    {
      "url": "http://github.com",
      "status": 301,
      "location": "https://github.com/",
      "response_time_ms": 45
    }
  ],
  "https_upgrade": true,
  "domain_change": false,
  "total_time_ms": 156
}

被出色公司的人们使用

VercelLLM PulseOLXCasa ModernaPipeCal.comBeehiivSnykTogglRemoteSprigDeel