Skip to main content
GET
/
v0
/
artifacts
/
{publicId}
/
versions
/
{vid}
/
diff
Diff Version
curl --request GET \
  --url https://api.example.com/v0/artifacts/{publicId}/versions/{vid}/diff
import requests

url = "https://api.example.com/v0/artifacts/{publicId}/versions/{vid}/diff"

response = requests.get(url)

print(response.text)
const options = {method: 'GET'};

fetch('https://api.example.com/v0/artifacts/{publicId}/versions/{vid}/diff', 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/artifacts/{publicId}/versions/{vid}/diff",
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/artifacts/{publicId}/versions/{vid}/diff"

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/artifacts/{publicId}/versions/{vid}/diff")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v0/artifacts/{publicId}/versions/{vid}/diff")

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_body
Retrieve the difference between a version and the version immediately before it. Text artifacts (markdown, html, code, text, json) return a word-level diff; csv artifacts return a row-level diff. This endpoint is publicly accessible — no authentication required. The diff is computed on first request and cached, so repeat calls are fast. A diff is always a version against its immediate predecessor — there is no arbitrary version-pair comparison.

Path Parameters

ParameterTypeRequiredDescription
publicIdstringYesThe public ID of the artifact
vidstringYesThe version ID to diff against its predecessor

Example Request

curl https://api.tokenrip.com/v0/artifacts/ast_abc123/versions/vid_9kLmN3pQ/diff

Example Response

{
  "ok": true,
  "data": {
    "versionId": "vid_9kLmN3pQ",
    "baseVersionId": "vid_7hGfD2sR",
    "baseVersion": 2,
    "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

FieldTypeDescription
versionIdstringThe version that was diffed
baseVersionIdstring | nullThe previous version it was compared against. null for the earliest version.
baseVersioninteger | nullThe sequential number of the previous version
payloadobject | nullThe diff. null for the earliest version or a non-diffable type (chart, file, table).

Text payload (strategy: "text")

FieldTypeDescription
segmentsarrayOrdered runs of text, each with an op of equal, insert, or delete
stats.addedintegerNumber of inserted words
stats.removedintegerNumber of removed words

Rows payload (strategy: "rows")

FieldTypeDescription
rowsarrayOrdered CSV rows, each with an op of equal, insert, or delete
stats.addedintegerNumber of inserted rows
stats.removedintegerNumber of removed rows

Error Codes

ErrorDescription
NOT_FOUNDNo artifact exists with the given publicId, or no version exists with the given vid on this artifact