diff.io :: api

We use JWT to ensure that api requests (claims) are generated by your account or CMS plug-ins. First create your object and encode it as JSON, then you create a JWT using a process like the below (in javascript):

This will result in a token like:

eyAiYWxnIjogIkhTMjU2IiwgInR5cCI6ICJKV1QifQ.eyJ1cmwxIjoiaHR0cDovL2RpZmYuaW8iLCJpc3MiOiJQMCIsImp0aSI6IjE0Mjg3MjEwMDYifQ.5SynwA3TZZgI9xeWJ9AK-K0hNaTDm6HSifO0dxOkvX4

Then you POST the request (no body required) to:

https://api.diff.io/v1/diff/{apikey}/{token}

If all goes well you should be sent a 303 redirect, landing you on a response like the below:

{diff: “io”status: “pending”}

Once the job has been processed, you will be able to retrieve the results at the same address. The output will be json which looks like the below:

{
diff: “io”,
status: “success”,
url: “https://diff.io/”,
from: “2015-03-10 15:08:42 UTC”,
to: “2015-04-05 04:52:00 UTC”,
different_pixels: 0,
total_pixels: 2583000,
job_took: “28 seconds”,
composite: “http://done.diff.io/v1/diffs/{date}/{jobid}/composite.png”,
montage: “http://done.diff.io/v1/diffs/{date}/{jobid}/montage.png”
}

montage_thumb

Every account comes with a pusher.com channel, so you can stream requests as they happen. We’ll cover how to listen to this channel in a future blog post. As well as the types of requests supported by diff.io.

If you are looking for a JWT library for your language of choice, checkout JWT.io.

 


 

Want to visually track any site on the internet, sign up today or contact us with questions.

Footnote:

Quoting the IETF draft:

JSON Web Token (JWT) is a compact, URL-safe means of representing claims to be transferred between two parties. The claims in a JWT are encoded as a JavaScript Object Notation (JSON) object that is used as the payload of a JSON Web Signature (JWS) structure or as the plaintext of a JSON Web Encryption (JWE) structure, enabling the claims to be digitally signed or MACed and/or encrypted.