This simple Deno Deploy application serves a serverless in-memory Oxigraph RDF store, allowing users to execute SPARQL SELECT
queries against a specified Turtle file.
- Fetches and loads a Turtle file into an in-memory Oxigraph store
- Allows executing SPARQL
SELECT
queries against the store via a GET request.
- Deno 1.x
- Deno Deploy (for deployment)
- Ensure you have Deno installed on your machine. Visit deno.land for installation instructions.
- Clone the repository or download the source code to your local machine.
You can customize the Turtle file URL and base URI by setting the following environment variables:
TURTLE_FILE_URL
: The URL of the Turtle file to load into the Oxigraph store.BASE_URI
: The base URI for the RDF data in the Turtle file.
You can set these variables in a .env
file or directly in the environment before running the application.
- Run the application locally using the following command:
deno run --allow-net --allow-env index.js
- Access the API by sending a GET request to
http://localhost:8000?query={your_query}
with your desired SPARQLSELECT
query.
Deploy the application using Deno Deploy:
- Create a new project on Deno Deploy and link it to your repository.
- Set the deployment settings to use
index.js
as the entry point. - Deploy the application.
Send a GET request with the query
parameter containing the SPARQL SELECT
query.
GET /?query={query}
query
(required) - The SPARQLSELECT
query to execute against the in-memory Oxigraph store.
Returns a JSON object containing the query results and any errors during the query execution.
{
"query": "string",
"results": [
{
"key": "value"
}
],
"error": "string (optional)",
"stack": "string (optional, only in development environment)"
}
A demo deployment of this application is available at the following URL:
https://serverless-sparql.deno.dev/
This demo deployment loads a simple RDF dataset from the example Turtle file available at https://www.yamaml.org/examples/tbbt_v02.ttl.
To execute a SPARQL SELECT query against the demo deployment, simply append your desired query as a URL-encoded parameter to the base URL. For example, the following query retrieves all distinct subject, predicate, and object triples from the RDF store:
SELECT DISTINCT ?s ?p ?o WHERE { ?s ?p ?o }
Access the query results by sending a GET request to the demo deployment URL with the query
parameter:
Alternatively, you can use a tool like curl
to send a GET request to the demo deployment:
curl "https://serverless-sparql.deno.dev/" \
--get \
--data-urlencode "query=SELECT DISTINCT ?s ?p ?o WHERE { ?s ?p ?o }"
This project is licensed under the MIT License.