TerminusDB Logo all white svg
Search
Close this search box.

Open API for JSON Diff and Patch

This video shows how to perform diff and patch operations using curl.

We have two public endpoints:

Diff: https://cloud.terminusdb.com/jsondiff

Patch: https://cloud.terminusdb.com/jsonpatch

We use JSON-patch/diff internally for our rebase operation and thought we would make it available for others to use so created the open API example for diff and patch.

The diff endpoint takes a POST of two JSON documents, before, and after. This endpoint then returns a 200 and a patch which takes before to after if applied using the patch interface. The payload is structured as a JSON document, with two keys, “before” and “after”, pointing to the documents you would like to diff.

An example of the payload:

				
					{ "before" : { "@id" : "Person/Jane", "@type" : "Person", "name" : "Jane"},
  "after" :  { "@id" : "Person/Jane", "@type" : "Person", "name" : "Janine"}}
				
			

Which would result in the following patch:

				
					{ "name" : { "@op" : "SwapValue", "@before" : "Jane", "@after": "Janine" }}
				
			

There are a number of available JSON Diff & Patch operations available using the open API, for full details with curl examples, visit our JSON Diff & Patch documentation.

JSON Diff & Patch with TerminusDB,

You can use TerminusDB and the Python and JavaScript clients to run diff and patch operations on your TerminusDB database, or other document databases, such as MongoDB.

For full details visit our documentation pages, and check out the tutorial walking you through the process step by step.

Other TerminusDB Videos

Talk to the team

If you've got questions or want to be part of the TerminusDB community, come say hi on Discord.
Community