ShExStatements API


ShExStatements has also a public API that can be easily accessible both on a local installation as well as on the public interface. It has one operation that takes as input a JSON array with two elements as given below:

  • delimiter
  • CSV (every line should be terminated by \n)

It returns a JSON array with one element containing the ShEx (shape expression).

Example JSON input

Take for example the file tvseries.json (also present in examples/api/tvseries.json). It is an array with two elements.

@tvseries|wdt:P31|wd:Q5398426|# instance of a tvseries\n
@tvseries|wdt:P136|@genre|*|# genre\n
@tvseries|wdt:P495|.|+|#country of origin\n
@genre|wdt:P31|wd:Q201658,wd:Q15961987|#instance of genre\n"

Calling ShExStatements API

Following is the way to call the ShExStatements API

$ curl -s -X POST -H "Accept: application/json"  --data  @examples/api/tvseries.json |sed 's/\\n/\n/g'


$ curl -s -X POST -H "Accept: application/json"  --data  @examples/api/tvseries.json |sed 's/\\n/\n/g'

Example JSON output response

It gives the following output. For the output, the above command makes use of sed.

"PREFIX wd: <>
PREFIX xsd: <>
PREFIX wdt: <>
start = @<tvseries>
<tvseries> {
  wdt:P31 [ wd:Q5398426  ] ;# instance of a tvseries
  wdt:P136 @<genre>* ;# genre
  wdt:P495 . ;#country of origin
  wdt:P57 . ;#director
  wdt:P58 . ;#screenwriter
<genre> {
  wdt:P31 [ wd:Q201658 wd:Q15961987  ] ;#instance of genre