Knowing when a comparison is ready
Comparison is asynchronous, so a newly created comparison is not immediately viewable. Fetch it to check:Polling sensibly
If you poll, back off rather than hammering the endpoint. Most comparisons complete in seconds, but a large document takes longer. A reasonable pattern is to check after one second, then at growing intervals, with an overall timeout after which you surface an error to the user. Better still, avoid polling altogether using thewait parameter described below.
Viewer URLs
The viewer is where your users actually see the comparison. Viewer URLs are built from your account ID and the comparison identifier:Public comparisons
If you created the comparison withpublic=true, the URL above works as-is. Anyone holding it can open the comparison.
Private comparisons (the default)
Private comparisons require a signed URL. The signature proves the URL was issued by you, and it carries an expiry, so access is time-limited. A signed URL adds two query parameters:This is the intended way to show a comparison to an end user. The user gets time-limited access to one specific comparison and never sees your auth token.
Generating a signed URL
The client libraries do this for you, and using them is strongly recommended over implementing the signature yourself:valid_until timestamp, keyed with your auth token, and hex encode the result. Getting this wrong produces a link the viewer rejects as invalid.
Choosing an expiry
Keepvalid_until as short as your workflow allows. The client libraries default to 30 minutes, which suits the common case of generating a link at the moment a user clicks through to view a comparison.
Longer expiries are appropriate when you are emailing a link that someone may open later, but the longer the window, the longer a forwarded link keeps working.
Skipping the wait with wait
Rather than polling until a comparison is ready and only then handing over a URL, you can add wait to the viewer URL:
identifier, this means you can construct the viewer URL and redirect a user to it immediately after creating the comparison, with no polling logic at all.
When combining wait with a signature, it is appended alongside the other parameters:

