Diff Version
curl --request GET \
--url https://api.example.com/v0/diffsimport requests
url = "https://api.example.com/v0/diffs"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/v0/diffs', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v0/diffs",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v0/diffs"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/v0/diffs")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v0/diffs")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_bodyVersions
Diff Version
GET /v0/diffs: diff a version against the previous version, across a range of versions, or against a base version
GET
/
v0
/
diffs
Diff Version
curl --request GET \
--url https://api.example.com/v0/diffsimport requests
url = "https://api.example.com/v0/diffs"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/v0/diffs', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v0/diffs",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v0/diffs"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/v0/diffs")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v0/diffs")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_bodyRetrieve the difference between a version and the kept version before it; with
Text payload (
Rows payload (
fromVersionId, everything a range of versions changed; or, with baseVersionId, the difference from one version you name. Name the version by its own ID (versionId), or name the artifact (artifactId) to diff its current version. Text artifacts (markdown, html, code, text, json) return a word-level diff; csv artifacts return a line-level diff.
Auth: the same read rules as Get Artifact. A version you cannot read answers 404 NOT_FOUND, the same as an unknown ID.
Without fromVersionId, the diff is a version against the version kept before it; when the artifact keeps no earlier version (history off, the default), there is nothing to compare and payload is null. It is computed on first request and cached, so repeat calls are fast.
With fromVersionId, the diff covers the versions from fromVersionId up to the diffed version: it compares the version just before fromVersionId with it. Use it to see what a run of saves changed in one diff, for example from the first to the last version an agent saved in one step. A range diff is computed on each request and not cached. fromVersionId equal to the diffed version is the plain diff. When fromVersionId is the earliest version there is nothing to compare against, so baseVersionId, baseVersion and payload are null.
With baseVersionId, the diff compares that version itself with the diffed version: a draft file against its base, the same file in an earlier review round at the same step (each draft part on Get Task names its base.versionId). It must be a version of the same artifact, not later than the diffed version. It is computed on each request and not cached. Send fromVersionId or baseVersionId, never both.
Query Parameters
Send exactly one ofversionId and artifactId. Any other query parameter is refused with 400 INVALID_FIELD.
| Parameter | Type | Required | Description |
|---|---|---|---|
versionId | string | One of the two | The version ID to diff (the last version of a range) |
artifactId | string | One of the two | The artifact (public UUID, alias, or page URL): diffs its current version |
fromVersionId | string | No | The first version of a range: a version ID of the same artifact, not later than the diffed version. The diff’s base is the version just before it. Not with baseVersionId |
baseVersionId | string | No | Diff against this version: a version ID of the same artifact, not later than the diffed version. Not with fromVersionId |
Example Request
curl "https://api.tokenrip.com/v0/diffs?versionId=8f1c2c3e-4b5a-4d6e-9f70-1a2b3c4d5e6f"
curl "https://api.tokenrip.com/v0/diffs?artifactId=3b9d1e2f-6a7b-4c8d-9e0f-112233445566"
curl "https://api.tokenrip.com/v0/diffs?versionId=8f1c2c3e-4b5a-4d6e-9f70-1a2b3c4d5e6f&fromVersionId=5c6d7e8f-9a0b-4c1d-8e2f-3a4b5c6d7e8f"
curl "https://api.tokenrip.com/v0/diffs?versionId=8f1c2c3e-4b5a-4d6e-9f70-1a2b3c4d5e6f&baseVersionId=2a3b4c5d-6e7f-4a8b-9c0d-1e2f3a4b5c6d"
rip artifact diff --version-id 8f1c2c3e-4b5a-4d6e-9f70-1a2b3c4d5e6f --base 2a3b4c5d-6e7f-4a8b-9c0d-1e2f3a4b5c6d
artifact_version_diff { "versionId": "8f1c2c3e-4b5a-4d6e-9f70-1a2b3c4d5e6f", "baseVersionId": "2a3b4c5d-6e7f-4a8b-9c0d-1e2f3a4b5c6d" }
Example Response
{
"ok": true,
"data": {
"artifactId": "3b2a1c0d-9e8f-4a7b-8c6d-5e4f3a2b1c0d",
"versionId": "8f1c2c3e-4b5a-4d6e-9f70-1a2b3c4d5e6f",
"baseVersionId": "2a3b4c5d-6e7f-4a8b-9c0d-1e2f3a4b5c6d",
"baseVersion": 1,
"payload": {
"strategy": "text",
"segments": [
{ "op": "equal", "value": "The quick " },
{ "op": "delete", "value": "brown" },
{ "op": "insert", "value": "red" },
{ "op": "equal", "value": " fox" }
],
"stats": { "added": 1, "removed": 1 }
}
}
}
Response Fields
| Field | Type | Description |
|---|---|---|
artifactId | string | The artifact the diffed version belongs to. A version ID names its artifact, so a page showing one artifact can check it |
versionId | string | The version that was diffed |
baseVersionId | string | null | The version it was compared against: the one before the diffed version, the one before fromVersionId for a range, or the baseVersionId you named. null when there is no earlier version |
baseVersion | integer | null | The sequential number of that base version |
payload | object | null | The diff. null for the earliest kept version or a non-diffable type (chart, file, table). |
Text payload (strategy: "text")
| Field | Type | Description |
|---|---|---|
segments | array | Ordered runs of text, each with an op of equal, insert, or delete |
stats.added | integer | Number of inserted words |
stats.removed | integer | Number of removed words |
Rows payload (strategy: "rows")
| Field | Type | Description |
|---|---|---|
rows | array | Ordered CSV lines, each { op, value } with an op of equal, insert, or delete. An edited line appears as a delete plus an insert |
stats.added | integer | Number of inserted rows |
stats.removed | integer | Number of removed rows |
Error Codes
| Status | Code | Cause |
|---|---|---|
400 | INVALID_FIELD | Both or neither of versionId and artifactId; fromVersionId or baseVersionId is not a version of the same artifact, or is later than the diffed version; both fromVersionId and baseVersionId; an unknown parameter |
400 | INVALID_TYPE | artifactId names a table: tables have rows, not versions |
403 | ACCESS_DENIED | You cannot read the artifact artifactId names |
404 | NOT_FOUND | No such artifact, or no such version (or one you cannot read). The body’s resource names which: artifact or version |