Diffchecker API

At the moment there exists 3 endpoints for computing text diffs, pdf diffs, and image diffs, all with varying output types. We plan to gradually add more input and output types as we move forward with the API (e.g. Excel, etc).

You may find the following resources helpful when dealing with PDF and image diffs:
This is a free beta, but we will email all Diffchecker API users with the pricing at least a week in advance of the stable version being released.

Text Diff
Usage
POST https://api.diffchecker.com/public/text
Parameters
Name          Type    In     Required    Description
-------------------------------------------------------------------------------------------------------------
output_type   string  query  yes         Specifies the type of output you receive in the response body.
                                         Value must be one of 'json', 'html', or 'html_json'.
                                           - json: (Content-Type: application/json)
                                                   Row metadata generated from diff computation
                                           - html: (Content-Type: text/html)
                                                   Same html/css you see on Diffchecker site
                                           - html_json: (Content-Type: application/json)
                                                   Same html/css you see on Diffchecker site, but split up
                                                   and embedded in JSON
email         string  query  yes         Email we can use to contact you.
diff_level    string  query  no          Specifies whether you want to diff by word or character.
                                         Value must be one of 'word' or 'character'. Default is 'word'.
left          string  body   yes         Left text you want to diff.
right         string  body   yes         Right text you want to diff.
Examples
curl --location --request POST 'https://api.diffchecker.com/public/text?output_type=html&email=YOUR_EMAIL' \
--header 'Content-Type: application/json' \
--data-raw '{
    "left": "roses are red\nviolets are blue",
    "right": "roses are green\nviolets are purple",
    "diff_level": "word"
}'
JSON Responses
output_type=json
{
  "rows": [
    {
      "end": false,
      "left": {
        "chunks": [
          {
            "value": "roses are ",
            "type": "equal"
          },
          {
            "value": "red",
            "type": "remove"
          }
        ],
        "line": 1
      },
      "right": {
        "chunks": [
          {
            "value": "roses are ",
            "type": "equal"
          },
          {
            "value": "green",
            "type": "insert"
          }
        ],
        "line": 1
      },
      "insideChanged": true,
      "start": true
    },
    {
      "end": true,
      "left": {
        "chunks": [
          {
            "value": "",
            "type": "remove"
          },
          {
            "value": "violets are ",
            "type": "equal"
          },
          {
            "value": "blue",
            "type": "remove"
          }
        ],
        "line": 2
      },
      "right": {
        "chunks": [
          {
            "value": "",
            "type": "insert"
          },
          {
            "value": "violets are ",
            "type": "equal"
          },
          {
            "value": "purple",
            "type": "insert"
          }
        ],
        "line": 2
      },
      "insideChanged": true
    }
  ],
  "added": 3,
  "removed": 3
}
output_type=html_json
{
  "html": "<table class=\"diff-table\"><thead><tr><td class=\"line-number-header\"></td><td class=\"side-content-header\"></td><td class=\"line-number-header\"></td><td class=\"side-content-header\"></td></tr></thead><tbody><tr class=\"diff-row\"><td data-content=\"1\" class=\"diff-line-number\"></td><td class=\"diff-line start diff-line-modified diff-line-with-removes\"><span class=\"diff-chunk diff-chunk-equal diff-chunk-modified\">roses are </span><span class=\"diff-chunk diff-chunk-removed diff-chunk-modified\">red</span></td><td data-content=\"1\" class=\"diff-line-number\"></td><td class=\"diff-line start diff-line-modified diff-line-with-inserts\"><span class=\"diff-chunk diff-chunk-equal diff-chunk-modified\">roses are </span><span class=\"diff-chunk diff-chunk-inserted diff-chunk-modified\">green</span></td></tr><tr class=\"diff-row\"><td data-content=\"2\" class=\"diff-line-number\"></td><td class=\"diff-line end diff-line-modified diff-line-with-removes\"><span class=\"diff-chunk diff-chunk-removed diff-chunk-modified\"></span><span class=\"diff-chunk diff-chunk-equal diff-chunk-modified\">violets are </span><span class=\"diff-chunk diff-chunk-removed diff-chunk-modified\">blue</span></td><td data-content=\"2\" class=\"diff-line-number\"></td><td class=\"diff-line end diff-line-modified diff-line-with-inserts\"><span class=\"diff-chunk diff-chunk-inserted diff-chunk-modified\"></span><span class=\"diff-chunk diff-chunk-equal diff-chunk-modified\">violets are </span><span class=\"diff-chunk diff-chunk-inserted diff-chunk-modified\">purple</span></td></tr></tbody></table>",
  "css": "\n.diff-table {\n  font-family: monospace;\n  background: #FFFFFF;\n  font-size: 0.8125rem;\n  border-collapse: collapse;\n}\n.side-content-header {\n  width: 50%;\n}\n.diff-row {\n  outline: 0;\n}\n.diff-line-number {\n  color: #999;\n  padding: 0 8px 0 5px;\n  text-align: right;\n  vertical-align: top;\n}\n.diff-line-number:before {\n  content: attr(data-content);\n}\n.diff-line {\n  white-space: pre-wrap;\n  word-break: break-all;\n  line-height: 1rem;\n  padding-right: 20px;\n}\n.diff-line-inserted {\n  background: #B5EFDB;\n}\n.diff-line-removed {\n  background: #FFC4C1;\n}\n.diff-line-empty {\n  background: #EAEEF0;\n}\n.diff-line-modified.diff-line-with-inserts {\n  background: #B5EFDB;\n}\n.diff-line-modified.diff-line-with-removes {\n  background: #FFC4C1;\n}\n.diff-chunk-inserted {\n  background: #6BDFB8;\n}\n.diff-chunk-removed {\n  background: #FF8983;\n}\n"
}
PDF Diff
Usage
POST https://api.diffchecker.com/public/pdf
Parameters
Name          Type    In     Required    Description
-------------------------------------------------------------------------------------------------------------
output_type   string  query  yes         Specifies the type of output you receive in the response body.
                                         Value must be one of 'json', 'html', or 'html_json'.
                                           - json: (Content-Type: application/json)
                                                   Row metadata generated from PDF-text diff computation
                                           - html: (Content-Type: text/html)
                                                   Same html/css you see on Diffchecker site for PDF-text diffs
                                           - html_json: (Content-Type: application/json)
                                                   Same html/css you see on Diffchecker site for PDF-text diffs,
                                                   but split up and embedded in JSON
                                           - png_json: (Content-Type: application/json)
                                                   Same PNGs you see on Diffchecker site for PDF-image diffs, but
                                                   embedded in JSON as data urls and additional metadata 
