Skip to content

Pagefreezer API 2017 02 03

dcwalk edited this page Mar 12, 2017 · 1 revision

Pagefreezer provides a simple diff API that allows coparisons of file versions; results are returned as JSON in a straightforward way. At present only single-page comparisons are possible; we should determine whether it's worthwhile to use the service as currently constructed.

Access Token

To test this service, you'll need our access token, which we can't share in github. If you need it before the event, get in touch with @titaniumbones.

The Compare Service

This is the only service currently available; it allows comparison between two URL's or 2 html blobs (but not one of each). It's available here over POST only:

https://api1.pagefreezer.com/utils/v1/diff/compare

Parameters

Parameter Description
source (optional) Default: url.
url=url1 and url2 must be URL of the target document.
text=url1 and url2 contains HTML text document itself.
url1 The source URL or HTML
url2 The target URL or HTML
diffmode (optional) Default: 0.
0=No pre-processing,
1=extra white spaces removed,
2=[\s]* are removed,
3=HTML tags are removed for full-text comparison
html (optional) Default: 1.
2=HTML with HEAD,
1=HTML without HEAD,
0=False (no HTML output).
snippet (optional) Default: 200 (characters). It will generate snippets of changes.

Examples

Using httpie

http post https://api1.pagefreezer.com/v1/api/utils/diff/compare \
source=text \
url1="<h1>good news</h1>" \
url2="<h1>bad news</h1>" \
"x-api-key: KEYHERE"

Using curl

curl -v -H "Accept: application/json" \
        -H "Content-Type: application/json" \
        -H "x-api-key: "KEYHERE" \
        -X POST -d @./input.json \
        https://api1.pagefreezer.com/v1/api/utils/diff/compare

This example expects a file input.json:

{"url1":"http://apple.com/jp", "url2":"http://apple.com/kr"}

Using jQuery:

$.ajax({
  type: "POST",
  url: "https://api1.pagefreezer.com/v1/api/utils/diff/compare",
  data: {
    url1: "<h1>good news</h1>" 
    url2: "<h1>bad news</h1>"
    source: "text",
    dataType: "json"
  },
  headers: {"x-api-key": "KEYHERE"}
});
 

Testing

se the files in archives to test out the diff service