-
Notifications
You must be signed in to change notification settings - Fork 0
Triple Store API
The ERMR triple store API acts as a mediator between clients and the internal triple store we are using. It interprets the requests of the client and forward a request in the correct format for the triple store.
When you have succesfully deployed ERMR on a host, the CDMI web service is accessible at http://host/api/triple.
To list existing repositories, the following request shall be performed:
GET <root URI>/api/triple
where:
-
<root URI>is the path to the registry.
The response message contains a JSON list of repositories informations (to be refined).
| HTTP Status | Description |
|---|---|
| 200 OK | The list is returned |
GET a list of repositories:
GET /api/triple HTTP/1.1
Host: 192.168.56.100
Response:
HTTP/1.1 200 Ok
[ { "title": "DemoLondon", "writable": true, "id": "DemoLondon" },
{ "title": "Test", "writable": true, "id": "Test" } ]
To create a new repository, the following request shall be performed:
PUT <root URI>/api/triple/<NewRepositoryName>
where:
-
<root URI>is the path to the registry. -
<NewRepositoryName>is the name for the repository to be created.
| HTTP Status | Description |
|---|---|
| 201 Created | The new repository was created |
PUT to the triple store URI to create a repository:
PUT /api/triple/MyRepository HTTP/1.1
Host: 192.168.56.100
Response:
HTTP/1.1 201 Created
To delete a repository, the following request shall be performed:
DELETE <root URI>/api/triple/<repositoryName>
where:
-
<root URI>is the path to the registry. -
<repositoryName>is the name of the repository to be deleted.
| HTTP Status | Description |
|---|---|
| 204 No Content | The repository was deleted |
DELETE a repository:
Delete /api/triple/MyRepository HTTP/1.1
Host: 192.168.56.100
Response:
HTTP/1.1 204 No Content
The following HTTP PUT/POST requests add triples to a repository. A PUT request empty the repository first while a POST request add triples.
PUT <root URI>/api/triple/<repositoryName>/statements
POST <root URI>/api/triple/<repositoryName>/statements
Where:
-
<root URI>is the path to the registry. -
<repositoryName>is the name of the repository.
| Header | Type | Description | Requirement |
|---|---|---|---|
| Content-Type | Header String | The content type of the triples | Mandatory |
| “text/plain” for ntriples | |||
| “application/rdf+xml” for RDF | |||
| “text/turtle” for Turtle |
The request message body contains the data to be stored.
| HTTP Status | Description |
|---|---|
| 201 Created | The triples were added |
PUT triples to the repository URI:
PUT /api/triple/MyRepository/statements HTTP/1.1
Host: 192.168.56.100
Content-Type: text/plain
<http://www.pericles.org/models#process1> <http://www.pericles.org/models#name> "Ingest" .
<http://www.pericles.org/models#process1> <http://www.pericles.org/models#description> "Ingest documents in the registry" .
<http://www.pericles.org/models#process1> <http://www.pericles.org/models#identity> "7d4e14c8-1adf-4cfd-b0b8-ede46944b006" .
<http://www.pericles.org/models#process1> <http://www.pericles.org/models#version> "0.1" .
Response:
HTTP/1.1 201 Created
To list triples contained in an existing repository, the following request shall be performed:
GET <root URI>/api/triple/<repositoryName>
GET <root URI>/api/triple/<repositoryName>/statements
where:
-
<root URI>is the path to the registry. -
<repositoryName>is the name of the repository to list.
| Header | Type | Description | Requirement |
|---|---|---|---|
| Accept | Header String | “application/json” | Optional |
| “application/rdf+xml” |
By default the response message contains a JSON list of triples. Specifying “application/rdf+xml” as the Accept header can be used to obtain the result in XML.
| HTTP Status | Description |
|---|---|
| 200 OK | The list is returned |
GET a list of repository triples:
GET /api/triple/MyRepository HTTP/1.1
Host: 192.168.56.100
Response:
HTTP/1.1 200 Ok
[
[
"<http://www.pericles.org/models#process3>",
"<http://www.pericles.org/models#version>",
"\"1.0\""
],
[
"<http://www.pericles.org/models#process3>",
"<http://www.pericles.org/models#identity>",
"\"3ecdb028-40ec-453a-b4eb-21ad9234ac5e\""
],
[
"<http://www.pericles.org/models#process3>",
"<http://www.pericles.org/models#description>",
"\"Extract metadata in a document of the registry\""
],
[
"<http://www.pericles.org/models#process3>",
"<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>",
"<http://www.pericles.org/models#process>"
],
...
]
To delete all triples of a repository, the following request shall be performed:
DELETE <root URI>/api/triple/<repositoryName>/statements
where:
-
<root URI>is the path to the registry. -
<repositoryName>is the name of the repository that contains triples to be deleted.
| HTTP Status | Description |
|---|---|
| 204 No Content | The triples were deleted |
DELETE a repository:
Delete /api/triple/MyRepository/statements HTTP/1.1
Host: 192.168.56.100
Response:
HTTP/1.1 204 No Content
To send a SPARQL query to a repository, the following request shall be performed:
GET <root URI>/api/triple/<repositoryName>?query=<SparqlQuery>
where:
-
<root URI>is the path to the registry. -
<repositoryName>is the name of the repository to query. -
<SparqlQuery>is a sparql query encoded as a URI.
| Header | Type | Description | Requirement |
|---|---|---|---|
| Accept | Header String | “application/json” | Optional |
| “application/sparql-results+xml” | |||
| “application/sparql-results+json” |
By default the response message contains a JSON dictionary (“application/json”):
- “values stores a list of tuples
- “name” stores a list of names for the returned tuples
Specifying “application/sparql-results+xml” or “application/sparql-results+json” can be used to obtain these outputs :
| HTTP Status | Description |
|---|---|
| 200 OK | The result is returned |
GET to evaluate a SPARQL query on a repository:
GET /api/triple/MyRepo?query=select%20?s%20?p%20?o%20%7B?s%20?p%20?o%7D HTTP/1.1
Host: 192.168.56.100
Response:
HTTP/1.1 200 Ok
{
"values": [
[
"<http://www.pericles.org/models#version>",
"\"1.0\""
],
[
"<http://www.pericles.org/models#identity>",
"\"3ecdb028-40ec-453a-b4eb-21ad9234ac5e\""
],
[
"<http://www.pericles.org/models#name>",
"\"Convert\""
],
...
],
"names": [
"p",
"o"
]
}