Skip to content

Latest commit

 

History

History
400 lines (344 loc) · 8.47 KB

API.md

File metadata and controls

400 lines (344 loc) · 8.47 KB

API

GRAPHS

GET /v1/graphs

Get a list of current graphs.

Response

200
{
	"data": ["user"]
}

Response error

400 Bad Request

curl

$ curl http://localhost:9666/v1/graphs
{"data": ["user"]}

ADD

POST /v1/data

Add a list of triples. The total number inserted is returned. Invalid triples(no sub, pred, or obj) are removed from the insert.

JSON Parameters

  • graph (required) graph name.
  • prefix (optional) uri prefix, will replace all items in data. For example foaf:name = http://xmlns.com/foaf/0.1/name
  • data (required) triples, uses prefix if defined.

Request

{
	"graph": "user",
	"prefix": {
		"eu": "https://eurisko.io/rdf/0.1/",
		"foaf": "http://xmlns.com/foaf/0.1/",
		"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
	},
	"data": [
		["_:1", "rdf:type", "foaf:Person"],
		["_:1", "foaf:name", "Albert"],
		["_:1", "eu:username", "alberto1"],
		["_:2", "foaf:name", "Barry"],
		["_:2", "eu:username", "bthug"],
		["_:3", "foaf:name", "Charles"],
		["_:3", "eu:username", "cthug"],
		["_:1", "", "_:2"],
		["_:1", "foaf:knows", "_:3"]
	]
}

Response

200 {"total": 8}

Response error

400 Bad Request
405 Method Not Allowed

curl

# Note if no prefix is defined you have to specifiy the full uri of subjects and predicates.
$ curl -d '{"graph":"user", "data": [["_:1", "http://xmlns.com/foaf/0.1/name", "Albert"]]'  http://localhost:9666/v1/data
{"total": 1}

DELETE

DELETE /v1/data

Remove a list of triples.

JSON Parameters

  • graph (required) graph name.
  • prefix (optional) uri prefix, will replace all items in data. For example foaf:name = http://xmlns.com/foaf/0.1/name
  • data (required) triples uses prefix if defined. Empty strings mean delete all for sub, pred, obj.

Request

{
	"graph": "user",
	"prefix": {
		"foaf": "http://xmlns.com/foaf/0.1/"
	},
	"data": [
		["_:1", "foaf:name", "Albert"],
		["_:3", "foaf:name", ""]
	]
}

Response

200 OK

Response error

400 Bad Request
405 Method Not Allowed

curl

# Note if no prefix is defined you have to specifiy the full uri of subjects and predicates.
$ curl -X DELETE -d '{"graph":"user", "data": [["_:1", "http://xmlns.com/foaf/0.1/name", "Albert"]]'  http://localhost:9666/v1/data
OK

TRIPLES

POST /v1/triples

Get a list of triples. The reason this is json encoded is to preserve the type for the obj parameter(bool,int,string,etc)

JSON Parameters

  • graph (required) graph
  • prefix (optional) uri prefix, will replace all items in data. For example foaf:name = http://xmlns.com/foaf/0.1/name
  • sub (optional) subject
  • pred (optional) predicate
  • obj (optional) object, can be nil
  • limit (optional:default 20) number of triples to return
  • offset (optional:default 0) skip to
  • orderby (optional string) sort by sub(s), pred(p), obj(o). A minus in front of the character means descending.
{
	"graph": "user",
	"prefix": {"foaf": "http://foaf"},
	"sub": "_:1",
	"pred": "http://xmlns.com/foaf/0.1/knows",
	"obj": "_:2",
	"limit": 1,
	"offset": 0,
	"orderby": "-s"
}

Response

200
{
	"graph": "user",
	"data": [
		["_:1", "http://xmlns.com/foaf/0.1/knows", "_:2"],
	]
}

Response error

400 Bad Request
405 Method Not Allowed
500 Internal Server Error

curl

$ curl  -d '{"graph": "user", "sub": "_:1", "pred": "", obj: "_:2"}' http://localhost:9666/v1/triples
{"graph": "user", "data":[["_:1", "http://xmlns.com/foaf/0.1/knows", "_:2"]]}

TRIPLES COUNT

POST /v1/triples/count

Get the number of triples for a query.

JSON Parameters

  • graph (required) graph
  • prefix (optional) uri prefix, will replace all items in data. For example foaf:name = http://xmlns.com/foaf/0.1/name
  • sub (optional) subject
  • pred (optional) predicate
  • obj (optional) object, can be nil
{
	"graph": "user",
	"prefix": {"foaf": "http://foaf"},
	"sub": "",
	"pred": "",
	"obj": ""
}

