A link preview comparison returns one result for each URL in the response, in the same order. A failed preview keeps its place. complete is true only when every preview succeeds.
This convention covers the JSON results produced by Unfurls and used by the compare-link-previews tool on listof.tools. It specifies the fields needed to match results and handle failures. Additional fields are allowed.
Matching results to URLs
schemaVersion is the number 1. urls is a nonempty array of URL strings. entries is an array of the same length.
For every position i, counting from zero, both rules must hold.
entries[i].indexis the integeri.entries[i].urlis the stringurls[i].
Use the returned URL list. Unfurls normalizes submitted URLs and removes duplicates, keeping the first occurrence. Submitting the same URL twice can therefore yield a single result.
Reading the outcome
Every entry has one of two status strings.
"ok"requires adataobject containing preview metadata. A cached preview counts as a success."error"requires anerrorobject with a numericstatusand a human-readablemessagestring. It may includeretryAfterin seconds.
complete is a boolean. It must be true when every entry has status "ok" and false when some or all entries have status "error".
HTTP status and retries
An ordered result uses HTTP 200 unless every entry is an error with status 429. HTTP 200 alone does not establish that any preview succeeded.
When every entry has error status 429, the response uses HTTP 429, retains all entries and supplies a Retry-After header in seconds. Wait at least that long before retrying the set. For a mixed result, keep successful previews and respect each failed entry's error.retryAfter when present.
A request can also be rejected before results are produced. A request-level rate limit can return HTTP 429 with a top-level error and no entries. Respect the retry delay. Such a body falls outside the ordered result format.
Example with one failed preview
The middle URL fails. The third URL keeps index 2. This excerpt omits unrelated fields.
{
"schemaVersion": 1,
"urls": ["https://example.org/a", "https://example.org/b", "https://example.org/c"],
"complete": false,
"entries": [
{"index": 0, "url": "https://example.org/a", "status": "ok", "data": {"title": "Page A"}},
{"index": 1, "url": "https://example.org/b", "status": "error", "error": {"status": 502, "message": "This site could not be unfurled."}},
{"index": 2, "url": "https://example.org/c", "status": "ok", "data": {"title": "Page C"}}
]
}
Setting complete to true or dropping the failed entry would make this response invalid.
Reuse
The publisher dedicates this publication to the public domain under CC0 1.0 Universal.