Exporting Graphs and Ontologies with Imports using Web APIs

62 views
Skip to first unread message

Hamid Abdirad

unread,
Oct 12, 2023, 3:46:53 PM10/12/23
to TopBraid Suite Users
Hi all,
I want to export/download the content of collections (with imports included) using the web api endpoints of Topbraid EDG. The ultimate objective is to use the exported collections in other solutions that may use open source modules (like rdflib and pyshacl in python, or dotNetRDF in C# or ...) - so a RDF/Turtle - or a TRIG file - with imports is ideal.  

Current challenges:
(1) tbs/exportRDFFile endpoint does not include imports in the response. So included graphs/ontologies are not found in the response. 

(2) /sparql endpoint, when used with "SELECT" queries, includes imported triples in the response but I am afraid the content and currently supported formats require a lot of post-processing that can affect the final ttl output (this endpoint does not readily provide a ttl output. a csv file can be exported but requires a lot of post-processing).

Any suggestions or guidance is much appreciated. 
Thank you 
Hamid

Richard Cyganiak

unread,
Oct 13, 2023, 4:22:18 AM10/13/23
to topbrai...@googlegroups.com
Hi Hamid,

To get Turtle from the SPARQL endpoint, use a CONSTRUCT query. In the simple case where you want to return the whole graph, use this query:

CONSTRUCT WHERE { ?s ?p ?o }

You can try this by going to /tbl/sparql, pasting the query into the form, choosing your asset collection from the dropdown, and checking the “Include imports” box.

A corresponding curl command would be something like this (assuming an asset collection called “t1” and EDG Studio):

curl -d default-graph-uri=urn:x-evn-master:t1 \
-d "query=CONSTRUCT WHERE { ?s ?p ?o }” \
-d with-imports=true \
-d format=turtle \
http://localhost:8083/tbl/sparql

Hope that helps,
Richard
> --
> The topics of this mailing list include TopBraid EDG and related technologies such as SHACL.
> To post to this group, send email to topbrai...@googlegroups.com
> ---
> You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/58889701-e82e-4308-97db-c4dd616f6466n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages