Workbench REST API curl commands

This page displays GraphDB Workbench REST API calls as curl commands which enables developers to script these calls in their applications.

This data is also available at http://localhost:7200/webapi on a GraphDB instance running on the default 7200 port.

In addition to this, the RDF4J API is also accessible.

Location Management

Most location management queries can either take the following set of attributes as an argument or return them as a response.

  • active (boolean): True if the location is the currently active one.
  • defaultRepository (string): Default repository for the location.
  • errorMsg (string): Error message, if there was an error connecting to this location.
  • label (string): Human readable label
  • local (boolean): True if the location is local (on the same machine as the workbench).
  • password (string): Password for the new location if any. This parameter only makes sense for remote locations.
  • system (boolean): True if the location is the system location.
  • uri (string): The GraphDB location URL.
  • username (string): Username for the new location if any. This parameter only makes sense for remote locations .
GET /rest/locations
Get all connected GraphDB locations
curl <base_url>/rest/locations -H 'Accept: application/json'
GET /rest/locations/active
Get active connected GraphDB location
curl <base_url>/rest/locations/active -H 'Accept: application/json'
POST /rest/locations
Modify settings for a connected GraphDB location
curl -X POST <base_url>/rest/locations -H 'Content-Type:application/json' -H 'Accept:text/plain' -d '
    {
        "username": "<username>",
        "password": "<password>",
        "uri": "<location_uri>"
    }'
PUT /rest/locations
Connect a local or remote GraphDB location
curl -X PUT <base_url>/rest/locations -H 'Content-Type:application/json' -H 'Accept:text/plain' -d '
    {
        "username": "<username>",
        "password": "<password>",
        "uri": "<location_uri>"
    }'
POST /rest/locations/activate
Activate a connected GraphDB location
curl -X POST <base_url>/rest/locations/activate -H 'Content-Type:application/json' -H 'Accept:text/plain' -d '
    {
        "username": "<username>",
        "password": "<password>",
        "uri": "<location_uri>"
    }'
DELETE /rest/locations
Disconnect a GraphDB location
curl -X DELETE <base_url>/rest/locations?uri=<encoded_location_uri> -H 'Accept: text/plain'
POST /rest/locations/default-repository
Set the default repository
curl -X POST <base_url>/rest/locations/default-repository -d '
{
    "repository": "<repo_id>"
}'
GET /rest/locations/id
Get the location ID
curl <base_url>/rest/locations/id

Hint

Common parameters:

<base\_url> - the url host and path leading to the deployed GDB-Workbench webapp;

<location\_uri> - file system path of the physical location of the repo (could be local or remote);

<encoded\_location\_uri> - url encoded file system path of the physical location of the repo (could be local or remote).

Repository Management

Most repository management queries can either take the following set of attributes as an argument or return them as a response.

  • externalUrl (string): The URL that the repository can be accessed at by an external service.
  • id (string): The repository id.
  • local (boolean): True if the repository is local (on the same machine as the workbench).
  • location (string): If remote, the repository’s location.
  • sesameType (string): The sesame type of the repository.
  • title (string): The repository title
  • type (string): Repository type - worker, master or system.
  • unsupported (boolean): True if the repository is unsupported.
  • writable (boolean): True if the repository is writable.
  • readable (boolean): True if the repository is readable.
  • uri (string): The GraphDB location URL.
