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.

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 recognized.

      • failOnUnknownLanguageTags (boolean): Fail parsing if languages are not recognized.

      • normalizeDataTypeValues (boolean): Normalize recognized datatypes values.

      • normalizeLanguageTags (boolean): Normalize recognized 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 recognized datatypes.

      • verifyLanguageTags (boolean): Verify language based on a given set of definitions for valid languages.

Cancel import operation

DELETE /rest/data/import/upload/<repo_id>

Example:

curl -x DELETE <base_url>/rest/data/import/upload/<repo_id>?name=<encoded_data_url>

Cancel server files import operation

DELETE /rest/data/import/server/<repo_id>

Example:

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 data URLs for import

GET /rest/data/import/upload/<repo_id>

Example:

curl <base_url>/rest/data/import/upload/<repo_id>

Get server files available for import

GET /rest/data/import/server/<repo_id>

Example:

curl <base_url>/rest/data/import/server/<repo_id>

Import from data URL into the repository

POST /rest/data/import/upload/<repo_id>/url

Example:

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
    },
    "replaceGraphs": [
      "string"
    ],
    "status": "PENDING",
    "timestamp": 0,
    "type": "string"
  }'
 <base_url>/rest/data/import/upload/<repo_id>/url

Import from server files into the repository

POST /rest/data/import/server/<repo_id>

Example:

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 GraphDB 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.

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 all connected GraphDB locations

GET /rest/locations

Example:

curl <base_url>/rest/locations -H 'Accept: application/json'

Get active connected GraphDB location

GET /rest/locations/active

Example:

curl <base_url>/rest/locations/active -H 'Accept: application/json'

Modify settings for a connected GraphDB location

POST /rest/locations

Example:

curl -X POST <base_url>/rest/locations -H 'Content-Type: application/json' -H 'Accept: text/plain' -d '
    {
        "username": "<username>",
        "password": "<password>",
        "uri": "<location_uri>"
    }'

Connect a local or remote GraphDB location

PUT /rest/locations

Example:

curl -X PUT <base_url>/rest/locations -H 'Content-Type: application/json' -H 'Accept: text/plain' -d '
    {
        "username": "<username>",
        "password": "<password>",
        "uri": "<location_uri>"
    }'

Activate a connected GraphDB location

POST /rest/locations/activate

Example:

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>"
    }'

Disconnect a GraphDB location

DELETE /rest/locations

Example:

curl -X DELETE <base_url>/rest/locations?uri=<encoded_location_uri> -H 'Accept: text/plain'

Set the default repository

POST /rest/locations/default-repository

Example:

curl -X POST <base_url>/rest/locations/default-repository -H 'Content-Type: application/json' -d '
{
    "repository": "<repo_id>"
}'

Get the location ID

GET /rest/locations/id

Example:

curl <base_url>/rest/locations/id

Hint

Common parameters:

<base_url>: The URL host and path leading to the deployed GraphDB 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 all repositories in the active location or another location

GET /rest/repositories

Example:

curl <base_url>/rest/repositories -H 'Accept: application/json'

Get the default repository configuration for a repository type: “se”, “master”, “worker”, “free”

GET /rest/repositories/defaultConfig/<repositoryType>

Example:

curl <base_url>/rest/repositories/defaultConfig/<repositoryType> -H 'Accept: application/json'

Get repository configuration in the active location or another attached location

GET /rest/repositories/<repo_id>

Example:

curl <base_url>/rest/repositories/<repo_id>?location=<encoded_location_uri> -H 'Accept: application/json'

Get repository size

GET /rest/repositories/<repo_id>/size

Example:

curl <base_url>/rest/repositories/<repo_id>/size?location=<encoded_location_uri> -H 'Accept: application/json'

Create a repository in an attached GraphDB location (.ttl file)

POST /rest/repositories

Example:

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>

Create a repository in an attached GraphDB location (params)

PUT /rest/repositories

Example:

curl -X POST <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":"Ruleset",
                    "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",
                    "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>
    }'

Edit repository configuration

PUT /rest/repositories/<repo_id>

Example:

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":"Ruleset",
                    "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",
                    "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.

Download repository configuration as a Turtle file. Optionally provide a location parameter.

GET /rest/repositories/<repo_id>/download

Example:

curl <base_url>/rest/repositories/<repo_id>/download?location=<encoded_location_uri>

Delete a repository in an attached GraphDB location

DELETE /rest/repositories/<repo_id>

Example:

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 web app;

<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.

Saved queries

Get saved query (or queries, if no parameter specified)

GET /rest/sparql/saved-queries

Example:

