Commit 1df672a9 authored by Josh Kunz's avatar Josh Kunz

Adds some examples to the readme.

parent e1b0363e
...@@ -56,15 +56,25 @@ knowledge graph in the form explained above. Python example ...@@ -56,15 +56,25 @@ knowledge graph in the form explained above. Python example
import requests import requests
response = requests.get("/graph") response = requests.get("/graph")
On success, the status code __200__ will be returned and the json-representation
of the knowledge graph will be in the response body. *Example response graph*:
{"a": [{"label": "b", "to": "q"}, {"label": "b", "to": "z"}],
"b": [{"label": "c", "to": "x"}, {"label": "c", "to": "z"}],
"z": [{"label": "b", "to": "a"}]}
If you perform a __POST__ request against this endpoint and the body If you perform a __POST__ request against this endpoint and the body
of the __POST__ request is a graph then the knowledge graph managed by of the __POST__ request is a graph then the knowledge graph managed by
the server is updated to contain the union of the submitted graph and the the server is updated to contain the union of the submitted graph and the
graph on the server. graph on the server.
import requests, json import requests, json
graph = ... graph = ...
response = requests.post("/graph", data = json.dumps(graph)) response = requests.post("/graph", data = json.dumps(graph))
An empty response and __200__ response code means that the update was
successful.
### /query ### /query
If you perform __POST__ request against this endpoint and the body If you perform __POST__ request against this endpoint and the body
...@@ -83,3 +93,13 @@ to the value "value". ...@@ -83,3 +93,13 @@ to the value "value".
import requests, json import requests, json
query_graph = ... query_graph = ...
response = requests.post("/query", data = json.dumps(query_graph)) response = requests.post("/query", data = json.dumps(query_graph))
On success, the response code will be __200__ and the query result in JSON format
will be in the response body. *Example response*:
[{"context": {"A": "z", "B": "b", "C": "a"},
"graph": {"a": [{"label": "b", "to": "z"}],
"z": [{"label": "b", "to": "a"}]}},
{"context": {"A": "a", "B": "b", "C": "z"},
"graph": {"a": [{"label": "b", "to": "z"}],
"z": [{"label": "b", "to": "a"}]}}]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment