Developer Reference

Redirect Chain

Explore Redirect Chain API documentation, request parameters, response fields, code examples, and error handling for DomScan integrations.

Redirect Chain

Follow URL redirect chains to detect HTTPS upgrades, domain changes, and final landing pages. Useful for SEO analysis, security auditing, and understanding URL routing. Tracks all 3xx redirects including 301, 302, 303, 307, and 308.

GET /v1/redirects

Query Parameters

ParameterTypeDescription
url required string Starting URL to follow (e.g., "http://example.com")
max_redirects optional number Maximum redirects to follow (default: 10, max: 20)

Response Fields

FieldTypeDescription
original_urlstringStarting URL that was provided
final_urlstringFinal URL after all redirects
redirect_countnumberTotal number of redirects followed
https_upgradebooleanWhether HTTP was upgraded to HTTPS
chainarrayEach redirect with URL, status code, location

Example Request

curl -H "X-API-Key: your-api-key" "https://domscan.net/v1/redirects?url=http://github.com"
const domscanFetch = (url, options = {}) =>
  fetch(url, {
    ...options,
    headers: { ...options.headers, "X-API-Key": "your-api-key" },
  });

const response = await domscanFetch(
  "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

domscan = requests.Session()
domscan.headers.update({"X-API-Key": "your-api-key"})

from urllib.parse import quote

url = quote("http://github.com", safe='')
response = domscan.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']}")

Example Response

{
  "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
}