Skip to content

REST API

Roger Zander edited this page Feb 18, 2018 · 24 revisions

Upload Data [POST]

Upload a new or existing object where {Id} is the identifier of the object.
http://{URL}/upload/{Id}

Return value is the hash of the uploaded Object.

PowerShell example ($id is the Identifier and $con is the JSON string):

Invoke-RestMethod -Uri "http://localhost:5000/upload/$($id)" -Method Post -Body $con -ContentType "application/json; charset=utf-8"

Upload XML Data [POST]

Upload a new or existing object where {Id} is the identifier of the object.

Note: XML will be converted into JSON.

http://{URL}/uploadxml/{Id}

Return value is the hash of the uploaded Object.

Get full Data [GET]

Resolves the Blockchain with all hashed values and returns the full object in JSON Format.
http://{URL}/full?id={Id}[&index={revision}]

http://{URL}/full?{lookupId}={LookupValue}[&index={revision}]

Example:

http://server/full?name=NUC1&index=1

Get differential between revisions [GET]

http://{URL}/diff?id={Id}[&index={revision}]|[&lindex={left revision}&rindex={right revision}]
http://{URL}/diff?{lookupId}={LookupValue}[&index={revision}][&mode=0¦1]

Diff Modes: Mode 0 returns the full object; Mode 1 returns in jsondiffpatch format

Example:
http://server/diff?name=NUC1&index=1

Get visual differential between revisions [GET]

http://{URL}/diffvis?id={Id}[&index={revision}]|[&lindex={left revision}&rindex={right revision}]
http://{URL}/diffvis?{lookupId}={LookupValue}[&index={revision}]|[&lindex={left revision}&rindex={right revision}]

Example:
http://server/diffvis?name=NUC1

Query Data [GET]

Get all Objects from the latest block in the chain. Use a JSONPath to filter the result. http://{URL}/query?[JSONPath,..][&$select={KeyName,..}][&$exclude={KeyName,..}]

Example:
http://{URL}/query?OS&$select=%23Name,_date&$exclude=$..MUILanguages

Query Data including History [GET]

Get all Objects from all blocks in the chain. Use a JSONPath to filter the result. http://{URL}/queryall?[JSONPath,..][&$select={KeyName,..}][&$exclude={KeyName,..}]

Example:
http://{URL}/queryall?OS.Caption,OS.Version&$select=%23Name,_date

Note: Query all blocks may take a long time to process.

Search [GET]

http://{URL}/search?{free text}&$select=%23Name

Show History [GET]

Get all index,timestamp and hashid for a specific device.
http://{URL}/history?id={Id}[&index={revision}]

http://{URL}/history?{lookupId}={LookupValue}

get all Changes [GET]

Get all Objects that have changed within a specifc timespan (default 24h).
Changetyp: 0 = new; 1 = update; -1 = all
The Timespan Format is separated by '-'. e.g "1-05-00-00" = 1day 5Hours
http://localhost:5000/changes?[age={timespan}][&changetype=-1|0|1]

Example: Get only new Objects created within the last 5h http://localhost:5000/changes?age=5-00-00&changetype=0

Export [GET]

Eports all blocks of all blockchains and upload to another JainDB. This is required if something does chain on the blockchain logic or if you want to change the hash algorythm etc.
http://{URL}/export?url={URL encoded target URL}[&remove={Jpath;Jpath}]

To remove objects during export, the "remove" option can be used to specify a JPath of an Object or Attribute.

XML2JSON [POST]

Convert an XML Object into JSON and return the JSON without uploading to the blockchain. http://{URL}/xml2json

Validate [Get]

This function is for testing/validation only. It compares the data stored in the blockchain with the cached full data and returns "true" if the hash is the same or "false" if they are different. http://{URL}/validate?id={Id}

Clone this wiki locally