CRAFTS#
CRAFTS is configured with a JSON file where each property names its endpoint and predicate. A query resolves a DOI to its OMID and title in OpenCitations Meta. A resource call then merges properties from both endpoints, but the join is keyed by the resource IRI: the same IRI must identify the entity in every store, and the client must supply it. You cannot start the join from the DOI, so the DOI is resolved to the OMID first, then the resource is fetched.
from helper import call
A simple request#
Resolve the DOI to its OMID and title in OpenCitations Meta.
call("http://localhost:8085/apis/oc/query?id=articleByDoi&doi=10.1007/s11192-022-04367-w", headers={"Authorization": "Bearer oc-read-token"})
curl -H 'Authorization: Bearer oc-read-token' 'http://localhost:8085/apis/oc/query?id=articleByDoi&doi=10.1007/s11192-022-04367-w'
# 200 OK
{
"head": {
"link": [],
"vars": [
"br",
"title"
]
},
"results": {
"distinct": false,
"ordered": true,
"bindings": [
{
"br": {
"type": "uri",
"value": "https://w3id.org/oc/meta/br/061202127149"
},
"title": {
"type": "literal",
"value": "Identifying And Correcting Invalid Citations Due To DOI Errors In Crossref Data"
}
}
]
},
"query": "PREFIX n0: <http://purl.org/spar/datacite/>\nPREFIX n1: <http://www.essepuntato.it/2010/06/literalreification/>\nPREFIX n2: <http://purl.org/dc/terms/>\nSELECT ?br ?title WHERE { ?id n0:usesIdentifierScheme n0:doi ; n1:hasLiteralValue \"10.1007/s11192-022-04367-w\" . ?br n0:hasIdentifier ?id ; n2:title ?title . }"
}
The join#
Fetch the resource keyed by that IRI: CRAFTS merges the title from Meta with the references from Index.
call("http://localhost:8085/apis/oc/resource?id=article&iri=https://w3id.org/oc/meta/br/061202127149", headers={"Authorization": "Bearer oc-read-token"})
curl -H 'Authorization: Bearer oc-read-token' 'http://localhost:8085/apis/oc/resource?id=article&iri=https://w3id.org/oc/meta/br/061202127149'
# 200 OK
{
"iri": "https://w3id.org/oc/meta/br/061202127149",
"title": {
"nolang": "Identifying And Correcting Invalid Citations Due To DOI Errors In Crossref Data"
},
"references": [
"https://w3id.org/oc/index/ci/061202127149-060504627",
"https://w3id.org/oc/index/ci/061202127149-061202300315",
"https://w3id.org/oc/index/ci/061202127149-061302130471",
"https://w3id.org/oc/index/ci/061202127149-061302130520",
"https://w3id.org/oc/index/ci/061202127149-061302130714",
"https://w3id.org/oc/index/ci/061202127149-061303572746",
"https://w3id.org/oc/index/ci/061202127149-061402111914",
"https://w3id.org/oc/index/ci/061202127149-061402112592",
"https://w3id.org/oc/index/ci/061202127149-061403569058",
"https://w3id.org/oc/index/ci/061202127149-061403572753",
"https://w3id.org/oc/index/ci/061202127149-061503593762",
"https://w3id.org/oc/index/ci/061202127149-061602967302",
"https://w3id.org/oc/index/ci/061202127149-061702317089",
"https://w3id.org/oc/index/ci/061202127149-06180173853",
"https://w3id.org/oc/index/ci/061202127149-061903578905",
"https://w3id.org/oc/index/ci/061202127149-062103559970",
"https://w3id.org/oc/index/ci/061202127149-062202182112",
"https://w3id.org/oc/index/ci/061202127149-062301987890",
"https://w3id.org/oc/index/ci/061202127149-06230495229",
"https://w3id.org/oc/index/ci/061202127149-062501777134",
"https://w3id.org/oc/index/ci/061202127149-062501777138",
"https://w3id.org/oc/index/ci/061202127149-06250648343",
"https://w3id.org/oc/index/ci/061202127149-06250648347",
"https://w3id.org/oc/index/ci/061202127149-06250648394",
"https://w3id.org/oc/index/ci/061202127149-062601255589",
"https://w3id.org/oc/index/ci/061202127149-0630685531",
"https://w3id.org/oc/index/ci/061202127149-06504020104",
"https://w3id.org/oc/index/ci/061202127149-06902330758",
"https://w3id.org/oc/index/ci/061202127149-06903005993",
"https://w3id.org/oc/index/ci/061202127149-06903303973"
]
}
Output#
JSON only; CRAFTS does not negotiate other formats.
Pagination#
Not supported.
Versioning#
Not supported.
API description#
A Swagger UI serving an OpenAPI 3.0 spec, at http://localhost:8085/docs/. The spec is pulled from the running container and rendered below.
import json
import re
import requests
from helper import embed_swagger
init_js = requests.get("http://localhost:8085/docs/swagger-ui-init.js", timeout=120).text
spec = json.loads(re.search(r'"swaggerDoc":\s*(\{.*?\}),\s*"customOptions"', init_js, re.S).group(1))
embed_swagger(spec, base_url="http://localhost:8085/")
Authentication#
Every operation requires credentials (the calls above carry a Bearer read token).