GET /rest/repositories
Get all repositories in the active location or another location
curl <base_url>/rest/repositories -H 'Accept: application/json'
GET /rest/repositories/{repositoryType}/config
Get the default repository configuration for the repository type
curl <base_url>/rest/repositories/<repo_type>/config -H 'Accept: application/json'
GET /rest/repositories/{repositoryId}
Get all repositories in the active location or another location
curl <base_url>/rest/repositories/<repo_id>?location=<encoded_location_uri> -H 'Accept: application/json'
GET /rest/repositories/cluster
Get all repositories of all nodes of a cluster
curl <base_url>/rest/repositories/cluster?location=<encoded_location_uri> -H 'Accept: application/json'
GET /rest/repositories/{repositoryId}/size
Get repository size
curl <base_url>/rest/repositories/<repo_id>/size?location=<encoded_location_uri> -H 'Accept: application/json'
POST /rest/repositories
Create a repository in an attached GraphDB location (ttl file)
curl -X POST <base_url>/rest/repositories?location=<encoded_location_uri> -H 'Accept: application/json' -H 'Content-Type: multipart/form-data' -F "config=@<repo_ttl_config_filename>"
PUT /rest/repositories
Create a repository in an attached GraphDB location (params)
curl -X PUT <base_url>/rest/repositories -H 'Content-Type:application/json' -d '
    {
        "id": "<repo_id>",
        "location": "<location_uri>",
        "params": {
                "baseURL": {
                    "label": "Base URL",
                    "name": "baseURL",
                    "value": "http://example.org/graphdb#"
                },
                "entityIndexSize": {
                    "label":"Entity index size",
                    "name":"entityIndexSize",
                    "value":"200000"
                },
                "entityIdSize": {
                    "label":"Entity ID bit-size",
                    "name":"entityIdSize",
                    "value":"32"
                },
                "ruleset": {
                    "label":"Rule-set",
                    "name":"ruleset",
                    "value":"owl-horst-optimized"
                },
                "storageFolder": {
                    "label":"Storage folder",
                    "name":"storageFolder",
                    "value":"storage"
                },
                "enableContextIndex": {
                    "label":"Use context index",
                    "name":"enableContextIndex",
                    "value":"false"
                },
                "cacheMemory": {
                    "label":"Total cache memory",
                    "name":"cacheMemory",
                    "value":"80m"
                },
                "tupleIndexMemory": {
                    "label":"Tuple index memory",
                    "name":"tupleIndexMemory",
                    "value":"80m"
                },
                "enablePredicateList": {
                    "label":"Use predicate indices",
                        "name":"enablePredicateList",
                    "value":"false"
                },
                "predicateMemory":{
                    "label":"Predicate index memory",
                    "name":"predicateMemory",
                    "value":"0"
                },
                "ftsMemory":{
                    "label":"Full-text search memory",
                    "name":"ftsMemory",
                    "value":"0"
                },
                "ftsIndexPolicy":{
                    "label":"Full-text search indexing policy",
                    "name":"ftsIndexPolicy",
                    "value":"never"
                },
                "ftsLiteralsOnly":{
                    "label":"Full-text search literals only",
                    "name":"ftsLiteralsOnly",
                    "value":"true"
                },
                "inMemoryLiteralProperties":{
                    "label":"Cache literal language tags",
                    "name":"inMemoryLiteralProperties",
                    "value":"false"
                },
                "enableLiteralIndex":{
                    "label":"Enable literal index",
                    "name":"enableLiteralIndex",
                    "value":"true"
                },
                "indexCompressionRatio":{
                    "label":"Index compression ratio",
                    "name":"indexCompressionRatio",
                    "value":"-1"
                },
                 "checkForInconsistencies":{
                    "label":"Check for inconsistencies",
                    "name":"checkForInconsistencies",
                    "value":"false"
                },
                "disableSameAs":{
                    "label":"Disable OWL sameAs optimisation",
                    "name":"disableSameAs",
                    "value":"false"
                },
                 "enableOptimization":{
                    "label":"Enable query optimisation",
                    "name":"enableOptimization",
                    "value":"true"
                },
                "transactionIsolation":{
                    "label":"Transaction isolation",
                    "name":"transactionIsolation",
                    "value":"true"
                },
                 "transactionMode":{
                    "label":"Transaction mode",
                    "name":"transactionMode",
                    "value":"safe"
                },
                "queryTimeout":{
                    "label":"Query time-out (seconds)",
                    "name":"queryTimeout",
                    "value":"0"
                },
                "queryLimitResults":{
                    "label":"Limit query results",
                    "name":"queryLimitResults",
                    "value":"0"
                },
                "throwQueryEvaluationExceptionOnTimeout": {
                    "label":"Throw exception on query time-out",
                    "name":"throwQueryEvaluationExceptionOnTimeout",
                    "value":"false"
                },
                "readOnly": {
                    "label":"Read-only",
                    "name":"readOnly",
                    "value":"false"
                },
                "nonInterpretablePredicates":{
                    "label":"Non-interpretable predicates",
                    "name":"nonInterpretablePredicates",
                    "value":"http://www.w3.org/2000/01/rdf-schema#label;http://www.w3.org/1999/02/22-rdf-syntax-ns#type;http://www.ontotext.com/owlim/ces#gazetteerConfig;http://www.ontotext.com/owlim/ces#metadataConfig"
                }

        },
        "title": <repo_title>,
        "type": <repo_type>
    }'