email         string  query  yes         Email we can use to contact you.
diff_level    string  query  no          Specifies whether you want to diff by word or character.
                                         Value must be one of 'word' or 'character'. Default is 'word'.
                                         Should only be used with PDF-text diff related output types.
left_pdf      file    body   yes         Left pdf file you want to diff. File extension must be .pdf
right_pdf     file    body   yes         Right pdf file you want to diff. File extension must be .pdf
Examples
curl --location --request POST 'https://api.diffchecker.com/public/pdf?input_type=form&output_type=png_json&email=YOUR_EMAIL' \
--form 'left_pdf=@"/Users/user_name/Documents/example-1.pdf"' \
--form 'right_pdf=@"/Users/user_name/Documentsr/example-2.pdf"'
JSON Responses
output_type=json
Same structure as Text diff response with output_type=json
output_type=html_json
Same structure as Text diff response with output_type=html_json
output_type=png_json
{
  "results": [
    {
      "mismatchPercentage": 0.38,
      "imageDataUrl": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABVAAAAS8CAYAAABqj6EFAAAABmJLR0QA/wD/AP...",
      "pageSide": "both"
    },
    {
      "mismatchPercentage": 0.5,
      "imageDataUrl": "data:image/png;base64,iVBORw0KGgoBBBBNSUhEUgAABVBBBBS8CAYAAABqj6EFBBBBBmJLR0QA/wD/AP...",
      "pageSide": "both"
    },
    {
      "mismatchPercentage": 100,
      "imageDataUrl": "data:image/png;base64,iVBORw0KGgoCCCCNSUhEUgAABVCCCCS8CAYAAABqj6EFCCCCBmJLR0QA/wD/AP...",
      "pageSide": "left"
    }
  ]
}
Image Diff
Usage
POST https://api.diffchecker.com/public/image
Parameters
Name          Type    In     Required    Description
-------------------------------------------------------------------------------------------------------------
input_type    string            query  yes         Specifies the request content-type. Value must be one of 'json' or 'form'
                                                     - json: application/json
                                                     - form: multipart/form-data
output_type   string            query  yes         Specifies the type of output you receive in the response body.
                                                   Value must be one of 'json' or 'png'.
                                                     - json: (Content-Type: application/json)
                                                             Same PNG you see on Diffchecker site for image diffs, but
                                                             embedded in JSON as a data url 
                                                     - png: (Content-Type: image/png)
                                                             Same PNG you see on Diffchecker site for image diffs
email         string            query  yes         Email we can use to contact you.
left_image    file or string    body   yes         If input_type=json:
                                                     string containing data url of left image you want to diff (link)
                                                   If input_type=form:
                                                     file of left image you want to diff. Accepted file extensions include .png, .jpg, .jpeg
right_image    file or string    body   yes         If input_type=json:
                                                     string containing data url of right image you want to diff (link)
                                                   If input_type=form:
                                                     file of right image you want to diff. Accepted file extensions include .png, .jpg, .jpeg
Examples
Form Input:
curl --location --request POST 'https://api.diffchecker.com/public/image?input_type=form&output_type=png&email=YOUR_EMAIL' \
--form 'left_image=@"/Users/user_name/Documents/example-1.png"' \
--form 'right_image=@"/Users/user_name/Documentsr/example-2.png"'

JSON Input:
curl --location --request POST 'https://api.diffchecker.com/public/image?input_type=json&output_type=png&email=YOUR_EMAIL' \
--header 'Content-Type: application/json' \
--data-raw '{
    "left_image": <left image data url>,
    "right_image": <right image data url>,
}'
JSON Responses
output_type=json
{
  "dataUrl": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABVAAAAS8CAYAAABqj6EFAAAABmJLR0QA/wD/AP..."
}