Managing repositories via HTTP with curl

What’s in this document?

Using curl lets you script this call in an application. See also the Help ‣ REST API view of the GraphDB Workbench where you will find a complete reference of all REST APIs and be able to run API calls directly from the browser.

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

Note

The command line utility storage-tool gives you several ways to work with GraphDB respositories from your operating system’s command line interface.

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.

  • 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 current or another location

GET /rest/repositories

Example:

curl <base_url>/rest/repositories

Get repository configuration as Turtle

GET /rest/repositories/<repo_id>

Example:

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

Get repository size

GET /rest/repositories/<repo_id>/size

Example:

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

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 'Content-Type: multipart/form-data' -F config=@<repo_ttl_config_filename>

Restart a repository

POST /rest/repositories/<repo_id>/restart

Example:

curl -X POST <base_url>/rest/repositories/<repo_id>/restart

Edit repository configuration

PUT /rest/repositories/<repo_id>

Example:

curl -X PUT <base_url>/rest/repositories/<repo_id> -H 'Accept: application/json' -H 'Content-Type: application/json' -d '
    {
        "id": "<repo_id>",
        "location": "<location_uri>",
        "title": "<repo_title>",
        "type": "graphdb",
        "sesameType":"graphdb:SailRepository",
        "params":{
            "queryTimeout":{
                "name":"queryTimeout",
                "label":"Query timeout (seconds)",
                "value":"0"
            },
            "cacheSelectNodes":{
                "name":"cacheSelectNodes",
                "label":"Cache select nodes",
                "value":"true"
            },
            "rdfsSubClassReasoning":{
                "name":"rdfsSubClassReasoning",
                "label":"RDFS subClass reasoning",
                "value":"true"
            },
            "validationEnabled":{
                "name":"validationEnabled",
                "label":"Enable the SHACL validation",
                "value":"true"
            },
            "ftsStringLiteralsIndex":{
                "name":"ftsStringLiteralsIndex",
                "label":"FTS index for xsd:string literals",
                "value":"default"
            },
            "shapesGraph":{
                "name":"shapesGraph",
                "label":"Named graphs for SHACL shapes",
                "value":"http://rdf4j.org/schema/rdf4j#SHACLShapeGraph"
            },
            "parallelValidation":{
                "name":"parallelValidation",
                "label":"Run parallel validation",
                "value":"true"
            },
            "checkForInconsistencies":{
                "name":"checkForInconsistencies",
                "label":"Enable consistency checks",
                "value":"false"
            },
            "performanceLogging":{
                "name":"performanceLogging",
                "label":"Log the execution time per shape",
                "value":"false"
            },
            "disableSameAs":{
                "name":"disableSameAs",
                "label":"Disable owl:sameAs",
                "value":"true"
            },
            "ftsIrisIndex":{
                "name":"ftsIrisIndex",
                "label":"FTS index for full-text indexing of IRIs",
                "value":"en"
            },
            "entityIndexSize":{
                "name":"entityIndexSize",
                "label":"Entity index size",
                "value":"10000000"
            },
            "dashDataShapes":{
                "name":"dashDataShapes",
                "label":"DASH data shapes extensions",
                "value":"true"
            },
            "queryLimitResults":{
                "name":"queryLimitResults",
                "label":"Limit query results",
                "value":"0"
            },
            "throwQueryEvaluationExceptionOnTimeout":{
                "name":"throwQueryEvaluationExceptionOnTimeout",
                "label":"Throw exception on query timeout",
                "value":"false"
            },
            "member":{
                "name":"member",
                "label":"FedX repo members",
                "value":[]
            },
            "storageFolder":{
                "name":"storageFolder",
                "label":"Storage folder",
                "value":"storage"
            },
            "validationResultsLimitPerConstraint":{
                "name":"validationResultsLimitPerConstraint",
                "label":"Validation results limit per constraint",
                "value":"1000"
            },
            "enablePredicateList":{
                "name":"enablePredicateList",
                "label":"Enable predicate list index",
                "value":"true"
            },
            "transactionalValidationLimit":{
                "name":"transactionalValidationLimit",
                "label":"Transactional validation limit",
                "value":"500000"
            },
            "ftsIndexes":{
                "name":"ftsIndexes",
                "label":"FTS indexes to build (comma delimited)",
                "value":"default, iri, en"
            },
            "logValidationPlans":{
                "name":"logValidationPlans",
                "label":"Log the executed validation plans",
                "value":"false"
            },
            "imports":{
                "name":"imports",
                "label":"Imported RDF files('\'';'\'' delimited)",
                "value":""
            },
            "isShacl":{
                "name":"isShacl",
                "label":"Enable SHACL validation",
                "value":"false"
            },
            "inMemoryLiteralProperties":{
                "name":"inMemoryLiteralProperties",
                "label":"Cache literal language tags",
                "value":"true"
            },
            "ruleset":{
                "name":"ruleset",
                "label":"Ruleset",
                "value":"rdfsplus-optimized"
            },
            "readOnly":{
                "name":"readOnly",
                "label":"Read-only",
                "value":"false"
            },
            "enableLiteralIndex":{
                "name":"enableLiteralIndex",
                "label":"Enable literal index",
                "value":"true"
            },
            "enableFtsIndex":{
                "name":"enableFtsIndex",
                "label":"Enable full-text search (FTS) index",
                "value":"false"
            },
            "defaultNS":{
                "name":"defaultNS",
                "label":"Default namespaces for imports('\'';'\'' delimited)",
                "value":""
            },
            "enableContextIndex":{
                "name":"enableContextIndex",
                "label":"Enable context index",
                "value":"false"
            },
            "baseURL":{
                "name":"baseURL",
                "label":"Base URL",
                "value":"http://example.org/owlim#"
            },
            "logValidationViolations":{
                "name":"logValidationViolations",
                "label":"Log validation violations",
                "value":"false"
            },
            "globalLogValidationExecution":{
                "name":"globalLogValidationExecution",
                "label":"Log every execution step of the SHACL validation",
                "value":"false"
            },
            "entityIdSize":{
                "name":"entityIdSize",
                "label":"Entity ID size",
                "value":"32"
            },
            "repositoryType":{
                "name":"repositoryType",
                "label":"Repository type",
                "value":"file-repository"
            },
            "eclipseRdf4jShaclExtensions":{
                "name":"eclipseRdf4jShaclExtensions",
                "label":"RDF4J SHACL extensions",
                "value":"true"
            },
            "validationResultsLimitTotal":{
                "name":"validationResultsLimitTotal",
                "label":"Validation results limit total",
                "value":"1000000"}
            }
        }
    }'

Tip

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

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>

Tip

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.

Repository monitoring

Get repository statistics

GET /rest/monitor/repository/{repositoryID}

Example:

curl -X GET --header 'Accept: application/json' '<base_url>/rest/monitor/repository/<repo_id>'