Retrieve the contents or permissions metadata of a graph, or a list of available graph URIs.
URL Parameters | |
---|---|
database? | Perform this operation on the named content database instead of the default content database associated with the REST API instance. Using an alternative database requires the "eval-in" privilege; for details, see Security Requirements in the REST Application Developer's Guide. |
graph? |
The URI of the named graph to retrieve. You cannot use this parameter
with the default parameter.
|
default? |
Indicates the request should return the default graph. This parameter
accepts no value. You cannot use this parameter with the
graph parameter.
|
category? |
The category of data to fetch about the requested document.
Valid categories: content (default),
metadata, permissions . The metadata and
permissions are synonymous. This parameter can only
be used when retrieving the contents or permission metadata for
a graph.
|
txid? |
The transaction identifier of the multi-statement transaction in
which to service this request. Use the /transactions
service to create and manage multi-statement transactions.
|
timestamp? |
A timestamp returned in the ML-Effective-Timestamp
header of a previous request. Use this parameter to iteratively
fetch a the contents of a graph as a particular system timestamp.
You can only use this parameter when the request includes a
graph or default parameter.
For more details, see
Performing Point-in-Time Operations in the REST Application Developer's Guide.
|
Request Headers | |
---|---|
Accept* |
The expected MIME type of the response. When retrieving a list
of available graphs (no request parameters), you can specify
text/plain , text/html , or
text/uri-list (default). When retrieving the contents of
a named graph or the default graph, you can specify any of the MIME
types listed in
Supported RDF Triple Formats in the Semantic Graph Developer's Guide.
When retrieving permissions metadata for a graph, you can specify
application/xml (default) or application/json .
|
Response Headers | |
---|---|
Content-Type | The MIME type of the data in the response body, corresponding to the MIME type in the Accept header. |
ML-Effective-Timestamp |
The system timestamp at which this operation was performed. You
can use the value in the timestamp parameter of a
subsequent request. For more details, see
Performing Point-in-Time Operations in the REST Application Developer's Guide.
|
Upon success, MarkLogic Server returns status 200 (OK). If a named graph
or the default graph is specified, the response body contains the
requested graph contents or metadata. If neither the graph
nor default
request parameters are present, the response
body contains a list of available graph URIs. If you request triples
in an unsupported format, MarkLogic Server returns status 406
(Not Acceptable).
rest-reader
role, or the
following privilege:
http://marklogic.com/xdmp/privileges/rest-reader
You can use this method in the following ways:
default
and graph
parameters. The
MIME type in the Accept header must be one of text/plain
,
text/html
, or text/uri-list
(default).
default
or graph
parameter (but not both). The MIME type in the Accept header
must be one of the MIME types listed in
Supported RDF Triple Formats in the Semantic Graph Developer's Guide.
default
or graph
parameter (but not both) and set the category
parameter
to permissions
or metadata
. The MIME type
in the Accept header must be application/xml
(default) or
application/json
.
When used to retrieve the contents of a graph, this interface implements the GET method of the W3C Graph Store HTTP Protocol; for details, see http://www.w3.org/TR/sparql11-http-rdf-update/.
NOTE: The collection lexicon must be enabled on your database when using the REST graph store interfaces or using the GRAPH '?g' construct in SPARQL queries. You can check and change the collection lexicon setting from the Admin Interface.
$ curl --anyauth --user user:password -i -X GET \ 'http://localhost:8000/v1/graphs' ==> Retrieve a list of graphs in the database. Since no Accept is given, results are returned as text/uri-list. MarkLogic Server responds with output similar to the following: HTTP/1.1 200 OK Content-type: text/uri-list; charset=UTF-8 Server: MarkLogic Content-Length: 61 Connection: Keep-Alive Keep-Alive: timeout=5 /my/named/graph http://marklogic.com/semantics#default-graph If you request output as text/html, MarkLogic Server returns data in the response body similar to the following: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Graphs</title> </head> <body> <ul> <li>/my/named/graph</li> <li>http://marklogic.com/semantics#default-graph</li> </ul> </body> </html>
$ curl --anyauth --user user:password -i -X GET -H "Accept: text/turtle" 'http://localhost:8000/v1/graphs?graph=/my/named/graph' ==> Retrieve the graph with URI /my/named/graph, in Turtle format. MarkLogic Server responds with output similar to the following: HTTP/1.1 200 OK Content-type: text/turtle; charset=UTF-8 Server: MarkLogic Content-Length: 6680 Connection: Keep-Alive Keep-Alive: timeout=5 @prefix xs: <http://www.w3.org/2001/XMLSchema#> . <http://dbpedia.org/resource/Abraham_Lincoln> <http://dbpedia.org/ontology/birthDate> "1809-02-12"^^xs:date . <http://dbpedia.org/resource/Alan_Turing> <http://dbpedia.org/ontology/birthDate> "1912-06-23"^^xs:date .
$ curl --anyauth --user user:password -i -X GET -H "Accept: application/json" \ 'http://localhost:8000/v1/graphs?graph=/my/named/graph&category=permissions' ==> Retrieve the permissions metadata for the graph with URI /my/named/graph, as JSON. MarkLogic Server responds with output similar to the following: HTTP/1.1 200 OK Content-type: application/json; charset=utf-8 Server: MarkLogic Content-Length: 123 Connection: Keep-Alive Keep-Alive: timeout=5 {"permissions":[ {"role-name":"rest-writer","capabilities":["update"]}, {"role-name":"rest-reader","capabilities":["read"]} ]}
$ curl --anyauth --user user:password -i -X GET -H "Accept: application/xml" \ 'http://localhost:8000/v1/graphs?graph=/my/named/graph&category=permissions' ==> Retrieve the permissions metadata for the graph with URI /my/named/graph, as XML. MarkLogic Server responds with output similar to the following: HTTP/1.1 200 OK Content-type: application/json; charset=utf-8 Server: MarkLogic Content-Length: 123 Connection: Keep-Alive Keep-Alive: timeout=5 <rapi:metadata uri="/my/named/graph"> <rapi:permissions> <rapi:permission> <rapi:role-name>rest-writer</rapi:role-name> <rapi:capability>update</rapi:capability> </rapi:permission> <rapi:permission> <rapi:role-name>rest-reader</rapi:role-name> <rapi:capability>read</rapi:capability> </rapi:permission> </rapi:permissions> </rapi:metadata>