Skip to main content

Canonical URL API

free
GET/v1/domain/canonical

Comprehensive 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 Specialist

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.

Global Marketing Manager

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.

SEO Engineer

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.

DevOps Engineer

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

NameLocationTypeRequiredDescription
domainquerystringRequiredDomain or full URL — accepts `example.com` or `https://example.com/path`.Example: https://example.com
validateReciprocityquerybooleanOptionalDeveloper+ 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.

FieldTypeDescription
domainstringThe queried domain (bare hostname).
urlstringFull URL that was fetched, echoing the protocol used in the request.
requestedUrlstringThe initial URL that was fetched
finalUrlstringThe URL after following all redirects
redirectChainarrayURLs in the redirect chain before reaching final content
canonicalobjectCanonical URL details (url, source, httpHeaderUrl, isAbsolute, isHttps, isSelfReferencing, isCrossDomain, canonicalCount, inHead)
targetValidationobjectCanonical target URL validation (status, isReachable, hasNoindex, isChain, chainTarget, targetRedirected) — null if self-referencing
ogUrlstringThe og:url meta tag value for cross-signal comparison
ogUrlMatchbooleanWhether og:url matches the canonical URL
hreflangobjectHreflang 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.
scorenumberCanonical health score from 0-100
gradestringLetter grade (A-F) based on score
issuesarraySeverity-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
curl --request GET 'https://api.edgedns.dev/v1/domain/canonical?domain=https%3A%2F%2Fexample.com' \
  --header "Authorization: Bearer YOUR_API_KEY"
JavaScript
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);
Python
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.

    Canonical URL API Reference | EdgeDNS