Canonical URL API
free/v1/domain/canonicalComprehensive canonical URL audit: extracts canonical tags from HTML and HTTP headers, validates placement, checks for conflicts, analyzes hreflang annotations, detects redirect chains, and cross-references with og:url. Returns a scored assessment with actionable SEO recommendations.
What It Does
Fetches the page with redirect tracking, parses both HTML <link> tags and HTTP Link headers for canonical URLs, validates tag placement in <head>, detects multiple/conflicting canonicals, checks og:url consistency, analyzes hreflang annotations, and grades the overall canonical configuration.
Why It's Useful
Canonical URLs tell search engines which version of a page to index. Incorrect canonicals — duplicates, conflicting signals, wrong placement, or cross-domain misconfigurations — can cause indexing failures and lost rankings. This endpoint catches all common canonical issues in a single request.
Use Cases
SEO Audit
Verify canonical URLs are correctly set across the site to prevent duplicate content issues.
Catch critical issues like multiple canonicals, body placement, and og:url mismatches that tools like Screaming Frog would flag.
International SEO
Verify hreflang annotations correctly link language/region versions and include x-default.
Ensure correct regional versions appear in local search results with validated language codes.
Site Migration
After migration, verify canonical URLs point to the new domain and redirect chains are clean.
Detect cross-domain canonicals, redirect chains, and HTTP/HTTPS mismatches before they impact rankings.
Continuous Monitoring
Integrate into CI/CD to catch canonical regressions before deployment.
Prevent SEO-breaking changes from reaching production using the score and grade system.
Parameters
| Name | Location | Type | Required | Description |
|---|---|---|---|---|
domain | query | string | Required | Domain or full URL — accepts `example.com` or `https://example.com/path`.Example: https://example.com |
validateReciprocity | query | boolean | Optional | Developer+ only: when true, fetches each hreflang alternate (cap 20) and verifies it declares a return link to the source page. Catches the #1 international-SEO failure mode (missing return links cause Google to ignore the entire cluster).Example: true |
Response Fields
Result fields below are inside the JSON data object. Any row named meta describes the sibling response metadata object. See response and error handling for status codes and error responses. Optional observations may be absent or null; inspect warnings and partial-failure fields before treating a missing result as a negative finding.
| Field | Type | Description |
|---|---|---|
domain | string | The queried domain (bare hostname). |
url | string | Full URL that was fetched, echoing the protocol used in the request. |
requestedUrl | string | The initial URL that was fetched |
finalUrl | string | The URL after following all redirects |
redirectChain | array | URLs in the redirect chain before reaching final content |
canonical | object | Canonical URL details (url, source, httpHeaderUrl, isAbsolute, isHttps, isSelfReferencing, isCrossDomain, canonicalCount, inHead) |
targetValidation | object | Canonical target URL validation (status, isReachable, hasNoindex, isChain, chainTarget, targetRedirected) — null if self-referencing |
ogUrl | string | The og:url meta tag value for cross-signal comparison |
ogUrlMatch | boolean | Whether og:url matches the canonical URL |
hreflang | object | Hreflang analysis: alternates array, count, hasXDefault, duplicateCodes (same code declared twice). Pass validateReciprocity=true (Developer+) to add a return-link audit: each alternate is fetched and checked for a back-link to the source — the #1 international-SEO failure mode per Google. |
score | number | Canonical health score from 0-100 |
grade | string | Letter grade (A-F) based on score |
issues | array | Severity-graded issues with codes and recommendations (critical, warning, info) |
Code Examples
Replace YOUR_API_KEY with your API key. This endpoint requires the free plan or higher; see plans and usage limits.
curl --request GET 'https://api.edgedns.dev/v1/domain/canonical?domain=https%3A%2F%2Fexample.com' \
--header "Authorization: Bearer YOUR_API_KEY"const response = await fetch(
"https://api.edgedns.dev/v1/domain/canonical?domain=https%3A%2F%2Fexample.com",
{
"method": "GET",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
);
if (!response.ok) {
throw new Error(`EdgeDNS returned HTTP ${response.status}`);
}
const data = await response.json();
console.log(data);import requests
response = requests.request(
'GET',
"https://api.edgedns.dev/v1/domain/canonical?domain=https%3A%2F%2Fexample.com",
headers={'Authorization': 'Bearer YOUR_API_KEY'},
timeout=60,
)
response.raise_for_status()
data = response.json()
print(data)Read the full Canonical URL guide
Learn the concepts, choose a practical workflow, and interpret the observations from Canonical URL before acting on them. Run supported checks via MCP or through REST.
Read the guide →Related Endpoints
External References
Learn more about the standards and protocols behind this endpoint.
Try This Endpoint
Test the Canonical URL endpoint live in the playground.