openapi: "3.0.1"
info:
  title: RDF4J REST API
  version: "10"
  description: |
    The RDF4J REST API is an HTTP protocol that covers a fully compliant implementation of the [SPARQL 1.1 Protocol W3C Recommendation](https://www.w3.org/TR/sparql11-protocol/). This ensures that RDF4J Server functions as a fully standard-compliant [SPARQL](https://www.w3.org/TR/sparql11-query/) endpoint.

    The RDF4J REST API additionally supports the [SPARQL 1.1 Graph Store HTTP Protocol W3C Recommendation](https://www.w3.org/TR/sparql11-http-rdf-update/). The RDF4J REST API extends the W3C standards in several aspects, the most important of which is database transaction management.

externalDocs:
  url: https://rdf4j.org/documentation/reference/rest-api/

servers:
  - url: http://localhost:8080/rdf4j-server/
    description: RDF4J Server on localhost

tags:
  - name: Repositories
    description: Repository management
  - name: SPARQL
    description: SPARQL Query and Update execution
  - name: Namespaces
    description: Namespaces management
  - name: Graph Store
    description: |
      The [SPARQL 1.1 Graph Store HTTP Protocol](https://www.w3.org/TR/sparql11-http-rdf-update/) is supported on a per-repository basis. The functionality is accessible at the /repositories/<ID>/rdf-graphs/service endpoint (for indirectly referenced named graphs), and at /repositories/<ID>/rdf-graphs/<NAME> for directly referenced named graphs. A request on a directly referenced named graph entails that the request URL itself is used as the named graph identifier in the repository.
    externalDocs:
      url: https://www.w3.org/TR/sparql11-http-rdf-update/
  - name: Transactions
    description: |
      RDF4J supports a REST-styleimplementation of a transactional protocol, by means of treating the transaction itself as a new resource that can be updated with consecutive operations. A transaction is started by a POST request to the transactions endpoint, which will return a new unique endpoint location for the new transaction. Operations (such as adding data, querying, committing/rolling back the transaction) are executed by means of PUT requests of consecutive operations against that unique transaction endpoint.
    externalDocs:
      url: https://rdf4j.org/documentation/programming/repository/#transactions
  - name: Protocol
    description: Protocol verification

components:
  requestBodies:
    RdfData:
      description: RDF data payload
      content:
        application/rdf+xml:
          schema:
            type: object
            xml:
              name: RDF
              namespace: http://www.w3.org/1999/02/22-rdf-syntax-ns#
        text/plain:
          schema:
            type: string
        text/turtle:
          schema:
            type: string
        text/rdf+n3:
          schema:
            type: string
        text/x-nquads:
          schema:
            type: string
        application/ld+json:
          schema:
            type: object
            format: json
        application/rdf+json:
          schema:
            type: object
            format: json
        application/trix:
          schema:
            type: object
            xml:
              name: TriX
        application/x-trig:
          schema:
            type: string
        application/x-binary-rdf:
          schema:
            type: string
            format: binary
  responses:
    200QueryResult:
      description: |
        SPARQL query result. If the `explain` parameter is supplied, the response is a query explanation instead: the
        server supports `text/plain` and `application/json` for explanations.
      content:
        application/sparql-results+xml:
          schema:
            type: object
            xml:
              name: sparql
              namespace: http://www.w3.org/2005/sparql-results#
          examples:
            SelectQueryResult:
              $ref: "#/components/examples/SparqlXmlBindings"
            AskQueryResult:
              $ref: "#/components/examples/SparqlXmlBoolean"
        application/x-binary-rdf-results-table:
          schema:
            type: string
            format: binary
        application/sparql-results+json:
          examples:
            SelectQueryResult:
              $ref: "#/components/examples/SparqlJsonBindings"
            AskQueryResult:
              $ref: "#/components/examples/SparqlJsonBoolean"
        text/boolean:
          schema:
            type: string
            format: boolean
          example:
            true
        application/rdf+xml:
          schema:
            type: object
            xml:
              name: RDF
              namespace: http://www.w3.org/1999/02/22-rdf-syntax-ns#
        text/plain:
          schema:
            type: string
            description: A plain-text RDF result or query explanation, depending on the request.
        application/json:
          schema:
            type: object
            description: A JSON query explanation returned when the `explain` parameter is supplied.
        text/turtle:
          schema:
            type: string
        text/rdf+n3:
          schema:
            type: string
        text/x-nquads:
          schema:
            type: string
        application/ld+json:
          schema:
            type: object
            format: json
        application/rdf+json:
          schema:
            type: object
            format: json
        application/trix:
          schema:
            type: object
            xml:
              name: TriX
        application/x-trig:
          schema:
            type: string
        application/x-binary-rdf:
          schema:
            type: string
            format: binary
    200RdfData:
      description: RDF data result
      content:
        application/rdf+xml:
          schema:
            type: object
            xml:
              name: RDF
              namespace: http://www.w3.org/1999/02/22-rdf-syntax-ns#
        text/plain:
          schema:
            type: string
        text/turtle:
          schema:
            type: string
        text/rdf+n3:
          schema:
            type: string
        text/x-nquads:
          schema:
            type: string
        application/ld+json:
          schema:
            type: object
            format: json
        application/rdf+json:
          schema:
            type: object
            format: json
        application/trix:
          schema:
            type: object
            xml:
              name: TriX
        application/x-trig:
          schema:
            type: string
        application/x-binary-rdf:
          schema:
            type: string
            format: binary

  examples:
    SparqlXmlBindings:
      value: |
        <?xml version='1.0' encoding='UTF-8'?>
        <sparql xmlns='http://www.w3.org/2005/sparql-results#'>
          <head>
            <variable name='s'/>
            <variable name='p'/>
            <variable name='o'/>
          </head>
          <results ordered='false' distinct='false'>
            <result>
              <binding name='s'>
                <uri>http://example.org/s1</uri>
              </binding>
              <binding name='p'>
                <uri>http://example.org/p1</uri>
              </binding>
              <binding name='o'>
                <literal>foo</literal>
              </binding>
            </result>
          </results>
        </sparql>
    SparqlXmlBoolean: 
      value: |
        <?xml version="1.0"?>
        <sparql xmlns="http://www.w3.org/2005/sparql-results#">
          <head>
          </head>
          <boolean>true</boolean>
        </sparql>
    SparqlJsonBindings:
      value:
        head:
          vars: [ "s", "p", "o" ]
          results:
            bindings:
              - s:
                  type: "uri"
                  value: "http://example.org/s1"
              - p:
                  type: "uri"
                  value: "http://example.org/p1"
              - o:
                  type: "literal"
                  value: "foo"
    SparqlJsonBoolean:
      value:
        head: {}
        boolean: true

paths:
  /protocol:
    get:
      tags:
        - Protocol
      summary: Fetch the protocol version
      description: The version of the protocol that the server uses to communicate over HTTP.
      responses:
        '200':
          description: The protocol version
          content:
            text/plain:
              schema:
                type: integer
                format: int32
              example: 10

  /repositories:
    get:
      tags:
        - Repositories
      summary: Retrieve a list of Repositories
      description: |
        Get a list of available Repositories, including ID, title, read- and write access parameters for each listed repository. The list is formatted as a tuple query result with variables 'uri', 'id', 'title', 'readable' and 'writable'. The 'uri' value gives the location of the repository and the 'readable' and 'writable' values are boolean typed literals indicating read- and write permissions.
      parameters:
        - name: Accept
          in: header
          schema:
            type: string
          example: application/sparql-results+xml, */*;q=0.5
      responses:
        '200':
          description: Repository list
          content:
            application/sparql-results+xml:
              schema:
                type: object
                xml:
                  name: sparql
                  namespace: http://www.w3.org/2005/sparql-results#
              example: |
                <?xml version='1.0' encoding='UTF-8'?>
                <sparql xmlns='http://www.w3.org/2005/sparql-results#'>
                  <head>
                    <variable name='uri'/>
                    <variable name='id'/>
                    <variable name='title'/>
                    <variable name='readable'/>
                    <variable name='writable'/>
                  </head>
                  <results ordered='false' distinct='false'>
                    <result>
                      <binding name='uri'>
                        <uri>http://localhost:8080/rdf4j-server/repositories/mem-rdf</uri>
                      </binding>
                      <binding name='id'>
                        <literal>mem-rdf</literal>
                      </binding>
                      <binding name='title'>
                        <literal>Main Memory RDF repository</literal>
                      </binding>
                      <binding name='readable'>
                        <literal datatype='http://www.w3.org/2001/XMLSchema#boolean'>true</literal>
                      </binding>
                      <binding name='writable'>
                        <literal datatype='http://www.w3.org/2001/XMLSchema#boolean'>false</literal>
                      </binding>
                    </result>
                  </results>
                </sparql>
            application/x-binary-rdf-results-table:
              schema:
                type: string
                format: binary
            application/sparql-results+json:
              schema:
                type: object
                format: json

  /repositories/{repositoryID}:
    get:
      tags:
        - SPARQL
      summary: Execute SPARQL query
      description: |
        Execute a SPARQL query on the repository. The result format is based on the type of result (boolean, variable bindings, or RDF data) and the negotiated acceptable content-type. Note that RDF4J supports executing SPARQL queries with either a GET or a POST request. POST is supported for queries that are too large to be encoded as a query parameter.

        Supplying `explain` returns a query explanation instead of query results. The explanation level is case-sensitive.
        `Unoptimized` and `Optimized` describe the parsed or optimized plan; `Executed` and `Timed` execute the query to
        include execution information. Use `Accept=application/json` or `Accept=text/plain` to select the explanation
        representation; this query parameter takes precedence over the HTTP `Accept` header. Without an `Accept`
        parameter or header, the server prefers `text/plain`.

        A client-generated nonblank `query-request-id` enables cancellation of this non-transactional regular query.
        A separate nonblank `explain-request-id` enables cancellation of an explanation request. These identifiers are
        different namespaces and must not be used interchangeably. Cancellation is sent as a separate `POST` request;
        see the POST operation below.
      parameters:
        - name: repositoryID
          in: path
          description: The repository ID
          required: true
          schema:
            type: string
        - name: query
          in: query
          description: The query to evaluate
          required: true
          schema:
            type: string
            example: select * where {?s ?p ?o} limit 10
        - name: queryLn
          in: query
          description: Specifies the query language that is used for the query. Acceptable values are strings denoting the query languages supported by the server, i.e. 'sparql' for SPARQL queries. If not specified, the server assumes the query is a SPARQL query
          required: false
          schema:
            type: string
        - name: infer
          in: query
          description: Specifies whether inferred statements should be included in the query evaluation. Inferred statements are included by default if they are available in the repository. Specifying any value other than 'true' (ignoring case) restricts the query evluation to explicit statements only.
          required: false
          schema:
            type: boolean
        - name: $<varname>
          in: query
          required: false
          description: Specifies variable bindings. Variables appearing in the query can be bound to a specific value outside the actual query using this option. The value should be an N-Triples encoded RDF value.
          schema:
            type: string
        - name: timeout
          in: query
          required: false
          description: Specifies a maximum query execution time, in whole seconds. The value should be an integer. A setting of 0 or a negative number indicates unlimited query time (the default).
          schema:
            type: integer
        - name: distinct
          in: query
          required: false
          description: Specifies if only distinct query solutions should be returned. The value should be true or false. If the supplied SPARQL query itself already has a DISTINCT modifier, this parameter will have no effect.
          schema:
            type: boolean
        - name: limit
          in: query
          required: false
          description: Specifies the maximum number of query solutions to return. The value should be a positive integer. If the supplied SPARQL query itself already has a LIMIT modifier, this parameter will only have an effect if the supplied value is lower than the LIMIT value in the query.
          schema:
            type: integer
        - name: offset
          in: query
          required: false
          description: Specifies the number of query solutions to skip. The value should be a positive integer. This parameter is cumulative with any OFFSET modifier in the supplied SPARQL query itself.
          schema:
            type: integer
        - name: explain
          in: query
          required: false
          description: |
            The level of explanation to return. If specified, the server will return an explanation of the query execution plan. The value should be one of the following:
            - `Unoptimized`: Simple parsed plan
            - `Optimized`: Parsed and optimized plan, including cost estimation
            - `Executed`: Plan as it was executed, including actual result size
            - `Timed`: Executed plan with timing details for each node
          schema:
            type: string
            enum:
              - Unoptimized
              - Optimized
              - Executed
              - Timed
        - name: query-request-id
          in: query
          required: false
          description: |
            A client-generated nonblank identifier for this non-transactional regular query. Reuse the same value in a
            later `POST` with `cancel-query=true` to request cancellation. Do not use this parameter for explanations;
            use `explain-request-id` instead.
          schema:
            type: string
            minLength: 1
        - name: explain-request-id
          in: query
          required: false
          description: |
            A client-generated nonblank identifier for this non-transactional query explanation. Supply it together
            with `explain`, then use the same value in a later `POST` with `cancel-explain=true` to request cancellation.
            Tracked explanations are not supported for transaction requests.
          schema:
            type: string
            minLength: 1
        - name: Accept
          in: query
          required: false
          description: |
            For query explanations, selects the representation and overrides the HTTP `Accept` header. The server
            accepts `text/plain` and `application/json` for explanations. This parameter is case-sensitive in the RDF4J
            protocol.
          schema:
            type: string
        - name: Accept
          in: header
          required: false
          description: The preferred response media type. For explanations, use `text/plain` or `application/json`.
          schema:
            type: string
      responses:
        '200':
          $ref: "#/components/responses/200QueryResult"
        '400':
          description: |
            Invalid request, such as an invalid explanation level, an unsupported `Accept` query parameter, or a
            missing query parameter.
        '406':
          description: No acceptable explanation representation was selected by the HTTP `Accept` header.
    post:
      tags:
        - SPARQL
      summary: Execute or cancel a SPARQL query
      description: |
        Execute a SPARQL query on the repository. The result format is based on the type of result (boolean, variable bindings, or RDF data) and the negotiated acceptable content-type. Note that RDF4J supports executing SPARQL queries with either a GET or a POST request. POST is supported for queries that are too large to be encoded as a query parameter.

        A `POST` with neither cancellation flag executes the query. A `POST` with `cancel-query=true` and a
        `query-request-id` requests cancellation of a non-transactional regular query. A `POST` with
        `cancel-explain=true` and an `explain-request-id` requests cancellation of a non-transactional query
        explanation. Cancellation requests may be bodyless: no query text is required, and the identifier may be supplied
        in the URL or in an `application/x-www-form-urlencoded` body. Use only one cancellation flag and its matching
        identifier namespace.

        A cancellation response of `204` means that the active operation accepted cancellation. `404` means that this
        server has no matching active operation, including when it has already completed, has not registered yet, or is
        handled by another server instance. `502` means that cancellation forwarding to an HTTP-backed repository
        failed. The cancellation registry is local to a server instance, so clients using load balancing should route
        cancellation to the query owner or retry boundedly. Connection cleanup may continue after a `204` response.

        Request IDs are scoped to this repository on this server instance. Generate a fresh nonblank UUID for each
        tracked request; blank cancellation IDs are invalid and an ID already active in the same namespace is rejected
        with HTTP 400. A regular query without a client ID receives an internal server ID and cannot be cancelled by
        the client by ID; automatic disconnect cancellation still applies.

        Supplying `explain` returns a query explanation. The explanation level is case-sensitive. `Unoptimized` and
        `Optimized` describe the parsed or optimized plan; `Executed` and `Timed` execute the query to include execution
        information. The server supports only `text/plain` and `application/json` for explanations; `Accept` as a query
        parameter takes precedence over the HTTP `Accept` header. For example, a raw SPARQL body can request an
        explanation with `POST /repositories/myrepo?explain=Optimized&Accept=application/json&explain-request-id=<id>`.
        A bodyless cancellation can be sent as `POST /repositories/myrepo?cancel-query=true&query-request-id=<id>`
        or with the equivalent form fields shown in the named examples below.
      parameters:
        - name: repositoryID
          in: path
          description: The repository ID
          required: true
          schema:
            type: string
        - name: query
          in: query
          required: false
          description: FORM POST requests only. The SPARQL query to evaluate when it is supplied as a URL parameter instead of in the form body.
          schema:
            type: string
        - name: queryLn
          in: query
          required: false
          description: FORM POST requests only. The query language used for the query. If omitted, the server assumes SPARQL.
          schema:
            type: string
        - name: explain
          in: query
          required: false
          description: |
            QUERY requests only. The explanation level to return instead of query results. The value is case-sensitive.
            `Executed` and `Timed` evaluate the query to include execution information.
          schema:
            type: string
            enum:
              - Unoptimized
              - Optimized
              - Executed
              - Timed
        - name: query-request-id
          in: query
          required: false
          description: |
            A client-generated nonblank identifier for a non-transactional regular query, or the identifier to cancel
            when `cancel-query=true`. Do not combine it with `explain`; use `explain-request-id` for explanations.
          schema:
            type: string
            minLength: 1
        - name: explain-request-id
          in: query
          required: false
          description: |
            A client-generated nonblank identifier for a non-transactional explanation, or the identifier to cancel
            when `cancel-explain=true`. Tracked explanations are not supported for transaction requests.
          schema:
            type: string
            minLength: 1
        - name: cancel-query
          in: query
          required: false
          description: |
            Set to `true` to cancel the active regular query identified by `query-request-id`. No query body is
            required for cancellation.
          schema:
            type: string
            enum:
              - "true"
        - name: cancel-explain
          in: query
          required: false
          description: |
            Set to `true` to cancel the active explanation identified by `explain-request-id`. No query body is
            required for cancellation.
          schema:
            type: string
            enum:
              - "true"
        - name: Accept
          in: query
          required: false
          description: |
            For query explanations, selects `text/plain` or `application/json` and overrides the HTTP `Accept`
            header. For ordinary queries, any media type supported by the selected result writer is allowed. This
            parameter is case-sensitive in the RDF4J protocol.
          schema:
            type: string
        - name: Accept
          in: header
          required: false
          description: The preferred response media type. For explanations, use `text/plain` or `application/json`.
          schema:
            type: string
      requestBody:
        description: |
          Optional for cancellation requests, which do not require a query body. Required for ordinary query
          execution unless the query is supplied as a URL parameter. For a form request, `query` is the query text;
          other parameters may be supplied in the URL or form body.
        required: false
        content:
          application/sparql-query:
            schema:
              type: string
            examples:
              trackedExplanation:
                summary: Tracked optimized explanation with a raw SPARQL body
                description: Put `explain=Optimized` and `explain-request-id` in the URL query string.
                value: "SELECT * WHERE {?S ?P ?O } LIMIT 10"
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                query:
                  type: string
                  description: The SPARQL query to execute.
                queryLn:
                  type: string
                query-request-id:
                  type: string
                  minLength: 1
                explain:
                  type: string
                  enum:
                    - Unoptimized
                    - Optimized
                    - Executed
                    - Timed
                explain-request-id:
                  type: string
                  minLength: 1
                Accept:
                  type: string
                  description: For explanation responses, use text/plain or application/json. Ordinary query responses may use any supported result media type.
                cancel-query:
                  type: string
                  enum:
                    - "true"
                cancel-explain:
                  type: string
                  enum:
                    - "true"
              additionalProperties: true
            examples:
              trackedExplanation:
                summary: Tracked optimized explanation as a form request
                value:
                  query: SELECT * WHERE {?S ?P ?O } LIMIT 10
                  explain: Optimized
                  explain-request-id: explanation-550e8400-e29b-41d4-a716-446655440000
                  Accept: application/json
              trackedQuery:
                summary: Tracked regular query as a form request
                value:
                  query: SELECT * WHERE {?S ?P ?O } LIMIT 10
                  query-request-id: query-550e8400-e29b-41d4-a716-446655440000
                  Accept: application/sparql-results+json
              cancelQuery:
                summary: Regular-query cancellation form
                description: No `query` field is required; only the matching cancellation flag and request ID are sent.
                value:
                  cancel-query: "true"
                  query-request-id: query-550e8400-e29b-41d4-a716-446655440000
              cancelExplanation:
                summary: Explanation cancellation form
                description: No `query` field is required; use the explanation request-ID namespace.
                value:
                  cancel-explain: "true"
                  explain-request-id: explanation-550e8400-e29b-41d4-a716-446655440000
      responses:
        '200':
          $ref: "#/components/responses/200QueryResult"
        '204':
          description: |
            Cancellation accepted for the matching active regular query or explanation. The response has no body;
            connection cleanup may still be in progress.
        '400':
          description: |
            Invalid request, such as a missing or blank cancellation identifier, an invalid explanation level, an
            unsupported `Accept` query parameter, or a duplicate active request identifier.
        '404':
          description: No matching active query or explanation is registered on this server instance for this repository.
        '406':
          description: No acceptable explanation representation was selected by the HTTP `Accept` header.
        '502':
          description: Cancellation forwarding to an HTTP-backed repository failed; the cancellation may be retried.
    delete:
      tags:
        - Repositories
      summary: Repository removal
      description: "Delete a specific repository by ID. Care should be taken with the use of this method: the result of this operation is the complete removal of the repository from the server, including its configuration settings and (if present) data directory"
      parameters:
        - name: repositoryID
          in: path
          required: true
          description: The repository ID
          schema:
            type: string
      responses:
        204:
          description: The repository was deleted
    put:
      tags:
        - Repositories
      summary: Repository creation
      parameters:
        - name: repositoryID
          in: path
          description: The repository ID
          required: true
          schema:
            type: string
      description: |
        A new repository with can be created on the server by sending a PUT request to this endpoint.

        The payload supplied with this request is an RDF document, containing an RDF-serialized form of a repository configuration. If the repository with the specified id previously existed, the Server will refuse the request. If it does not exist, a new, empty, repository will be created.
      requestBody:
        description: configuration of the repository to be created
        required: true
        $ref: "#/components/requestBodies/RdfData"
      responses:
        '204':
          description: created

  /repositories/{repositoryID}/statements:
    get:
      tags:
        - Repositories
      summary: Fetch statements from the repository.
      description: Get RDF statements from the repository matching the filtering parameters
      parameters:
        - name: repositoryID
          in: path
          required: true
          description: The repository ID
          schema:
            type: string
        - name: subj
          in: query
          description: Restricts the operation to statements with the specified N-Triples encoded resource as subject.
          schema:
            type: string
        - name: pred
          in: query
          description: Restricts the operation to statements with the specified N-Triples encoded URI as predicate.
          schema:
            type: string
        - name: obj
          in: query
          description: Restricts the operation to statements with the specified N-Triples encoded value as object.
          schema:
            type: string
        - name: context
          in: query
          description: If specified, restricts the operation to one or more specific contexts in the repository. The value of this parameter is either an N-Triples encoded URI or bnode ID, or the special value 'null' which represents all context-less statements. If multiple 'context' parameters are specified, the request will operate on the union of all specified contexts. The operation is executed on all statements that are in the repository if no context is specified.
          schema:
            type: string
        - name: infer
          in: query
          description: Specifies whether inferred statements should be included in the result of GET requests. Inferred statements are included by default. Specifying any value other than 'true' (ignoring case) restricts the request to explicit statements only.
          schema:
            type: string
      responses:
        '200':
          $ref: "#/components/responses/200RdfData"

    delete:
      tags:
        - Repositories
      summary: Delete statements from the repository.
      description: Deletes statements from the repository matching the filtering parameters
      parameters:
        - name: repositoryID
          in: path
          required: true
          description: The repository ID
          schema:
            type: string
        - name: subj
          in: query
          description: Restricts the operation to statements with the specified N-Triples encoded resource as subject.
          schema:
            type: string
        - name: pred
          in: query
          description: Restricts the operation to statements with the specified N-Triples encoded URI as predicate.
          schema:
            type: string
        - name: obj
          in: query
          description: Restricts the operation to statements with the specified N-Triples encoded value as object.
          schema:
            type: string
        - name: context
          in: query
          description: If specified, restricts the operation to one or more specific contexts in the repository. The value of this parameter is either an N-Triples encoded URI or bnode ID, or the special value 'null' which represents all context-less statements. If multiple 'context' parameters are specified, the request will operate on the union of all specified contexts. The operation is executed on all statements that are in the repository if no context is specified.
          schema:
            type: string
      responses:
        '204':
          description: The statements were successfully deleted

    put:
      tags:
        - Repositories
      summary: Replace data in the repository
      description: Update data in the repository, replacing any existing data with the supplied data
      parameters:
        - name: repositoryID
          in: path
          required: true
          description: The repository ID
          schema:
            type: string
        - name: context
          in: query
          description: If specified, restricts the operation to one or more specific contexts in the repository. The value of this parameter is either an N-Triples encoded URI or bnode ID, or the special value 'null' which represents all context-less statements. If multiple 'context' parameters are specified, the request will operate on the union of all specified contexts. The operation is executed on all statements that are in the repository if no context is specified.
          schema:
            type: string
        - name: baseURI
          in: query
          description: Specifies the base URI to resolve any relative URIs found in uploaded data against
          schema:
            type: string
      requestBody:
        description: RDF data to be added, replacing any existing data.
        required: true
        $ref: "#/components/requestBodies/RdfData"
      responses:
        204:
          description: The data was successfully updated

    post:
      tags:
        - SPARQL
      summary: Execute SPARQL update or upload data.
      description: |
        Update the data in the repository. The data supplied with this request is expected to contain either a [SPARQL 1.1 Update](https://www.w3.org/TR/sparql11-update/) string, an RDF document, or a special purpose transaction document. If a SPARQL 1.1 Update string is supplied, the update operation will be parsed and executed. If an RDF document is supplied, the statements found in the RDF document will be added to the repository. If a transaction document is supplied, the updates specified in the transaction document will be executed.
      parameters:
        - name: repositoryID
          in: path
          required: true
          description: The repository ID
          schema:
            type: string
        - name: baseURI
          in: query
          description: Specifies the base URI to resolve any relative URIs found in uploaded data against.
          schema:
            type: string
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                update:
                  type: string
            example:
              update: INSERT {?s ?p ?o} WHERE {?s ?p ?o}
          application/sparql-update:
            schema:
              type: string
            example: INSERT {?s ?p ?o} WHERE {?s ?p ?o}
          application/rdf+xml:
            schema:
              type: object
              xml:
                name: RDF
                namespace: http://www.w3.org/1999/02/22-rdf-syntax-ns#
          text/plain:
            schema:
              type: string
          text/turtle:
            schema:
              type: string
          text/rdf+n3:
            schema:
              type: string
          text/x-nquads:
            schema:
              type: string
          application/ld+json:
            schema:
              type: object
              format: json
          application/rdf+json:
            schema:
              type: object
              format: json
          application/trix:
            schema:
              type: object
              xml:
                name: TriX
          application/x-trig:
            schema:
              type: string
          application/x-binary-rdf:
            schema:
              type: string
              format: binary
          application/x-rdftransaction:
            schema:
              type: string
      responses:
        204:
          description: The data was seccussfully updated

  /repositories/{repositoryID}/size:
    get:
      tags:
        - Repositories
      summary: Repository size
      description: The endpoint will give you the number of statements in the repository or in the specified context
      parameters:
        - name: repositoryID
          in: path
          required: true
          description: The repository ID
          schema:
            type: string
        - name: context
          in: query
          schema:
            type: string
          description: If specified, restricts the operation to one or more specific contexts in the repository. The value of this parameter is either an N-Triples encoded URI or bnode ID, or the special value 'null' which represents all context-less statements. If multiple 'context' parameters are specified, the request will operate on the union of all specified contexts. The operation is executed on all statements that are in the repository if no context is specified.
      responses:
        200:
          description: Get the size of (the contexts in) the specified repository.
          content:
            text/plain:
              schema:
                type: string
                format: number
              example: 42

  /repositories/{repositoryID}/contexts:
    get:
      tags:
        - Repositories
      summary: Retrieve context identifiers in the repository.
      description: Get a list of all context identifiers in the repository. The list is formatted as a tuple query result with a single variable “contextID”, which is bound to URIs and blank nodes that are used as context identifiers.
      parameters:
        - name: repositoryID
          in: path
          required: true
          description: The repository ID
          schema:
            type: string
      responses:
        200:
          description: List of contexts encoded as tuple query result.
          content:
            application/sparql-results+xml:
              schema:
                type: object
                xml:
                  name: sparql
                  namespace: http://www.w3.org/2005/sparql-results#
              example: |
                <?xml version='1.0' encoding='UTF-8'?>
                <sparql xmlns='http://www.w3.org/2005/sparql-results#'>
                  <head>
                    <variable name='contextID'/>
                  </head>
                  <results ordered='false' distinct='false'>
                    <result>
                      <binding name='contextID'>
                        <uri>urn:x-local:graph1</uri>
                      </binding>
                    </result>
                  </results>
                </sparql>
            application/x-binary-rdf-results-table:
              schema:
                type: string
                format: binary
            application/sparql-results+json:
              schema:
                type: object
                format: json

  /repositories/{repositoryID}/namespaces:
    get:
      tags:
        - Namespaces
      summary: Retrieve namespaces
      description: Fetch all namespace declaration info available in the repository
      parameters:
        - name: repositoryID
          in: path
          required: true
          description: The repository ID
          schema:
            type: string
      responses:
        200:
          description: List of namespaces encoded as tuple query result.
          content:
            application/sparql-results+xml:
              schema:
                type: object
                xml:
                  name: sparql
                  namespace: http://www.w3.org/2005/sparql-results#
              example: |
                <?xml version='1.0' encoding='UTF-8'?>
                <sparql xmlns='http://www.w3.org/2005/sparql-results#'>
                  <head>
                    <variable name='prefix'/>
                    <variable name='namespace'/>
                  </head>
                  <results ordered='false' distinct='false'>
                    <result>
                      <binding name='prefix'>
                        <literal>rdf</literal>
                      </binding>
                      <binding name='namespace'>
                        <literal>http://www.w3.org/1999/02/22-rdf-syntax-ns#</literal>
                      </binding>
                    </result>
                  </results>
                </sparql>
            application/x-binary-rdf-results-table:
              schema:
                type: string
                format: binary
            application/sparql-results+json:
              schema:
                type: object
                format: json
    delete:
      tags:
        - Namespaces
      summary: Clear all namespaces
      description: Remove all namespace declarations from the repository
      parameters:
        - name: repositoryID
          in: path
          required: true
          description: The repository ID
          schema:
            type: string
      responses:
        204:
          description: All namespaces were removed

  /repositories/{repositoryID}/namespaces/{namespacesPrefix}:
    get:
      tags:
        - Namespaces
      summary: Get namespace by prefix
      description: Gets the namespace that has been defined for a particular prefix.
      parameters:
        - name: repositoryID
          in: path
          required: true
          description: The repository ID
          schema:
            type: string
        - name: namespacesPrefix
          in: path
          required: true
          description: URI prefix of a RDF resource
          schema:
            type: string
      responses:
        200:
          description: The defined namespace of the given prefix.
          content:
            text/plain:
              schema:
                type: string
              example: http://www.example.com
    put:
      tags:
        - Namespaces
      summary: Set namespace for a particular prefix
      description: Sets a new namespace for a particular prefix. If the prefix was previously mapped to a different namespace, this will be overwritten.
      parameters:
        - name: repositoryID
          in: path
          required: true
          description: The repository ID
          schema:
            type: string
        - name: namespacesPrefix
          in: path
          required: true
          description: URI prefix of a RDF resource
          schema:
            type: string
          example: ex
      requestBody:
        content:
          text/plain:
            schema:
              type: string
            example: http://www.example.com
      responses:
        204:
          description: The defined namespace was successfully set to the given prefix.
    delete:
      tags:
        - Namespaces
      summary: Remove namespace for a particular prefix
      description: Removes the namespace that has been defined for a particular prefix.
      parameters:
        - name: repositoryID
          in: path
          required: true
          description: The repository ID
          schema:
            type: string
        - name: namespacesPrefix
          in: path
          required: true
          description: URI prefix of a RDF resource
          schema:
            type: string
      responses:
        204:
          description: The defined namespace with the given prefix was successfully removed.

  /repositories/{repositoryID}/rdf-graphs/{graph}:
    get:
      tags:
        - Graph Store
      summary: Fetch all statements
      description: Fetch all statements from a directly referenced named graph.
      parameters:
        - name: repositoryID
          in: path
          required: true
          description: The repository ID
          schema:
            type: string
        - name: graph
          in: path
          required: true
          description: URL path part uniquely identifying a named graph. The entire request url is read as a named graph.
          schema:
            type: string
      responses:
        200:
          $ref: "#/components/responses/200RdfData"
    post:
      tags:
        - Graph Store
      summary: Add statements
      description: Add statements to a directly referenced named graph.
      parameters:
        - name: repositoryID
          in: path
          required: true
          description: The repository ID
          schema:
            type: string
        - name: graph
          in: path
          required: true
          description: URL path part uniquely identifying a named graph. The entire request url is read as a named graph.
          schema:
            type: string
      requestBody:
        $ref: "#/components/requestBodies/RdfData"
      responses:
        204:
          description: The data was successfully updated

    delete:
      tags:
        - Graph Store
      summary: Clear a directly referenced named graph
      description: Clear a directly referenced named graph.
      parameters:
        - name: repositoryID
          in: path
          required: true
          description: The repository ID
          schema:
            type: string
        - name: graph
          in: path
          required: true
          description: URL path part uniquely identifying a named graph. The entire request url is read as a named graph.
          schema:
            type: string
      responses:
        204:
          description: Successfully cleared the defined named graph

  /repositories/{repositoryID}/rdf-graphs/service:
    get:
      tags:
        - Graph Store
      summary: Get statements from an indirectly referenced named graph
      description: Fetch all statements from an indirectly referenced named graph.
      parameters:
        - name: repositoryID
          in: path
          required: true
          description: The repository ID
          schema:
            type: string
        - name: graph
          in: query
          required: false
          description: Indirectly referenced named graph name. The named graph URI is the value of this parameter.
          schema:
            type: string
        - name: default
          in: query
          required: false
          allowEmptyValue: true
          description: Default named graph.
          schema:
            type: string
      responses:
        200:
          $ref: "#/components/responses/200RdfData"

  /repositories/{repositoryID}/transactions:
    post:
      tags:
        - Transactions
      summary: Start a new transaction
      description: |
        RDF4J supports a RESTful implementation of a transactional protocol, by means of treating the transaction itself as a new resource that can be updated with consecutive operations. A transaction is started by a POST request to the transactions endpoint, which will return a new unique endpoint location for the new transaction. Operations (such as adding data, querying, committing/rolling back the transaction) are executed by means of PUT requests of consecutive operations against that unique transaction endpoint.
      parameters:
        - name: repositoryID
          in: path
          required: true
          description: The repository ID
          schema:
            type: string
          example: myDB
      responses:
        201:
          description: Started
          headers:
            Location:
              description: URL of the newly created transaction resource
              schema:
                type: string
              example: /rdf4j-server/repositories/myDB/transactions/64a5937f-c112-d014-a044-f0123b93

  /repositories/{repositoryID}/transactions/{transactionID}:
    put:
      tags:
        - Transactions
      summary: Execute a transaction action
      description: |
        Transaction operations are carried on this endpoint. The full URI is the exact value of the Location header as returned by the request to start a transaction.

        A QUERY action may include `explain=Unoptimized`, `Optimized`, `Executed`, or `Timed` to return an
        untracked query explanation. The level names are case-sensitive; `Executed` and `Timed` evaluate the query.
        Transaction queries do not support tracked explanations or cancellation. `query-request-id`, `cancel-query`,
        and `cancel-explain` are rejected with HTTP 400. A nonblank `explain-request-id` is rejected with HTTP 400
        when `explain` is supplied; transaction explanations are otherwise untracked and cannot be cancelled.
        For an explanation, the `Accept` query parameter selects `text/plain` or `application/json` and takes
        precedence over the HTTP `Accept` header. The parameter name is case-sensitive (`Accept`).
      parameters:
        - name: repositoryID
          in: path
          required: true
          description: The repository ID
          schema:
            type: string
        - name: transactionID
          in: path
          required: true
          description: The transaction ID
          schema:
            type: string
        - name: action
          in: query
          required: true
          schema:
            type: string
            enum:
              [ ADD, DELETE, GET, QUERY, UPDATE, SIZE, COMMIT, PING ]
          description: |
            Specifies the type of operation being carried on the transaction.
        - name: subj
          in: query
          required: false
          description: GET actions only. Restricts the operation to statements with the specified N-Triples encoded resource as subject.
          schema:
            type: string
        - name: pred
          in: query
          required: false
          description: GET actions only. Restricts the operation to statements with the specified N-Triples encoded resource as predicate.
          schema:
            type: string
        - name: obj
          in: query
          required: false
          description: GET actions only. Restricts the operation to statements with the specified N-Triples encoded resource as object.
          schema:
            type: string
        - name: query
          in: query
          required: false
          description: QUERY actions only. Specifies the SPARQL query to evaluate.
          schema:
            type: string
        - name: queryLn
          in: query
          required: false
          description: QUERY actions only. Specifies the query language that is used for the query. Acceptable values are strings denoting the query languages supported by the server, i.e 'sparql' for SPARQL queries. If not specified, the server assumes the query is a SPARQL query.
          schema:
            type: string
        - name: explain
          in: query
          required: false
          description: QUERY actions only. Requests an untracked query explanation. Values are case-sensitive and must be Unoptimized, Optimized, Executed, or Timed. Executed and Timed evaluate the query.
          schema:
            type: string
            enum: [ Unoptimized, Optimized, Executed, Timed ]
        - name: Accept
          in: query
          required: false
          description: QUERY actions with `explain` only. Selects `text/plain` or `application/json` for explanations and overrides the HTTP Accept header. For ordinary transaction results, any supported media type is allowed. The parameter name is case-sensitive.
          schema:
            type: string
        - name: Accept
          in: header
          required: false
          description: QUERY actions with `explain` only. Selects the explanation representation when no `Accept` query parameter is supplied.
          schema:
            type: string
        - name: infer
          in: query
          required: false
          description: GET and QUERY actions only. Specifies whether inferred statements should be included in the result. Inferred statements are included by default (if available in the repository). Specifying any value other than 'true' (ignoring case) restricts the result to explicit statements only.
          schema:
            type: boolean
        - name: update
          in: query
          required: false
          description: UPDATE actions only. Specifies the SPARQL 1.1 Update operation to be executed. The value is expected to be a syntactically valid SPARQL 1.1 Update string.
          schema:
            type: string
        - name: baseURI
          in: query
          required: false
          description: UPDATE, DELETE, and ADD actions only. Specifies a base URI to be used for executing the operation.
          schema:
            type: string
        - name: using-graph-uri
          in: query
          required: false
          description: UPDATE actions only. One or more named graph URIs to be used as the default graph(s) for retrieving statements.
          schema:
            type: boolean
        - name: using-named-graph-uri
          in: query
          required: false
          description: UPDATE actions only. One or more named graph URIs to be used as named graphs for retrieving statements.
          schema:
            type: boolean
        - name: remove-graph-uri
          in: query
          required: false
          description: UPDATE actions only. One or more named graph URIs to be used as the default graph(s) for removing statements.
          schema:
            type: boolean
        - name: insert-graph-uri
          in: query
          required: false
          description: UPDATE actions only. One or more named graph URIs to be used as the default graph(s) for inserting statements.
          schema:
            type: boolean
      requestBody:
        description: |
          RDF Data payload. Only relevant for ADD actions.
        content:
          application/rdf+xml:
            schema:
              type: object
              xml:
                name: RDF
                namespace: http://www.w3.org/1999/02/22-rdf-syntax-ns#
          text/plain:
            schema:
              type: string
          text/turtle:
            schema:
              type: string
          text/rdf+n3:
            schema:
              type: string
          text/x-nquads:
            schema:
              type: string
          application/ld+json:
            schema:
              type: object
              format: json
          application/rdf+json:
            schema:
              type: object
              format: json
          application/trix:
            schema:
              type: object
              xml:
                name: TriX
          application/x-trig:
            schema:
              type: string
          application/x-binary-rdf:
            schema:
              type: string
              format: binary
      responses:
        200:
          description: |
            OK. The response depends on the transaction action. For a QUERY action with `explain`, the result is an
            untracked explanation; the conditional explanation representations are documented below. Other actions
            retain their normal transaction result semantics.
          content:
            text/plain:
              schema:
                type: string
                description: Returned for QUERY with `explain` when the selected explanation representation is text/plain.
            application/json:
              schema:
                type: object
                description: Returned for QUERY with `explain` when the selected explanation representation is application/json.
            "*/*":
              schema:
                description: Other transaction actions and ordinary query results use their action-specific supported representation.
        204:
          description: No content
        400:
          description: |
            Invalid transaction QUERY parameters, including an unsupported explanation level or `Accept` query
            parameter, or use of tracked request IDs or cancellation flags.
        406:
          description: No acceptable explanation representation was selected by the HTTP `Accept` header.

    delete:
      tags:
        - Transactions
      summary: Abort a transaction
      description: |
        An active transaction can be aborted by means of a HTTP DELETE request on the transaction resource. This will execute a transaction rollback on the repository and will close the transaction. After executing a DELETE, further operations on the same transaction will result in an error.
      parameters:
        - name: repositoryID
          in: path
          required: true
          description: The repository ID
          schema:
            type: string
        - name: transactionID
          in: path
          required: true
          schema:
            type: string
          description: The transaction ID
      responses:
        204:
          description: Successfully aborted the defined transaction.
