This document outlines the process of creating a REST API to manage instances of a class using CRUD SPARQL Templates in the ENAPSO together View Management Service.
Before creating a REST API, you must first define the necessary CRUD SPARQL Templates for managing instances of a class. You can follow the instructions on the following Confluence page to create these templates:
Creating CRUD SPARQL Templates
Once the templates are created, you can proceed with setting up the REST API.
To create REST API endpoints for the defined SPARQL templates, send a request to the following endpoint:
POST /v1/create-endpoint-4-template |
{ "records": [ { "endpoint": "domain", "baseURL": "/v1", "endpointConfig": [ { "method": "get", "template": "getListOfDomain" }, { "method": "post", "template": "createDomain" }, { "method": "put", "template": "updateDomain" }, { "method": "delete", "template": "deleteDomain" } ] } ] } |
records
: An array of configuration objects that define a set of CRUD operations for a specific endpoint.
endpoint
: The name of the REST endpoint.
baseURL
: The base URL under which the endpoint is grouped (e.g., /v1
).
endpointConfig
: An array of objects specifying CRUD operations:
method
: HTTP method (get
, post
, put
, delete
).
template
: Name of the SPARQL template executed for this endpoint.
{ "status": 200, "message": "Route Created Successfully", "success": true, "records": [ {"success": true, "status": 200, "message": "Route GET /v1/domain created successfully."}, {"success": true, "status": 200, "message": "Route POST /v1/domain created successfully."}, {"success": true, "status": 200, "message": "Route PUT /v1/domain created successfully."}, {"success": true, "status": 200, "message": "Route DELETE /v1/domain created successfully."} ] } |
Once the endpoints are successfully created, you can send requests to them with the required variables.
{ "variables": { "domainValues": [ {"domain": "Check New", "language": "en"}, {"domain": "Hallo New", "language": "de"} ] } } |
Send a GET request with query parameters:
GET /v1/domain?limit=1&offset=5&language=fr&calculateTotal=true&countPropertyName=?iri |
limit: Specifies the number of records to return.
offset: Specifies the starting point for fetching records.
language: Specifies the language of the returned data (e.g., fr
for French).
calculateTotal: Set to true
to include the total number of records in the response (default: false
).
countPropertyName: Defines the property based on which the count is calculated (default: *
).
Any additional parameters can be passed in the format name=value
, as demonstrated with language=fr
.
{ "variables": { "domainIRI": "http://ont.enapso.com/companion/data#Domain_a06a7605-d374-47b1-b2bb-e4512df04cc7", "domainValues": [ {"domain": "Hell", "language": "en"}, {"domain": "Hollo", "language": "fr"} ] } } |
{ "variables": { "domain": "Hell" } } |
Following the steps above, you can successfully create and manage REST API endpoints for CRUD operations on SPARQL templates using the ENAPSO together View Management Service.