ShExpose#

ShExpose generates a REST API from ShEx shapes through a LinkMLShExLDOExpress pipeline: every shape becomes a set of CRUD routes, and the SPARQL is derived from the shape instead of being written by hand. It binds one endpoint and addresses a resource by its RDF subject IRI, so the lookup here is by OMID rather than by DOI. The shape below describes a bibliographic resource as a fabio:Expression carrying its title and its authors’ names.

from urllib.parse import quote

from helper import call

omid = "https://w3id.org/oc/meta/br/061202127149"
uri = quote(omid, safe="")

A simple request#

ShExpose addresses a resource by its URL-encoded subject IRI. Looking up the OMID returns the attributes named in the shape: the title from OpenCitations Meta together with the author surnames and given names, each value wrapped in a {language, value} object.

call(f"http://localhost:8090/expression/{uri}/")
curl http://localhost:8090/expression/https%3A%2F%2Fw3id.org%2Foc%2Fmeta%2Fbr%2F061202127149/ 
# 200 OK

{
  "title": {
    "language": "@none",
    "value": "Identifying And Correcting Invalid Citations Due To DOI Errors In Crossref Data"
  },
  "familyName": [
    {
      "language": "@none",
      "value": "Cioffi"
    },
    {
      "language": "@none",
      "value": "Coppini"
    },
    {
      "language": "@none",
      "value": "Massari"
    },
    {
      "language": "@none",
      "value": "Moretti"
    },
    {
      "language": "@none",
      "value": "Peroni"
    },
    {
      "language": "@none",
      "value": "Santini"
    },
    {
      "language": "@none",
      "value": "Shahidzadeh"
    }
  ],
  "givenName": [
    {
      "language": "@none",
      "value": "Alessia"
    },
... (26 more lines)

The join#

Not supported.

Output#

JSON only, with no content negotiation.

call(f"http://localhost:8090/expression/{uri}/title")
curl http://localhost:8090/expression/https%3A%2F%2Fw3id.org%2Foc%2Fmeta%2Fbr%2F061202127149/title 

# 200 OK

{
  "language": "@none",
  "value": "Identifying And Correcting Invalid Citations Due To DOI Errors In Crossref Data"
}

Pagination#

Not supported.

Versioning#

Not supported.

API description#

OpenAPI 3.0, generated from the shapes with zod-to-openapi. ShExpose serves a Swagger UI at http://localhost:8090/docs and the spec at http://localhost:8090/openapi.json.

import requests

from helper import embed_swagger

spec = requests.get("http://localhost:8090/openapi.json", timeout=120).json()
embed_swagger(spec, base_url="http://localhost:8090/")

Authentication#

Not supported for consumers: the generated API is open. For the upstream endpoint, ShExpose can send HTTP Basic credentials on reads and a QLever bearer token on writes.