grlc, the git repository linked data API constructor, automatically builds Web APIs using SPARQL queries stored in git repositories. http://grlc.io/
Contributors: Albert Meroño, Rinke Hoekstra, Carlos Martínez
Copyright: Albert Meroño, VU University Amsterdam
License: MIT License (see LICENSE.txt)
grlc is a lightweight server that takes SPARQL queries curated in GitHub repositories, and translates them to Linked Data Web APIs. This enables universal access to Linked Data. Users are not required to know SPARQL to query their data, but instead can access a web API.
Running via docker is the easiest and preferred form of deploying grlc. You'll need a working installation of docker and docker-compose. To deploy grlc, just pull the latest image from Docker hub, and run docker compose with a docker-compose.yml
that suits your needs (an example is provided in the root directory):
git clone https://github.com/CLARIAH/grlc cd grlc docker pull clariah/grlc docker-compose -f docker-compose.default.yml up
(You can omit the first two commands if you just copy this file somehwere in your filesystem)
If you use the supplied docker-compose.default.yml
your grlc instance will be available at http://localhost:8001
In order for grlc to communicate with GitHub, you'll need to tell grlc what your access token is:
- Get a GitHub personal access token. In your GitHub's profile page, go to Settings, then Developer settings, Personal access tokens, and Generate new token
- You'll get an access token string, copy it and save it somewhere safe (GitHub won't let you see it again!)
- Edit your
docker-compose.yml
ordocker-compose.default.yml
file, and paste this token as value of the environment variable GRLC_GITHUB_ACCESS_TOKEN
If you want to run grlc at system boot as a service, you can find example upstart scripts at upstart/
Through these you'll miss some cool docker bundled features (like nginx-based caching). We provide these alternatives just for testing, development scenarios, or docker compatibility reasons.
If you want to use grlc as a library, you'll find it useful to install via pip
.
pip install grlc grlc-server
More details can be found at grlc's PyPi page (thanks to c-martinez!).
you can find an example of how to run grlc natively here
grlc assumes a GitHub repository (support for general git repos is on the way) where you store your SPARQL queries as .rq files (like in this one). grlc will create an API operation per such a SPARQL query/.rq file.
If you're seeing this, your grlc instance is up and running, and ready to build APIs. Assuming you got it running at http://localhost:8088/
and your queries are at https://github.com/CEDAR-project/Queries
, just point your browser to the following locations:
- To request the swagger spec of your API,
http://localhost:8088/api/username/repo/spec
, e.g. http://localhost:8088/api/CEDAR-project/Queries/spec or http://localhost:8088/api/CLARIAH/wp4-queries/spec - To request the api-docs of your API swagger-ui style,
http://localhost:8088/api/username/repo/api-docs
, e.g. http://localhost:8088/api/CEDAR-project/Queries/api-docs or http://localhost:8088/api/CLARIAH/wp4-queries/api-docs
By default grlc will direct your queries to the DBPedia SPARQL endpoint. To change this either:
- Add a
endpoint:
decorator in the first comment block of the query text (preferred, see below) - Add the URL of the endpoint on a single line in an
endpoint.txt
file within the GitHub repository that contains the queries. - Or you can directly modify the grlc source code (but it's nicer if the queries are self-contained)
That's it!
Check these out:
- http://grlc.io/api/CLARIAH/wp4-queries-hisco/
- http://grlc.io/api/albertmeronyo/lodapi/
- http://grlc.io/api/albertmeronyo/lsq-api
You'll find the sources of these and many more in GitHub
A couple of SPARQL comment embedded decorators are available to make your swagger-ui look nicer (note all comments start with #+
):
-
To specify a query-specific endpoint,
#+ endpoint: http://example.com/sparql
. -
To indicate the HTTP request method,
#+ method: GET
. -
To paginate the results in e.g. groups of 100,
#+ pagination: 100
. -
To create a summary of your query/operation,
#+ summary: This is the summary of my query/operation
-
To assign tags to your query/operation,
#+ tags: #+ - firstTag #+ - secondTag
-
To indicate which parameters of your query/operation should get enumerations (and get dropdown menus in the swagger-ui),
#+ enumerate: #+ - var1 #+ - var2
Notice that these should be plain variable names without SPARQL/BASIL conventions (so
var1
instead of?_var1_iri
)
See examples at https://github.com/albertmeronyo/lodapi.
Use this GitHub search to see examples from other users of grlc.
- Request parameter mappings into SPARQL: grlc is compliant with BASIL's convention on how to map GET/POST request parameters into SPARQL
- Automatic, user customizable population of parameter values in swagger-ui's dropdown menus via SPARQL triple pattern querying
- URL-based content negotiation: you can request for specific content types by attaching them to the operation request URL, e.g. http://localhost:8088/CEDAR-project/Queries/residenceStatus_all.csv will request for results in CSV
- Pagination of API results, as per the
pagination
decorator and GitHub's API Pagination Traversal - Docker images in Docker Hub for easy deployment
- Compatibility with Linked Data Fragments servers, RDF dumps, and HTML+RDFa files
- Generation of provenance in PROV of both the repo history (via Git2PROV) and grlc's activity additions
- Commit-based API versioning that's coherent with the repo versioning with git hashes
grlc needs you to continue bringing Semantic Web content to developers, applications and users. No matter if you are just a curious user, a developer, or a researcher; there are many ways in which you can contribute:
- File in bug reports
- Request new features
- Set up your own environment and start hacking
Check our contributing guidelines for these and more, and join us today!
If you cannot code, that's no problem! There's still plenty you can contribute:
- Share your experience at using grlc in Twitter (mention the handler @grlcldapi)
- If you are good with HTML/CSS, let us know
- SPARQL2Git is a Web interface for editing SPARQL queries and saving them in GitHub as grlc APIs.
- grlcR is a package for R that brings Linked Data into your R environment easily through grlc.
- Albert Meroño-Peñuela, Rinke Hoekstra. “grlc Makes GitHub Taste Like Linked Data APIs”. The Semantic Web – ESWC 2016 Satellite Events, Heraklion, Crete, Greece, May 29 – June 2, 2016, Revised Selected Papers. LNCS 9989, pp. 342-353 (2016). (PDF)
- Albert Meroño-Peñuela, Rinke Hoekstra. “SPARQL2Git: Transparent SPARQL and Linked Data API Curation via Git”. In: Proceedings of the 14th Extended Semantic Web Conference (ESWC 2017), Poster and Demo Track. Portoroz, Slovenia, May 28th – June 1st, 2017 (2017). (PDF)
- Albert Meroño-Peñuela, Rinke Hoekstra. “Automatic Query-centric API for Routine Access to Linked Data”. In: The Semantic Web – ISWC 2017, 16th International Semantic Web Conference. Lecture Notes in Computer Science, vol 10587, pp. 334-339 (2017). (PDF)