> For the complete documentation index see https://domscan.net/llms.txt. Markdown versions of every docs page are available by appending .md to the page URL.

Source: https://domscan.net/docs/redirect-chain

# Redirect Chain

DomScan API: Follow URL redirect chains to detect HTTPS upgrades, domain changes, and final landing pages.

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

| Parameter | Type | Description |
| --- | --- | --- |
| url required | string | Starting URL to follow (e.g., "http://example.com") |
| max_redirects optional | number | Maximum redirects to follow (default: 10, max: 20) |
| domain optional | string | Alias for url when you only have a bare domain. The url parameter wins when both are supplied, and https:// is added automatically. |

#### Response fields

| Field | Type | Description |
| --- | --- | --- |
| `original_url` | string | Starting URL that was provided |
| `final_url` | string | Final URL after all redirects |
| `redirect_count` | number | Total number of redirects followed |
| `https_upgrade` | boolean | Whether HTTP was upgraded to HTTPS |
| `chain` | array | Each redirect with URL, status code, location |

#### Example request

```bash
curl -H "X-API-Key: your-api-key" "https://domscan.net/v1/redirects?url=http://github.com"
```

```javascript
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}`);
});
```

```python
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

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