PUT /rest/repositories/{repositoryId}
Edit repository configuration
curl -X PUT <base_url>/rest/repositories/<repo_id> -H 'Accept:application/json' -d '
    {
        "id": "<repo_id>",
        "location": "<location_uri>",
        "params": {
                "baseURL": {
                    "label": "Base URL",
                    "name": "baseURL",
                    "value": "http://example.org/graphdb#"
                },
                "entityIndexSize": {
                    "label":"Entity index size",
                    "name":"entityIndexSize",
                    "value":"200000"
                },
                "entityIdSize": {
                    "label":"Entity ID bit-size",
                    "name":"entityIdSize",
                    "value":"32"
                },
                "ruleset": {
                    "label":"Rule-set",
                    "name":"ruleset",
                    "value":"owl-horst-optimized"
                },
                "storageFolder": {
                    "label":"Storage folder",
                    "name":"storageFolder",
                    "value":"storage"
                },
                "enableContextIndex": {
                    "label":"Use context index",
                    "name":"enableContextIndex",
                    "value":"false"
                },
                "cacheMemory": {
                    "label":"Total cache memory",
                    "name":"cacheMemory",
                    "value":"80m"
                },
                "tupleIndexMemory": {
                    "label":"Tuple index memory",
                    "name":"tupleIndexMemory",
                    "value":"80m"
                },
                "enablePredicateList": {
                    "label":"Use predicate indices",
                        "name":"enablePredicateList",
                    "value":"false"
                },
                "predicateMemory":{
                    "label":"Predicate index memory",
                    "name":"predicateMemory",
                    "value":"0"
                },
                "ftsMemory":{
                    "label":"Full-text search memory",
                    "name":"ftsMemory",
                    "value":"0"
                },
                "ftsIndexPolicy":{
                    "label":"Full-text search indexing policy",
                    "name":"ftsIndexPolicy",
                    "value":"never"
                },
                "ftsLiteralsOnly":{
                    "label":"Full-text search literals only",
                    "name":"ftsLiteralsOnly",
                    "value":"true"
                },
                "inMemoryLiteralProperties":{
                    "label":"Cache literal language tags",
                    "name":"inMemoryLiteralProperties",
                    "value":"false"
                },
                "enableLiteralIndex":{
                    "label":"Enable literal index",
                    "name":"enableLiteralIndex",
                    "value":"true"
                },
                "indexCompressionRatio":{
                    "label":"Index compression ratio",
                    "name":"indexCompressionRatio",
                    "value":"-1"
                },
                 "checkForInconsistencies":{
                    "label":"Check for inconsistencies",
                    "name":"checkForInconsistencies",
                    "value":"false"
                },
                "disableSameAs":{
                    "label":"Disable OWL sameAs optimisation",
                    "name":"disableSameAs",
                    "value":"false"
                },
                 "enableOptimization":{
                    "label":"Enable query optimisation",
                    "name":"enableOptimization",
                    "value":"true"
                },
                "transactionIsolation":{
                    "label":"Transaction isolation",
                    "name":"transactionIsolation",
                    "value":"true"
                },
                 "transactionMode":{
                    "label":"Transaction mode",
                    "name":"transactionMode",
                    "value":"safe"
                },
                "queryTimeout":{
                    "label":"Query time-out (seconds)",
                    "name":"queryTimeout",
                    "value":"0"
                },
                "queryLimitResults":{
                    "label":"Limit query results",
                    "name":"queryLimitResults",
                    "value":"0"
                },
                "throwQueryEvaluationExceptionOnTimeout": {
                    "label":"Throw exception on query time-out",
                    "name":"throwQueryEvaluationExceptionOnTimeout",
                    "value":"false"
                },
                "readOnly": {
                    "label":"Read-only",
                    "name":"readOnly",
                    "value":"false"
                },
                "nonInterpretablePredicates":{
                    "label":"Non-interpretable predicates",
                    "name":"nonInterpretablePredicates",
                    "value":"http://www.w3.org/2000/01/rdf-schema#label;http://www.w3.org/1999/02/22-rdf-syntax-ns#type;http://www.ontotext.com/owlim/ces#gazetteerConfig;http://www.ontotext.com/owlim/ces#metadataConfig"
                }
        },
        "title": "<repo_title>",
        "type": "<repo_type>"
    }'

Hint

Adjust parameters with new values except for <repo\_id> in order to edit the current repository configuration.

GET /rest/repositories/{repositoryId}/download
Download repository configuration as a Turtle file. Optionally provide a location parameter.
curl <base_url>/rest/repositories/<repo_id>/download?location=<encoded_location_uri>
DELETE /rest/repositories/{repositoryId}
Delete a repository in an attached GraphDB location
curl -X DELETE <base_url>/rest/repositories/<repo_id>?location=<encoded_location_uri> -H 'Accept: application/json'