Response

200
{
	"graph": "user",
	"data": 101
}

Response error

400 Bad Request
405 Method Not Allowed
500 Internal Server Error

curl

$ curl  -d '{"graph": "user", "sub": "", "pred": "", obj: ""}' http://localhost:9666/v1/triples/count
{"graph": "user", "data": 101}

VALUE

POST /v1/value

Get a single value from a triple.

JSON Parameters

  • graph (required) graph
  • prefix (optional) uri prefix, will replace all items in data. For example foaf:name = http://xmlns.com/foaf/0.1/name
  • sub (optional) subject
  • pred (optional) predicate
  • obj (optional) object, can be nil
{
	"graph": "user",
	"prefix": {"foaf": "http://foaf"},
	"sub": "_:1",
	"pred": "http://xmlns.com/foaf/0.1/knows",
	"obj": nil,
}

Response

200
{
	"graph": "user",
	"data": "_:2"
}

Response error

400 Bad Request
405 Method Not Allowed
500 Internal Server Error

curl

$ curl  -d '{"graph": "user", "sub": "_:1", "pred": "", obj: ""}' http://localhost:9666/v1/value
{"graph": "user", "data": "_:2"}

QUERY

POST /v1/query

Get a list of bound variables.

JSON Parameters

  • graph (required) graph
  • data (required) query bindings in triples, uses prefix if defined.
  • prefix (optional) uri prefix, will replace all items in data query.
  • select (required) array of which variables to return, if empty all variables returned. If count ?COUNT data contains a count.
  • optional array of the indexes within data of the triples to treat as optional, meaning return results even if the optional triple has none.
  • distinct (optional:default true) return distinct results
  • limit (optional:default 20) number of items to return.
  • offset (optional:default 0) skip.
  • orderby (optional) sort by variable, a minus in front of string means descending sort.
  • filter (optional) array of filters [{key: 'clicks', op: '<', val: 3}, {key: 'age', op: '>', val: 20}]
{
	"graph": "user",
	"prefix": {
		"eu": "https://eurisko.io/rdf/0.1/",
		"foaf": "http://xmlns.com/foaf/0.1/"
	},
	"select": ["?userid", "?knows_name", "?knows_username"],
	"data": [
		["?userid", "foaf:knows", "?knowsid"],
		["?knowsid", "foaf:name", "?knows_name"]
		["?knowsid", "eu:username", "?knows_username"]
	],
	"optional": [1, 2],
	"distinct": true,
	"limit": 2,
	"offset": 10,
	"orderby": "-userid"
}

Response

200
{
	"graph": "user",
	"data": [
		{"userid": "_:1", "knows_name": "Barry", "knows_username": "bthug"}, 
		{"userid": "_:1", "knows_name": "Charles", "knows_username": "cthug"}
	]
}

Response error

400 Bad Request
405 Method Not Allowed
500 Internal Server Error

curl

$ curl -d '{"graph": "user", "prefix": {"eu": "https://eurisko.io/rdf/0.1/"}, "data": [["?userid", "eu:name", "Albert"]]'  http://localhost:9666/v1/query
{"graph": "user", "data":[["userid", "https://eurisko.io/rdf/0.1/user/2", "name": "Albert"]]}

Inference

PUT /v1/inference

Apply named inference rule

Parameters

  • graph (required) graph
  • inferenece (required) name of the inference to apply, (geo)

Response

200

Response error

400 Bad Request
405 Method Not Allowed
500 Internal Server Error

PATH

GET /v1/path

Get any paths available from a start to end node.

Parameters

  • graph (required) graph
  • start
  • end
  • predicateName
  • predicateAdjacent

Response

200 
{
	"graph": "user",
	"data": ["a", "connects", "to", "b"]
}

Response error

400 Bad Request
405 Method Not Allowed
500 Internal Server Error

DROP

POST /v1/drop

Drop a graph and it's indexes

JSON Parameters

  • graph (required) graph name.

Response

200 OK 

Response error

400 Bad Request
405 Method Not Allowed
500 Internal Server Error

INDEX

POST /v1/index

Index a graph

JSON Parameters

  • graph (required) graph name.
  • background (optional) index in the background.

Response

200 OK 

Response error

400 Bad Request
405 Method Not Allowed
500 Internal Server Error