curl <base_url>/rest/sparql/saved-queries?name=<query_name>

Create a new saved query

POST /rest/sparql/saved-queries

Example:

curl -X POST <base_url>/rest/sparql/saved-queries -d '
{
    "body": "<query_body>",
    "name": "<query_name>"
}'

Edit an existing saved query

PUT /rest/sparql/saved-queries

Example:

curl -X PUT <base_url>/rest/sparql/saved-queries -d '
{
    "body": "<query_body>",
    "name": "<query_name>"
}'

Delete an existing saved query

DELETE /rest/sparql/saved-queries

Example:

curl -X DELETE <base_url>/rest/sparql/saved-queries?name=<query_name>

Security management

Check if security is enabled

GET /rest/security

Example:

curl -X GET --header 'Accept: application/json' <base_url>/rest/security

Enable security

POST /rest/security

Example:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/plain' -d true <base_url>/rest/security

Check if free access is enabled

GET /rest/security/freeaccess
curl -X GET --header 'Accept: application/json' <base_url>/rest/security/freeaccess

Enable or disable free access

POST /rest/security/freeaccess

Example:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '
    {
            appSettings: {
                    DEFAULT_SAMEAS: boolean
                    DEFAULT_INFERENCE: boolean
                    EXECUTE_COUNT: boolean
                    IGNORE_SHARED_QUERIES: boolean
                    },
            authorities: ["string"],
            enabled: boolean
    }'
    <base_url>/rest/security/freeaccess

Get all users

GET /rest/security/user

Example:

curl <base_url>/rest/security/user

Get a user

GET /rest/security/user/<username>

Example:

curl <base_url>/rest/security/user/<username>

Delete a user

DELETE /rest/security/user/<username>

Example:

curl -X DELETE --header 'Accept: text/plain' <base_url>/rest/security/user/<username>

Change settings for a user

PATCH /rest/security/user/<username>

Example:

curl -X PATCH --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'X-GraphDB-Password: <password>' -d '
    {
        appSettings: {
            DEFAULT_SAMEAS: boolean
            DEFAULT_INFERENCE: boolean
            EXECUTE_COUNT: boolean
            IGNORE_SHARED_QUERIES: boolean
            }
    }'
    <base_url>/rest/security/user/<username>

Create a user

POST /rest/security/user/<username>

Example:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/plain' --header 'X-GraphDB-Password: <password>' -d '
    {
        appSettings: {
            DEFAULT_SAMEAS: boolean
            DEFAULT_INFERENCE: boolean
            EXECUTE_COUNT: boolean
            IGNORE_SHARED_QUERIES: boolean
            },
        grantedAuthorities: ["string"],
        pass: "string",
        username: "string"
    }'
    <base_url>/rest/security/user/<username>

Edit a user

PUT /rest/security/user/<username>

Example:

curl -X PUT --header 'Content-Type: application/json' --header 'Accept: text/plain' --header 'X-GraphDB-Password: <password>' -d '
    {
        appSettings: {
            DEFAULT_SAMEAS: boolean
            DEFAULT_INFERENCE: boolean
            EXECUTE_COUNT: boolean
            IGNORE_SHARED_QUERIES: boolean
            },
        grantedAuthorities: ["string"],
        pass: "string",
        username: "string"
    }'
    <base_url>/rest/security/user/<username>

SQL views management

Access, create, and edit SQL views (tables), as well as delete existing saved queries and see all SQL views for the active repository.

Get all SQL view names for current repository

GET /rest/sql-views/tables

Example:

curl <base_url>/rest/sql-views/tables

Get a SQL view configuration

GET /rest/sql-views/tables/<name>

Example:

curl <base_url>/rest/sql-views/tables/<name>

Create a new SQL view

POST /rest/sql-views/tables/

Example:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{
    name: "string",
    query: "string",
    columns: ["string"]
    }'
    <base_url>/rest/sql-views/tables/

Edit an existing SQL view

PUT /rest/sql-views/tables/<name>

Example:

curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{
    name: "string",
    query: "string",
    columns: ["string"]
    }'
    <base_url>/rest/sql-views/tables/<name>

Delete an existing saved query

DELETE /rest/sql-views/tables/<name>

Example:

curl -X DELETE <base_url>/rest/sql-views/tables/<name>

Authentication

Obtain a GDB token in exchange for username and password

POST /rest/login/**

Example:

curl <base_url>/rest/login/<username> -X POST -H 'X-GraphDB-Password: <password>'

This command will return the user’s roles and GraphDB applications settings. It will also generate a GDB token, which is returned in an Authorization header and will be used at every next authentication request.