Hint

Common parameters:

<base\_url> - the url host and path leading to the deployed GDB-Workbench webapp;

<location\_uri> - file system path of the physical location of the repo (could be local or remote);

<encoded\_location\_uri> - url encoded file system path of the physical location of the repo (could be local or remote);

<repo\_id> - the id string with which the current repository can be referred to;

<repo\_title> - human-readable name of the current repository;

<repo\_type> - type of the repository, could be se, worker, master.

Data import

Most data import queries can either take the following set of attributes as an argument or return them as a response.

  • fileNames (string list): A list of filenames that are to be imported.
  • importSettings (JSON object): Import settings.
    • baseURI (string): Base URI for the files to be imported.
    • context (string): Context for the files to be imported.
    • data (string): Inline data.
    • forceSerial (boolean): Force use of the serial statements pipeline.
    • name (string): Filename.
    • status (string): Status of an import - pending, importing, done, error, none, interrupting.
    • timestamp (integer): When was the import started.
    • type (string): The type of the import.
    • replaceGraphs (string list): A list of graphs that you want to be completely replaced by the import.
    • parserSettings (JSON object): Parser settings.
      • failOnUnknownDataTypes (boolean) - fail parsing if datatypes are not recognised.
      • failOnUnknownLanguageTags (boolean) - fail parsing if languages are not recognised.
      • normalizeDataTypeValues (boolean) - normalize recognized datatypes values.
      • normalizeLanguageTags (boolean) - normalize recognised language tags.
      • preserveBNodeIds (boolean) - use blank node IDs found in the file instead of assigning them.
      • stopOnError (boolean) - stop on error. If false, the error will be logged and parsing will continue.
      • verifyDataTypeValues (boolean) - verify recognised datatypes.
      • verifyLanguageTags (boolean) - verify language based on a given set of definitions for valid languages.
      • verifyRelativeURIs (boolean) - verify relative URIs.
      • verifyURISyntax (boolean) - verify the URI syntax.
DELETE /rest/data/import/upload/{repositoryId}
Cancel import operation
curl -x DELETE <base_url>/rest/data/import/upload/<repo_id>?name=<encoded_data_url>
DELETE /rest/data/import/server/{repositoryId}
Cancel server files import operation
curl -X DELETE <base_url>/rest/data/import/server/<repo_id>?name=<encoded_filepath>

Hint

<encoded\_filepath> - encoded filepath leading to a server file that is in the process of being imported.

GET /rest/data/import/url
Get data urls for import
curl <base_url>/rest/data/import/upload/<repo_id>
GET /rest/data/import/server/{repositoryId}
Get server files available for import
curl <base_url>/rest/data/import/server/<repo_id>
POST /rest/data/import/upload/{repositoryId}/url
Import from data url into the repository
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '
{
    "baseURI": "string",
    "context": "string",
    "data": "string",
    "forceSerial": true,
    "format": "string",
    "message": "string",
    "name": "string",
    "parserSettings": {
      "failOnUnknownDataTypes": boolean,
      "failOnUnknownLanguageTags": boolean,
      "normalizeDataTypeValues": boolean,
      "normalizeLanguageTags": boolean,
      "preserveBNodeIds": boolean,
      "stopOnError": boolean,
      "verifyDataTypeValues": boolean,
      "verifyLanguageTags": boolean,
      "verifyRelativeURIs": boolean,
      "verifyURISyntax": boolean
    },
    "replaceGraphs": [
      "string"
    ],
    "status": "PENDING",
    "timestamp": 0,
    "type": "string"
  }'
 '<base_url>/rest/data/import/upload/<repo_id>/url'
POST /rest/data/import/server/{repositoryId}
Import from server files into the repository
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{
  "fileNames": [
    "<data_url>",
    "<data_url>"
  ]
}' '<base_url>/rest/data/import/server/<repo_id>'

Hint

Common parameters:

<base\_url> - the url host and path leading to the deployed GDB-Workbench webapp;

<repo\_id> - the id string with which the current repository can be referred to;

<encoded\_repository\_filepath> - encoded filepath leading to physical repo location;

<data\_url> - url leading to the data source to be imported;

<encoded\_data\_url> - encoded url leading to the data source to be imported;

<encoded\_server\_filepath> - encoded filepath leading to server files to be imported.

Saved Queries

