BASIL#

BASIL stores its SPARQL queries in its own triplestore and renders the results itself, so its output formats are fixed rather than negotiated with the endpoint. It binds a single endpoint, so it answers from Meta only.

from pathlib import Path

from helper import call

BASIL_ID = Path("basil/state/api-id").read_text().strip()
BASIL_RDF_ID = Path("basil/state/api-id-rdf").read_text().strip()

A simple request#

Looking up a DOI returns the article’s title from OpenCitations Meta.

call(f"http://localhost:8080/basil/{BASIL_ID}/api.json?doi=10.1007/s11192-022-04367-w")
curl 'http://localhost:8080/basil/s163hkp9fr5k/api.json?doi=10.1007/s11192-022-04367-w' 
# 200 OK

{
  "vars": [
    "br",
    "title"
  ],
  "items": [
    {
      "br": "https://w3id.org/oc/meta/br/061202127149",
      "title": "Identifying And Correcting Invalid Citations Due To DOI Errors In Crossref Data"
    }
  ]
}

The join#

No join. BASIL binds a single endpoint, so it cannot reach OpenCitations Index to add the reference count.

Output#

SELECT results as JSON or CSV; a CONSTRUCT query as RDF.

call(f"http://localhost:8080/basil/{BASIL_ID}/api.csv?doi=10.1007/s11192-022-04367-w")
curl 'http://localhost:8080/basil/s163hkp9fr5k/api.csv?doi=10.1007/s11192-022-04367-w' 

# 200 OK

br,title
https://w3id.org/oc/meta/br/061202127149,Identifying And Correcting Invalid Citations Due To DOI Errors In Crossref Data
call(f"http://localhost:8080/basil/{BASIL_RDF_ID}/api.ttl?doi=10.1007/s11192-022-04367-w")
curl 'http://localhost:8080/basil/vf45o8rpuptk/api.ttl?doi=10.1007/s11192-022-04367-w' 
# 200 OK

BASE   <file:///basil/>
PREFIX datacite: <http://purl.org/spar/datacite/>
PREFIX dcterms:  <http://purl.org/dc/terms/>
PREFIX literal:  <http://www.essepuntato.it/2010/06/literalreification/>

<https://w3id.org/oc/meta/br/061202127149>
        dcterms:title           "Identifying And Correcting Invalid Citations Due To DOI Errors In Crossref Data";
        datacite:hasIdentifier  <https://w3id.org/oc/meta/id/061202156316> .

Pagination#

Not supported.

Versioning#

Not supported.

API description#

Swagger 1.2.

call(f"http://localhost:8080/basil/{BASIL_ID}/api-docs")
curl http://localhost:8080/basil/s163hkp9fr5k/api-docs 

# 200 OK

{"swaggerVersion":"1.2","basePath":"http://localhost:8080/basil","resourcePath":"s163hkp9fr5k","apis":[{"path":"/s163hkp9fr5k/api","resourcePath":"/s163hkp9fr5k/api","operations":[{"method":"GET","nickname":"API","summary":"","type":"void","produces":["text/x-nquads","application/sparql-results+json","application/n-triples","text/csv","application/ld+json","text/turtle","text/plain","application/sparql-results+xml","application/rdf+xml","application/xml","text/tsv","application/json","application/rdf+json"],"parameters":[{"name":"doi","description":"","required":true,"type":"string","paramType":"query"}]}]},{"path":"/s163hkp9fr5k/api{ext}","resourcePath":"/s163hkp9fr5k/api","operations":[{"method":"GET","nickname":"APIext","summary":"","type":"void","produces":["text/x-nquads","application/sparql-results+json","application/n-triples","text/csv","application/ld+json","text/turtle","text/plain","application/sparql-results+xml","application/rdf+xml","application/xml","text/tsv","application/json","application/rdf+json"],"parameters":[{"name":"doi","description":"","required":true,"type":"string","paramType":"query"},{"name":"ext","description":"Extension of the output data format (e.g., .json, .xml)","required":"false","type":"string","paramType":"path","allowMultiple":"false"}]}]}]}

Authentication#

Writes are protected by HTTP Basic; reads are open. The login flow:

call("http://localhost:8080/basil/auth/login", method="POST", data={"username": "demo", "password": "demo"})
curl -X POST -H 'Content-type: application/json' --data '{"username": "demo", "password": "demo"}' http://localhost:8080/basil/auth/login 

# 201 Created

{
  "message": "Login successful: demo",
  "user": "http://localhost:8080/basil/users/demo"
}