BlueBrain / nexus

Blue Brain Nexus - A knowledge graph for data-driven science
https://bluebrainnexus.io/
Apache License 2.0
276 stars 74 forks source link

Request for API to return application/ld+json format #1909

Closed adeel-ansari closed 3 years ago

adeel-ansari commented 3 years ago

Some visualization tools can visualize data returned in the following format (GET https://bnb.data.bl.uk/sparql?query=DESCRIBE http://bnb.data.bl.uk/id/resource/018212405):

{ "@graph": [ { "@id": "http://bnb.data.bl.uk/id/resource/GBB721847", "http://www.w3.org/2002/07/owl#sameAs": [ { "@id": "http://bnb.data.bl.uk/id/resource/018212405" } ] }, { "@id": "http://bnb.data.bl.uk/id/person/ZweigStefan1881-1942", "http://www.bl.uk/schemas/bibliographic/blterms#hasCreated": [ { "@id": "http://bnb.data.bl.uk/id/resource/018212405" } ] }, { "@id": "http://bnb.data.bl.uk/id/resource/018212405", "@type": [ "http://schema.org/Book", "http://purl.org/dc/terms/BibliographicResource", … [truncated]

Currently Nexus api's return application/sparql-results+json format:

{ "head": { "vars": [ "subject", "predicate", "object", "context" ] }, "results": { "bindings": [ { "object": { "type": "uri", "value": "https://bluebrain.github.io/nexus/schemas/unconstrained.json" }, "predicate": { "type": "uri", "value": "https://bluebrain.github.io/nexus/vocabulary/constrainedBy" }, "subject": { "type": "uri", "value": "https://reservoir.global/v1/resources/Public/CONP/_/3206cae4-764a-4a84-88a5-ecc1a317830f" } }, …[truncated]

Can we add a feature to return the json-ld format?

umbreak commented 3 years ago

As far as Blazegraph goes, the supported response types are listed here. I don't see anything that looks like what you are describing.

@adeel-ansari can you please give us further feedback? What is the exact query (SELECT, CONSTRUCT, ...) and what is the exact HTTP Accept header those visualization tools are sending to the /sparql endpoint?

adeel-ansari commented 3 years ago

@umbreak , unfortunately I don't have the original query I was using at the time. If I get a chance in the coming weeks, I'll try to re-create.

I was following neo4j instructions to visualize the nexus data in neo4j: https://neo4j.com/labs/neosemantics/how-to-guide/#_previewing_the_data. Because of the format that Nexus was returning, the data wasn't being displayed.

The serialization formats allowed are: Turtle, N-Triples, JSON-LD, RDF/XML, TriG and N-Quads (For named graphs)

If it's something you want to try, note you have to install neo4j and the neosemantics component: https://neo4j.com/labs/neosemantics/installation/

Full documentation here: https://neo4j.com/labs/neosemantics/4.2/

umbreak commented 3 years ago

I see. I can confirm that this works in Blazegraph as well, using the HTTP Accept header application/ld+json when the SPARQL query is a construct query:

$ curl -s -H 'Accept: application/ld+json' '{endpoint}/sparql' 
   -d 'query=CONSTRUCT%20%7B%3Fs%20%3Fp%20%3Fo%7D%20WHERE%20%7B%3Fs%20%3Fp%20%3Fo%7D%20limit%2010'

We will probably want to support the following:

bogdanromanx commented 3 years ago

@wwajerowicz is this currently supported in the blazegraph plugin?

umbreak commented 3 years ago

No. I'm working on supporting it. It could be done by the following days.

This will make part of the composite views a bit easier. We can query the common blazegraph namespace using the text/plain Accept header and get back n-triples instead of what we are currently doing (getting the json-sparql-results and converting them into ntriples).