GET /rest/sparql/saved-queries
Get saved query (or queries, if no parameter specified)
curl <base_url>/rest/sparql/saved-quereis?name=<query_name>
POST /rest/sparql/saved-queries
Create a new saved query
curl -X POST <base_url>/rest/sparql/saved-queries -d '
{
    "body": "<query_body>",
    "name": "<query_name>"
}'
PUT /rest/sparql/saved-queries
Edit an existing saved query
curl -X PUT <base_url>/rest/sparql/saved-queries -d '
{
    "body": "<query_body>",
    "name": "<query_name>"
}'
DELETE /rest/sparql/saved-queries
Delete an existing saved query
curl -X DELETE <base_url>/rest/sparql/saved-queries?name=<query_name>

Cluster Management

GET /rest/cluster/masters/{masterRepositoryId}
Get information about master
curl <base_url>/rest/cluster/masters/<master_repo_id>
POST /rest/cluster/masters/{masterRepositoryId}
Set master attribute
curl -X POST <base_url>/rest/cluster/masters/<master_repo_id>?masterLocation=<master_location> --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '<inline_bean_model>'
GET /rest/cluster/masters/{masterRepositoryId}/workers
Get workers connected to a master
curl <base_url>/rest/cluster/masters/<master_repo_id>/workers?masterLocation=<master_location>
DELETE /rest/cluster/masters/{masterRepositoryId}/workers
Disconnect a worker from a master
curl -X DELETE <base_url>/rest/cluster/masters/<master_repo_id>/workers?masterLocation=<master_location>\&workerURL=<worker_url>
DELETE /rest/cluster/masters/{masterRepositoryId}/peers
Disconnect two masters
curl -X DELETE <base_url>/rest/cluster/masters/<master_repo_id>/peers?masterLocation=<master_location>\&masterNodeID=<master_node_id>\&peerLocation=<peer_location>\&peerNodeID=<peer_node_id>\&peerRepositoryID=<peer_repo_id>
POST /rest/cluster/masters/{masterRepositoryId}/peers
Connect two masters
curl -X POST <base_url>/rest/cluster/masters/<master_id>/peers -H 'Accept: application/json' -H 'Content-Type: application/json' -d '
    {
        "bidirectional": boolean,
        "masterLocation": "<master_location>",
        "masterNodeID": "<master_node_id>",
        "peerLocation": "<peer_location>",
        "peerNodeID": "<peer_node_id>",
        "peerRepositoryID": "<peer_repo_id>"
    }'
POST /rest/cluster/masters/{masterRepositoryId}/workers
Connect a worker to a master
curl -X POST <base_url>/rest/cluster/masters/<master_repo_id>/workers -H 'Accept: application/json' -H 'Content-Type: application/json' -d '
    {
        "workerURL": "<worker_url>",
        "masterLocation": "<master_location>"
    }'
POST /rest/cluster/nodes/clone
Clone a worker
curl -X POST <base_url>/rest/cluster/nodes/clone -H 'Accept: application/json' -H 'Content-Type: application/json' -d '
    {
        "cloningNodeLocation": "<clone_node_location>",
        "cloningNodeRepositoryID": "<clone_node_repo_id>",
        "newNodeLocation": "<new_node_location>",
        "newNodeRepositoryID": "<new_node_repo_id>",
        "newNodeTitle": "<new_node_repo_title>"
    }'

Hint

<clone\_node\_location> - current physical location of the worker repository to be cloned;

<clone\_node\_repo\_id> - the string id of the current physical location of the worker repository to be cloned;

<new\_node\_location> - new physical location of the new worker repository to be created;

<new\_node\_repo\_id> - the string id of the new physical location of the new worker repository to be created;

<new\_node\_repo\_title> - new title of the new worker repository to be created.

GET /rest/cluster/masters/{masterRepositoryId}/backup
Initiate a cluster backup
curl <base_url>/rest/cluster/masters/<master_repo_id>/backup?masterLocation=<master_location>&masterRepositoryId=<master_repo_id>&backupName=<backup_name>
GET /rest/cluster/masters/{masterRepositoryId}/restore
Initiate a cluster restore
curl <base_url>/rest/cluster/masters/<master_repo_id>/restore?masterLocation=<master_location>&masterRepositoryId=<master_repo_id>&backupName=<backup_name>

Hint

Common parameters:

<base\_url> - the url host and path leading to the deployed GDB-Workbench webapp;

<master\_repo\_id> - the id string with which the current repository of type master can be referred to;

<master\_location> - file path leading to physical master repository location. Use local as value when referred from and to the same location;

<worker\_url> - absolute url referring to a worker repository;

<backup\_name> - the id string referring to a new backup of a repository or to an old one when attempting to restore it.