-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapi.html
More file actions
105 lines (98 loc) · 3.29 KB
/
api.html
File metadata and controls
105 lines (98 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="Description" content="ShExStatements"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="shortcut icon" href="images/logo/favicon.png"/>
<link rel= "stylesheet" type= "text/css" href= "/css/style.css">
<title>ShExStatements</title>
<script>
</script>
</head>
<body vocab="http://schema.org/" typeof="Website">
<div class="page">
<div id="header">
<div id="logo"><a href="./">ShExStatements</a>
</div>
</div>
<div id="sidebar">
<div id="sidebarlinks">
<ul>
<li><a href="./">Home</a></li>
<li><a href="./quickstart">Quick Start</a></li>
<li><a href="./docs">Documentation</a></li>
<li><a href="./api">API</a></li>
<li><a href="./about">About</a> </li>
</ul>
</div>
</div>
<div id="content">
<div class="section">
<h2>ShExStatements API</h2>
<h3>Operations</h3>
<p>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:</p>
<ul>
<li>delimiter</li>
<li>CSV (every line should be terminated by \n)</li>
</ul>
<p>It returns a JSON array with one element containing the ShEx (shape expression).</p>
<h3>Example JSON input</h3>
<p>Take for example the file <code>tvseries.json</code> (also present in <code>examples/api/tvseries.json</code>). It is an array with two elements.</p>
<pre>
<code>
[
"|",
"wd|<http://www.wikidata.org/entity/>|||\n
wdt|<http://www.wikidata.org/prop/direct/>|||\n
xsd|<http://www.w3.org/2001/XMLSchema#>|||\n
\n
@tvseries|wdt:P31|wd:Q5398426|# instance of a tvseries\n
@tvseries|wdt:P136|@genre|*|# genre\n
@tvseries|wdt:P495|.|+|#country of origin\n
@tvseries|wdt:P57|.|+|#director\n
@tvseries|wdt:P58|.|+|#screenwriter\n
@genre|wdt:P31|wd:Q201658,wd:Q15961987|#instance of genre\n"
]
</code>
</pre>
<h2>Calling ShExStatements API</h2>
<p>Following is the way to call the ShExStatements API</p>
<pre>
<code>
$ curl -s http://127.0.0.1:5000/ -X POST -H "Accept: application/json" --data @examples/api/tvseries.json |sed 's/\\n/\n/g'
</code>
</pre>
<p>or</p>
<pre>
<code>
$ curl -s https://shexstatements.toolforge.org/ -X POST -H "Accept: application/json" --data @examples/api/tvseries.json |sed 's/\\n/\n/g'
</code>
</pre>
<h3>Example JSON output response</h3>
<p>It gives the following output. For the output, the above command makes use of <code>sed</code>.</p>
<pre>
<code>
"PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
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
}
"
</code>
</pre>
</div>
</div>
<script>
</script>
</body>
</html>