{"componentChunkName":"component---src-templates-default-template-tsx","path":"/documentation/api/ws-api/","result":{"data":{"asciidoc":{"id":"99f77fa4-06fe-5ffe-b897-e05610a7ac91","html":"<div id=\"toc\" class=\"toc\">\n<div id=\"toctitle\">Table of Contents</div>\n<ul class=\"sectlevel1\">\n<li><a href=\"#_overview\">Overview</a>\n<ul class=\"sectlevel2\">\n<li><a href=\"#_concepts\">Concepts</a>\n<ul class=\"sectlevel3\">\n<li><a href=\"#_requirements_of_namespace_ids_and_attributes\">Requirements of Namespace, IDs and Attributes</a></li>\n<li><a href=\"#_ws_api\">WS API</a></li>\n</ul>\n</li>\n<li><a href=\"#_ws_event_streaming_api_events_1_0_0\">WS Event Streaming API (events-1.0.0)</a>\n<ul class=\"sectlevel3\">\n<li><a href=\"#_requests\">Requests</a></li>\n<li><a href=\"#_responses\">Responses</a></li>\n<li><a href=\"#_filters\">Filters</a></li>\n</ul>\n</li>\n<li><a href=\"#_ws_graph_api_graph_2_0_0\">WS Graph API (graph-2.0.0)</a>\n<ul class=\"sectlevel3\">\n<li><a href=\"#_overview_2\">Overview</a></li>\n<li><a href=\"#_individual_requests\">Individual Requests</a></li>\n</ul>\n</li>\n<li><a href=\"#_error_codes\">Error Codes</a></li>\n</ul>\n</li>\n</ul>\n</div>\n<div class=\"sect1\">\n<h2 id=\"_overview\">Overview</h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>This document will give you an overview about the HIRO Graph Developer WS API.</p>\n</div>\n<div class=\"sect2\">\n<h3 id=\"_concepts\">Concepts</h3>\n<div class=\"paragraph\">\n<p>Please be familiar with the <a href=\"/7.0/\">HIRO Graph</a> and the <a href=\"https://tools.ietf.org/html/rfc6455\">Websocket Protocol</a>.</p>\n</div>\n<div class=\"sect3\">\n<h4 id=\"_requirements_of_namespace_ids_and_attributes\">Requirements of Namespace, IDs and Attributes</h4>\n<div class=\"olist arabic\">\n<ol class=\"arabic\">\n<li>\n<p>All Requirements of <a href=\"/7.0/\">HIRO Graph</a> apply.</p>\n</li>\n</ol>\n</div>\n</div>\n<div class=\"sect3\">\n<h4 id=\"_ws_api\">WS API</h4>\n<div class=\"admonitionblock tip\">\n<table>\n<tr>\n<td class=\"icon\">\n<i class=\"fa icon-tip\" title=\"Tip\"></i>\n</td>\n<td class=\"content\">\nIn order to use the API you need to register an application, please drop us a line at <a href=\"mailto:support@hiro.almato.ai\">support@hiro.almato.ai</a>.\n</td>\n</tr>\n</table>\n</div>\n<div class=\"olist arabic\">\n<ol class=\"arabic\">\n<li>\n<p>All initial connect requests must contain a valid access token _TOKEN. Request a valid access token from the HIRO IAM server.</p>\n</li>\n<li>\n<p>All requests will be made against a base $url (e.g. <code>core.almato.ai</code>).</p>\n</li>\n<li>\n<p>All further examples assume <code>wss://</code> as the protocol.</p>\n</li>\n</ol>\n</div>\n</div>\n</div>\n<div class=\"sect2\">\n<h3 id=\"_ws_event_streaming_api_events_1_0_0\">WS Event Streaming API (events-1.0.0)</h3>\n<div class=\"paragraph\">\n<p>The Streaming endpoint is located at <code>/api/events-ws/</code>.</p>\n</div>\n<div class=\"paragraph\">\n<p>The standard steps to follow are:</p>\n</div>\n<div class=\"olist arabic\">\n<ol class=\"arabic\">\n<li>\n<p>Connect</p>\n</li>\n<li>\n<p>Subscribe to scope (if allscopes set to false)</p>\n</li>\n<li>\n<p>Register a filter</p>\n</li>\n<li>\n<p>Receive data</p>\n</li>\n</ol>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Example</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">const ws = new WebSocket(`wss://${url}/api/events-ws/6/?groupId=&amp;offset=`, ['events-1.0.0', 'token-' + token]);</code></pre>\n</div>\n</div>\n<table class=\"tableblock frame-all grid-all stretch\">\n<caption class=\"title\">Table 1. Table Parameters</caption>\n<colgroup>\n<col style=\"width: 33.3333%;\">\n<col style=\"width: 33.3333%;\">\n<col style=\"width: 33.3334%;\">\n</colgroup>\n<thead>\n<tr>\n<th class=\"tableblock halign-left valign-top\">Name</th>\n<th class=\"tableblock halign-left valign-top\">Description</th>\n<th class=\"tableblock halign-left valign-top\">Default</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\">groupId</p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\">subscribe to the same event stream by opening multiple connections with the same groupId. The stream will be partitioned amongst all connections. If connection is lost, the groupId will allow you to receive any missed events.</p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\">''</p></td>\n</tr>\n<tr>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\">offset</p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\"><code>smallest</code> (start from the last event received by this group) or <code>largest</code> (start by events that come in after the connection).</p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\">''</p></td>\n</tr>\n<tr>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\">delta</p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\">Only receive the changes to a vertex, not the whole vertex. Each a attribute in the event body is prefixed with <code>+</code>, <code>-</code>, <code>=</code> (added, removed, changed).</p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\">false</p></td>\n</tr>\n<tr>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\">allscopes</p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\">By default, events from all scopes are subscribed to. Setting this to false, requires use of the <code>subscribe</code> message to subscribe to specific scopes. See message types below.</p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\">true</p></td>\n</tr>\n</tbody>\n</table>\n<div class=\"sect3\">\n<h4 id=\"_requests\">Requests</h4>\n<div class=\"listingblock\">\n<div class=\"title\">Example: Updating a token on an already established connection</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">const msg = {\n  'type': 'token',\n  'args': {\n   _TOKEN: 'new token'\n  }\n};\nws.send(JSON.stringify(msg));</code></pre>\n</div>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Example: Subscribe to events from a given scope</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">const msg = {\n  'type': 'subscribe',\n  'id': scope_id // The ogit/_id of the ogit/DataScope (i.e. the scope of your instance) you want to subscribe to\n};\nws.send(JSON.stringify(msg));</code></pre>\n</div>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Example: Register a Filter</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">const msg = {\n  'type': 'register',\n  'args': {\n   'filter-id': 'unique filter id for this websocket',\n   'filter-type': 'jfilter',\n   'filter-content': '(element.ogit/_type = ogit/Question)'\n  }\n};\nws.send(JSON.stringify(msg));</code></pre>\n</div>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Example: Unregister a Filter</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">const msg = {\n  'type': 'unregister',\n  'args': {\n   'filter-id': 'unique filter id for this websocket'\n  }\n};\nws.send(JSON.stringify(msg));</code></pre>\n</div>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Example: Unregister all Filters</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">const msg = {\n  'type': 'clear',\n  'args': {}\n};\nws.send(JSON.stringify(msg));</code></pre>\n</div>\n</div>\n</div>\n<div class=\"sect3\">\n<h4 id=\"_responses\">Responses</h4>\n<div class=\"paragraph\">\n<p>Events contain the originator of the event, the action taken, and the contents.</p>\n</div>\n<div class=\"sect4\">\n<h5 id=\"_standard_events\">Standard events</h5>\n<div class=\"paragraph\">\n<p>By default, the eventstream sends the entire body of the affected vertex.</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Example: An Event</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-ts\" data-lang=\"ts\">{\n  id: string; // ogit/_id from body\n  body: {\n   /* properties like ogit/_id */\n   \"ogit/name\": \"My name\"\n  },\n  metadata: {\n    \"ogit/_modified-by\": string;\n    \"ogit/_modified-by-app\": string;\n    \"ogit/_modified-on\": number;\n  };\n  nanotime: number;\n  timestamp: number;\n  type:  \"CREATE\" | \"REPLACE\" | \"UPDATE\" | \"CONNECT\" | \"DISCONNECT\" | \"DELETE\" | \"WRITE_TIMESERIES\";\n}</code></pre>\n</div>\n</div>\n</div>\n<div class=\"sect4\">\n<h5 id=\"_delta_events\">Delta events</h5>\n<div class=\"paragraph\">\n<p>Delta events only contain the changes on the node. Each attribute is prefixed by <code>+</code>, <code>-</code>, <code>=</code>.</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Example: An Delta Event</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-ts\" data-lang=\"ts\">{\n  id: string; // ogit/_id from body\n  body: {\n   /* properties like ogit/_id prefixed by change */\n   \"+ogit/firstName\": \"My name\" // Added\n   \"-ogit/lastName\": \"My name\" // Removed\n   \"=ogit/email\": \"My name\" // Changed\n  },\n  metadata: {\n    \"ogit/_modified-by\": string;\n    \"ogit/_modified-by-app\": string;\n    \"ogit/_modified-on\": number;\n  };\n  nanotime: number;\n  timestamp: number;\n  type:  \"CREATE\" | \"REPLACE\" | \"UPDATE\" | \"CONNECT\" | \"DISCONNECT\" | \"DELETE\" | \"WRITE_TIMESERIES\";\n}</code></pre>\n</div>\n</div>\n</div>\n</div>\n<div class=\"sect3\">\n<h4 id=\"_filters\">Filters</h4>\n<div class=\"paragraph\">\n<p>In order to only receive certain events, filters can be registered. The <code>filterType</code> is currently only <code>jfilter</code>.</p>\n</div>\n<div class=\"sect4\">\n<h5 id=\"_syntax\">Syntax</h5>\n<table class=\"tableblock frame-all grid-all stretch\">\n<caption class=\"title\">Table 2. Table Filter Operators</caption>\n<colgroup>\n<col style=\"width: 25%;\">\n<col style=\"width: 25%;\">\n<col style=\"width: 25%;\">\n<col style=\"width: 25%;\">\n</colgroup>\n<thead>\n<tr>\n<th class=\"tableblock halign-center valign-top\">Operator</th>\n<th class=\"tableblock halign-center valign-top\">Description</th>\n<th class=\"tableblock halign-left valign-top\">Supported types</th>\n<th class=\"tableblock halign-left valign-top\">Filter example</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><code>=</code></p></td>\n<td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><em>equals to</em></p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\">String,\nNumber</p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\"><code>(firstname = John)</code></p></td>\n</tr>\n<tr>\n<td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><code>~</code></p></td>\n<td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><em>differs from</em></p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\">String,\nNumber</p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\"><code>(name ~ Smith)</code></p></td>\n</tr>\n<tr>\n<td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><code>&gt;</code></p></td>\n<td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><em>more than</em></p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\">Number</p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\"><code>(height &gt; 1.6)</code></p></td>\n</tr>\n<tr>\n<td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><code>&gt;=</code></p></td>\n<td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><em>more or equals</em></p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\">Number</p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\"><code>(height &gt;= 1.6)</code></p></td>\n</tr>\n<tr>\n<td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><code>&lt;</code></p></td>\n<td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><em>less than</em></p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\">Number</p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\"><code>(age &lt; 20)</code></p></td>\n</tr>\n<tr>\n<td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><code>&#8656;</code></p></td>\n<td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><em>less or equals</em></p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\">Number</p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\"><code>(age &#8656; 20)</code></p></td>\n</tr>\n<tr>\n<td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><code>!</code></p></td>\n<td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><em>not</em></p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\">Filter</p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\"><code>!(age&lt;10)</code></p></td>\n</tr>\n<tr>\n<td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><code>&amp;</code></p></td>\n<td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><em>and</em></p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\">Filters</p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\"><code>&amp;(name=Doe)(firstname=John)</code></p></td>\n</tr>\n<tr>\n<td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><code>|</code></p></td>\n<td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><em>or</em></p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\">Filters</p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\"><code>|(age&lt;10)(male=true)</code></p></td>\n</tr>\n<tr>\n<td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><em>wildcards</em></p></td>\n<td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><em>matches all</em></p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\">String</p></td>\n<td class=\"tableblock halign-left valign-top\"><p class=\"tableblock\"><code>&amp;(firstname=J*)(name=Do?)</code></p></td>\n</tr>\n</tbody>\n</table>\n<div class=\"listingblock\">\n<div class=\"title\">Example: A Filter</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-js\" data-lang=\"js\">{\n  'filter-content': '&amp;(element.ogit/_type=ogit/Question)(action=C*)'\n}</code></pre>\n</div>\n</div>\n</div>\n</div>\n</div>\n<div class=\"sect2\">\n<h3 id=\"_ws_graph_api_graph_2_0_0\">WS Graph API (graph-2.0.0)</h3>\n<div class=\"paragraph\">\n<p>The WS Graph API permits to do REST primitives over WS.\nThe WS Graph API endpoint is located at <code>/api/graph-ws/</code>.</p>\n</div>\n<div class=\"admonitionblock note\">\n<table>\n<tr>\n<td class=\"icon\">\n<i class=\"fa icon-note\" title=\"Note\"></i>\n</td>\n<td class=\"content\">\nBlobs can be fetched via this api, but they can only be stored via REST.\n</td>\n</tr>\n</table>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Example</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">const ws = new WebSocket(`wss://${url}/api/graph-ws/6/`, ['graph-2.0.0', 'token-' + token]);\nws.addEventListener(\"open\", function() {\n  if (ws.protocol !== \"graph-2.0.0\") {\n    throw new Error(\"Expecting WebSocket protocol 'graph-2.0.0', got \" + ws.protocol);\n  }\n  //do something with connection\n});</code></pre>\n</div>\n</div>\n<div class=\"sect3\">\n<h4 id=\"_overview_2\">Overview</h4>\n<div class=\"paragraph\">\n<p>Websocket API requests are JSON, and have the following structure:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Example</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">const request =\n{\n  'id': 'mandatory id for matching the reply',\n  'type': 'the type of the request, e.g. get, create, replace, connect, ...',\n  '_TOKEN': 'optional, if none specified, the one from the establishing the websocket will be used',\n  'headers':\n  {\n    // headers for the request\n  },\n  'body':\n  {\n    // body for the request\n  }\n};</code></pre>\n</div>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">ws.send(JSON.stringify(request));</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>In order to do correct multiplexing in the websocket stream, all responses will be wrapped by an envelope.\nA client must buffer all messages until the flag <code>more</code> is <code>false</code> in an envelope.</p>\n</div>\n<div class=\"paragraph\">\n<p>Response Envelope:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">{\n  \"id\": \"id of the request\",\n  \"more\": true|false // `false` if this is the last message for the response\n  \"multi\": true|false // `true` if this response is fragmented, the stream of messages represents an array as the final result\n  \"body\": []|{}|... // for responses with `multi=true` the body should be put to an array [] and when `more=false` the result should be the array with the assembled parts\n}</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>In order to process these envelope which arrive intermixed with other response envelopes, one\nmust buffer the envelopes unti the last flag is true.</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">const requests = {}; // holds all responses\n\nws.onmessage = function(msg)\n{\n  const payload = JSON.parse(what);\n\n  const request = requests[payload.id];\n  if (!request) throw new Error(\"request could not be found \" + req.id);\n\n  if (payload.error)\n  {\n    // an error must always be delivered\n    request.cb(payload);\n    delete(requests[payload.id]);\n  } else if (!payload.multi &amp;&amp; payload.more) {\n    throw new Error(\"non-multi messages cannot be fragmented\");\n  } else if (!payload.multi) {\n    // thats a single response message\n    request.cb(payload);\n    delete(requests[payload.id]);\n  } else {\n    // thats a fragmented response, buffer up everything until payload.more = false\n    if (payload.body !== null) request.buf.push(payload.body);request.buf.push(payload.body);\n\n    if (!payload.more)\n    {\n      request.cb(request.buf);\n      delete(requests[payload.id]);\n    }\n  };\n);</code></pre>\n</div>\n</div>\n</div>\n<div class=\"sect3\">\n<h4 id=\"_individual_requests\">Individual Requests</h4>\n<div class=\"listingblock\">\n<div class=\"title\">Get an Entity</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">{\n  \"id\":   \"request id\",\n  \"type\": \"get\",\n  /* other optional properties */\n  \"headers\":\n  {\n    \"ogit/_id\": \"id of the node\"\n  },\n  \"body\":\n  {\n    // all parameters for the corresponding REST request are available here\n  }\n}</code></pre>\n</div>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Create an Entity</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">{\n  \"id\":   \"request id\",\n  \"type\": \"create\",\n  /* other optional properties */\n  \"headers\":\n  {\n    \"ogit/_type\": \"type of the node\"\n  },\n  \"body\":\n  {\n    // all parameters for the corresponding REST request are available here\n  }\n}</code></pre>\n</div>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Update an Entity</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">{\n  \"id\":   \"request id\",\n  \"type\": \"update\",\n  /* other optional properties */\n  \"headers\":\n  {\n    \"ogit/_id\": \"id of the node\"\n  },\n  \"body\":\n  {\n    // all parameters for the corresponding REST request are available here\n  }\n}</code></pre>\n</div>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Replace an Entity</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">{\n  \"id\":   \"request id\",\n  \"type\": \"replace\",\n  /* other optional properties */\n  \"headers\":\n  {\n    \"ogit/_id\": \"id of the node\",\n  },\n  \"body\":\n  {\n    // all parameters for the corresponding REST request are available here\n  }\n}</code></pre>\n</div>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Replace an Entity/Verb</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">{\n  \"id\":   \"request id\",\n  \"type\": \"delete\",\n  /* other optional properties */\n  \"headers\":\n  {\n    \"ogit/_id\": \"id of the node/edge\"\n  },\n  \"body\":\n  {\n    // all parameters for the corresponding REST request are available here\n  }\n}</code></pre>\n</div>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Connect two Entities</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">{\n  \"id\":   \"request id\",\n  \"type\": \"connect\",\n  /* other optional properties */\n  \"headers\":\n  {\n    \"ogit/_type\": \"type of the verb\"\n  },\n  \"body\":\n  {\n    \"out\": \"id of the outgoing node\",\n    \"in\": \"id of the ingoing node\"\n  }\n}</code></pre>\n</div>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Query</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">{\n  \"id\":   \"request id\",\n  \"type\": \"query\",\n  /* other optional properties */\n  \"headers\":\n  {\n    \"type\": \"type of the query, e.g. vertices\"\n  },\n  \"body\":\n  {\n    // all parameters for the corresponding REST request are available here\n  }\n}</code></pre>\n</div>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Write Timeseries Values</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">{\n  \"id\":   \"request id\",\n  \"type\": \"writets\",\n  /* other optional properties */\n  \"headers\":\n  {\n    \"ogit/_id\": \"id of the node\"\n  },\n  \"body\":\n  {\n    // all parameters for the corresponding REST request are available here\n  }\n}</code></pre>\n</div>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Fetch Timeseries Values</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">{\n  \"id\":   \"request id\",\n  \"type\": \"streamts\",\n  /* other optional properties */\n  \"headers\":\n  {\n    \"ogit/_id\": \"id of the node\"\n  },\n  \"body\":\n  {\n    // all parameters for the corresponding REST request are available here\n  }\n}</code></pre>\n</div>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Fetch History of an Entity</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">{\n  \"id\":   \"request id\",\n  \"type\": \"history\",\n  /* other optional properties */\n  \"headers\":\n  {\n    \"ogit/_id\": \"id of the node\"\n  },\n  \"body\":\n  {\n    // all parameters for the corresponding REST request are available here\n  }\n}</code></pre>\n</div>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Me</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">{\n  \"id\":   \"request id\",\n  \"type\": \"me\",\n  '_TOKEN': 'optional, if none specified, the one from the establishing the websocket will be used',\n  \"headers\":\n  {\n  },\n  \"body\":\n  {\n    // all parameters for the corresponding REST request are available here\n  }\n}</code></pre>\n</div>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Fetch blob content</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">{\n  \"id\":   \"request id\",\n  \"type\": \"getcontent\",\n  '_TOKEN': 'optional, if none specified, the one from the establishing the websocket will be used',\n  \"headers\":\n  {\n    \"ogit/_id\": \"id of the node\"\n  },\n  \"body\":\n  {\n    // all parameters for the corresponding REST request are available here\n  }\n}</code></pre>\n</div>\n</div>\n<div class=\"admonitionblock note\">\n<table>\n<tr>\n<td class=\"icon\">\n<i class=\"fa icon-note\" title=\"Note\"></i>\n</td>\n<td class=\"content\">\nIn order to store blob content, the REST API must be used.\n</td>\n</tr>\n</table>\n</div>\n<div class=\"paragraph\">\n<p>The responses for receiving blob content are chunked envelopes looking like this, and the client needs to assemble these:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">{\n  \"id\":   \"request id\",\n  \"multi\": true,\n  \"last\": true|false\n  \"body\":\n  {\n    \"data\": \"chunk of blob data\",\n    \"encoding\": \"base64\" // base64 is currently the only encoding possible\n  }\n}</code></pre>\n</div>\n</div>\n</div>\n</div>\n<div class=\"sect2\">\n<h3 id=\"_error_codes\">Error Codes</h3>\n<div class=\"olist arabic\">\n<ol class=\"arabic\">\n<li>\n<p>All error codes of <strong>HIRO Graph API</strong> apply.</p>\n</li>\n<li>\n<p>All error codes of <a href=\"https://tools.ietf.org/html/rfc6455\">Websocket Protocol</a> apply.</p>\n</li>\n</ol>\n</div>\n<div class=\"admonitionblock note\">\n<table>\n<tr>\n<td class=\"icon\">\n<i class=\"fa icon-note\" title=\"Note\"></i>\n</td>\n<td class=\"content\">\nOn Websocket close message HIRO Graph error codes are not propagated and only Websocket Protocol codes are returned. If exists <code>error</code> from close message content should be used to recognize and implement handling. Example error response message:\n</td>\n</tr>\n</table>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-javascript\" data-lang=\"javascript\">{\n  \"error\": {\"message\": \"authentication required\"}\n}</code></pre>\n</div>\n</div>\n</div>\n</div>\n</div>","document":{"main":"HIRO Graph WebSocket API","title":"HIRO Graph WebSocket API","subtitle":""},"fields":{"toc":true,"location":["documentation","api","ws-api"]}},"sidebarYaml":{"id":"6d066bdd-c982-5a69-b909-a31e6fc044e0","showIndex":null}},"pageContext":{"id":"99f77fa4-06fe-5ffe-b897-e05610a7ac91","parent":"documentation"}},"staticQueryHashes":["1010459453","1010459453","2356112386","2356112386","2603905930","2603905930","3026652197","3026652197","3167850324","3167850324","63159454","63159454"]}