Restful API Manager Over SPARQL Endpoints. Turns SPARQL endpoints into documented REST APIs.
Quick start
pip install ramose
Requires Python 3.10 or later.
Create a spec file meta_v1.hf:
#url /v1
#type api
#base https://api.opencitations.net/meta
#title OpenCitations Meta REST API
#description REST API for bibliographic metadata from OpenCitations Meta
#version 1.0.0
#license ISC
#contacts [contact@opencitations.net](mailto:contact@opencitations.net)
#endpoint https://opencitations.net/meta/sparql
#method post
#url /metadata/{doi}
#type operation
#doi str(10\..+)
#method get
#description Returns bibliographic metadata for the given DOI.
#call /metadata/10.1162/qss_a_00292
#field_type str(title) datetime(pub_date) str(venue) str(type)
#sparql PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX datacite: <http://purl.org/spar/datacite/>
PREFIX dcterm: <http://purl.org/dc/terms/>
PREFIX fabio: <http://purl.org/spar/fabio/>
PREFIX frbr: <http://purl.org/vocab/frbr/core#>
PREFIX literal: <http://www.essepuntato.it/2010/06/literalreification/>
PREFIX prism: <http://prismstandard.org/namespaces/basic/2.0/>
SELECT ?title ?pub_date ?venue ?type WHERE {
?identifier literal:hasLiteralValue "[[doi]]"^^xsd:string ;
datacite:usesIdentifierScheme datacite:doi ;
^datacite:hasIdentifier ?res .
OPTIONAL { ?res dcterm:title ?title }
OPTIONAL { ?res prism:publicationDate ?pub_date }
OPTIONAL {
?res frbr:partOf+ ?journal .
?journal a fabio:Journal ; dcterm:title ?venue
}
OPTIONAL { ?res a ?type . FILTER(?type != fabio:Expression) }
}
Spec files can also use YAML:
- url: /v1 type: api base: https://api.opencitations.net/meta title: OpenCitations Meta REST API description: REST API for bibliographic metadata from OpenCitations Meta version: "1.0.0" license: ISC contacts: "[contact@opencitations.net](mailto:contact@opencitations.net)" endpoint: https://opencitations.net/meta/sparql method: post - url: /metadata/{doi} type: operation doi: 'str(10\..+)' method: get description: Returns bibliographic metadata for the given DOI. call: /metadata/10.1162/qss_a_00292 field_type: str(title) datetime(pub_date) str(venue) str(type) sparql: | PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX datacite: <http://purl.org/spar/datacite/> PREFIX dcterm: <http://purl.org/dc/terms/> PREFIX fabio: <http://purl.org/spar/fabio/> PREFIX frbr: <http://purl.org/vocab/frbr/core#> PREFIX literal: <http://www.essepuntato.it/2010/06/literalreification/> PREFIX prism: <http://prismstandard.org/namespaces/basic/2.0/> SELECT ?title ?pub_date ?venue ?type WHERE { ?identifier literal:hasLiteralValue "[[doi]]"^^xsd:string ; datacite:usesIdentifierScheme datacite:doi ; ^datacite:hasIdentifier ?res . OPTIONAL { ?res dcterm:title ?title } OPTIONAL { ?res prism:publicationDate ?pub_date } OPTIONAL { ?res frbr:partOf+ ?journal . ?journal a fabio:Journal ; dcterm:title ?venue } OPTIONAL { ?res a ?type . FILTER(?type != fabio:Expression) } }
Run locally:
python -m ramose -s meta_v1.hf -c '/v1/metadata/10.1162/qss_a_00292'Or start the web server:
python -m ramose -s meta_v1.hf -w 127.0.0.1:8080
Visit http://localhost:8080/v1 for auto-generated docs.
How to cite
If you use RAMOSE, please cite both the article and the software:
Daquino, M., Heibi, I., Peroni, S., Shotton, D. (2022). Creating RESTful APIs over SPARQL endpoints using RAMOSE. Semantic Web, 13(2), 195-213. https://doi.org/10.3233/SW-210439
To cite the latest version of this software (2.8.3), use this BibTeX entry:
@software{RAMOSE-2.8.3, author = {Peroni, Silvio and Daquino, Marilena and Brembilla, Davide and Heibi, Ivan and Massari, Arcangelo}, title = {RAMOSE}, url = {https://archive.softwareheritage.org/swh:1:snp:d9143da495332541d80421c49a8d59dfc12311d1;origin=https://github.com/opencitations/ramose}, version = {2.8.3}, year = {2026} }
License
ISC