blob: 8814e2dc0c97455c055c00def1c8b3ed2ea4b42e [file] [log] [blame]
Ian Maxonbf8620b2024-04-01 16:09:18 -07001<!DOCTYPE html>
2<!--
3 | Generated by Apache Maven Doxia Site Renderer 1.8.1 from src/site/markdown/api.md at 2024-04-01
4 | Rendered using Apache Maven Fluido Skin 1.7
5-->
6<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7 <head>
8 <meta charset="UTF-8" />
9 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10 <meta name="Date-Revision-yyyymmdd" content="20240401" />
11 <meta http-equiv="Content-Language" content="en" />
12 <title>AsterixDB &#x2013; HTTP API to AsterixDB</title>
13 <link rel="stylesheet" href="./css/apache-maven-fluido-1.7.min.css" />
14 <link rel="stylesheet" href="./css/site.css" />
15 <link rel="stylesheet" href="./css/print.css" media="print" />
16 <script type="text/javascript" src="./js/apache-maven-fluido-1.7.min.js"></script>
17
18 </head>
19 <body class="topBarDisabled">
20 <div class="container-fluid">
21 <div id="banner">
22 <div class="pull-left"><a href="./" id="bannerLeft"><img src="images/asterixlogo.png" alt="AsterixDB"/></a></div>
23 <div class="pull-right"></div>
24 <div class="clear"><hr/></div>
25 </div>
26
27 <div id="breadcrumbs">
28 <ul class="breadcrumb">
29 <li id="publishDate">Last Published: 2024-04-01</li>
30 <li id="projectVersion" class="pull-right">Version: 0.9.9</li>
31 <li class="pull-right"><a href="index.html" title="Documentation Home">Documentation Home</a></li>
32 </ul>
33 </div>
34 <div class="row-fluid">
35 <div id="leftColumn" class="span2">
36 <div class="well sidebar-nav">
37 <ul class="nav nav-list">
38 <li class="nav-header">Get Started - Installation</li>
39 <li><a href="ncservice.html" title="Option 1: using NCService"><span class="none"></span>Option 1: using NCService</a></li>
40 <li><a href="ansible.html" title="Option 2: using Ansible"><span class="none"></span>Option 2: using Ansible</a></li>
41 <li><a href="aws.html" title="Option 3: using Amazon Web Services"><span class="none"></span>Option 3: using Amazon Web Services</a></li>
42 <li class="nav-header">AsterixDB Primer</li>
43 <li><a href="sqlpp/primer-sqlpp.html" title="Using SQL++"><span class="none"></span>Using SQL++</a></li>
44 <li class="nav-header">Data Model</li>
45 <li><a href="datamodel.html" title="The Asterix Data Model"><span class="none"></span>The Asterix Data Model</a></li>
46 <li class="nav-header">Queries</li>
47 <li><a href="sqlpp/manual.html" title="The SQL++ Query Language"><span class="none"></span>The SQL++ Query Language</a></li>
48 <li><a href="SQLPP.html" title="Raw SQL++ Grammar"><span class="none"></span>Raw SQL++ Grammar</a></li>
49 <li><a href="sqlpp/builtins.html" title="Builtin Functions"><span class="none"></span>Builtin Functions</a></li>
50 <li class="nav-header">API/SDK</li>
51 <li class="active"><a href="#"><span class="none"></span>HTTP API</a></li>
52 <li><a href="csv.html" title="CSV Output"><span class="none"></span>CSV Output</a></li>
53 <li class="nav-header">Advanced Features</li>
54 <li><a href="aql/externaldata.html" title="Accessing External Data"><span class="none"></span>Accessing External Data</a></li>
55 <li><a href="feeds.html" title="Data Ingestion with Feeds"><span class="none"></span>Data Ingestion with Feeds</a></li>
56 <li><a href="udf.html" title="User Defined Functions"><span class="none"></span>User Defined Functions</a></li>
57 <li><a href="sqlpp/filters.html" title="Filter-Based LSM Index Acceleration"><span class="none"></span>Filter-Based LSM Index Acceleration</a></li>
58 <li><a href="sqlpp/fulltext.html" title="Support of Full-text Queries"><span class="none"></span>Support of Full-text Queries</a></li>
59 <li><a href="sqlpp/similarity.html" title="Support of Similarity Queries"><span class="none"></span>Support of Similarity Queries</a></li>
60 <li><a href="geo/quickstart.html" title="GIS Support Overview"><span class="none"></span>GIS Support Overview</a></li>
61 <li><a href="geo/functions.html" title="GIS Functions"><span class="none"></span>GIS Functions</a></li>
62 <li><a href="interval_join.html" title="Support of Interval Joins"><span class="none"></span>Support of Interval Joins</a></li>
63 <li><a href="spatial_join.html" title="Support of Spatial Joins"><span class="none"></span>Support of Spatial Joins</a></li>
64 <li><a href="sqlpp/arrayindex.html" title="Support of Array Indexes"><span class="none"></span>Support of Array Indexes</a></li>
65 <li class="nav-header">Deprecated</li>
66 <li><a href="aql/primer.html" title="AsterixDB Primer: Using AQL"><span class="none"></span>AsterixDB Primer: Using AQL</a></li>
67 <li><a href="aql/manual.html" title="Queries: The Asterix Query Language (AQL)"><span class="none"></span>Queries: The Asterix Query Language (AQL)</a></li>
68 <li><a href="aql/builtins.html" title="Queries: Builtin Functions (AQL)"><span class="none"></span>Queries: Builtin Functions (AQL)</a></li>
69</ul>
70 <hr />
71 <div id="poweredBy">
72 <div class="clear"></div>
73 <div class="clear"></div>
74 <div class="clear"></div>
75 <div class="clear"></div>
76<a href="./" title="AsterixDB" class="builtBy"><img class="builtBy" alt="AsterixDB" src="images/asterixlogo.png" /></a>
77 </div>
78 </div>
79 </div>
80 <div id="bodyColumn" class="span10" >
81<!--
82 ! Licensed to the Apache Software Foundation (ASF) under one
83 ! or more contributor license agreements. See the NOTICE file
84 ! distributed with this work for additional information
85 ! regarding copyright ownership. The ASF licenses this file
86 ! to you under the Apache License, Version 2.0 (the
87 ! "License"); you may not use this file except in compliance
88 ! with the License. You may obtain a copy of the License at
89 !
90 ! http://www.apache.org/licenses/LICENSE-2.0
91 !
92 ! Unless required by applicable law or agreed to in writing,
93 ! software distributed under the License is distributed on an
94 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
95 ! KIND, either express or implied. See the License for the
96 ! specific language governing permissions and limitations
97 ! under the License.
98 !-->
99<h1>HTTP API to AsterixDB</h1>
100<div class="section">
101<h2><a name="Table_of_Contents"></a><a name="toc" id="toc">Table of Contents</a></h2>
102<ul>
103
104<li><a href="#queryservice">Query Service API</a></li>
105<li><a href="#querystatus">Query Status API</a></li>
106<li><a href="#queryresult">Query Result API</a></li>
107</ul></div>
108<div class="section">
109<h2><a name="POST_.2Fquery.2Fservice_.5BBack_to_TOC.5D"></a><a name="queryservice" id="queryservice">POST /query/service</a><font size="4"> <a href="#toc">[Back to TOC]</a></font></h2>
110<p><b>Description</b> Returns result for query as JSON. The response is a JSON object that contains some result metadata along with either an embedded result or an opaque handle that can be used to navigate to the result (see the decription of the <tt>mode</tt> parameter for more details).</p>
111<p><b>Parameters</b></p>
112<ul>
113
114<li><tt>statement</tt> - Specifies at least one valid SQL++ statement to run. The statements need to be urlencoded. Required.</li>
115<li><tt>pretty</tt> - If the parameter <tt>pretty</tt> is given with the value <tt>true</tt>, the result will be indented. (Optional)</li>
116<li><tt>client_context_id</tt> - A user-defined sequence of characters that the API receives and returns unchanged. This can be used e.g. to match individual requests, jobs, and responses. Another option could be to use it for groups of requests if an application decides to put e.g. an group identifier into that field to route groups of responses to a particular response processor.</li>
117<li><tt>dataverse</tt> - Default dataverse for this statement (Optional). If the specified dataverse does not exist then this setting is ignored.</li>
118<li><tt>mode</tt> - Result delivery mode. Possible values are <tt>immediate</tt>, <tt>deferred</tt>, <tt>async</tt> (default: <tt>immediate</tt>). If the delivery mode is <tt>immediate</tt> the query result is returned with the response. If the delivery mode is <tt>deferred</tt> the response contains a handle to the <a href="#queryresult">result</a>. If the delivery mode is <tt>async</tt> the response contains a handle to the query&#x2019;s <a href="#querystatus">status</a>.</li>
119<li><tt>readonly</tt> - Reject DDL and DML statements, only accept the following kinds: <a href="sqlpp/manual.html#SELECT_statements">SELECT</a>, <a href="sqlpp/manual.html#Declarations">USE</a>, <a href="sqlpp/manual.html#Declarations">DECLARE FUNCTION</a>, and <a href="sqlpp/manual.html#Performance_tuning">SET</a></li>
120<li><tt>args</tt> - (SQL++ only) A JSON array where each item is a value of a <a href="sqlpp/manual.html#Parameter_references">positional query parameter</a></li>
121<li><tt>$parameter_name</tt> - (SQL++ only) a JSON value of a <a href="sqlpp/manual.html#Parameter_references">named query parameter</a>.</li>
122</ul>
123<p><b>Command (immediate result delivery)</b></p>
124
125<div>
126<div>
127<pre class="source">$ curl -v --data-urlencode &quot;statement=select 1;&quot; \
128 --data pretty=true \
129 --data client_context_id=xyz \
130 http://localhost:19002/query/service
131</pre></div></div>
132
133<p><b>Sample response</b></p>
134
135<div>
136<div>
137<pre class="source">&gt; POST /query/service HTTP/1.1
138&gt; Host: localhost:19002
139&gt; User-Agent: curl/7.43.0
140&gt; Accept: */*
141&gt; Content-Length: 57
142&gt; Content-Type: application/x-www-form-urlencoded
143&gt;
144&lt; HTTP/1.1 200 OK
145&lt; transfer-encoding: chunked
146&lt; connection: keep-alive
147&lt; content-type: application/json; charset=utf-8
148&lt;
149{
150 &quot;requestID&quot;: &quot;5f72e78c-482a-45bf-b174-6443c8273025&quot;,
151 &quot;clientContextID&quot;: &quot;xyz&quot;,
152 &quot;signature&quot;: &quot;*&quot;,
153 &quot;results&quot;: [ {
154 &quot;$1&quot; : 1
155 } ]
156 ,
157 &quot;status&quot;: &quot;success&quot;,
158 &quot;metrics&quot;: {
159 &quot;elapsedTime&quot;: &quot;20.263371ms&quot;,
160 &quot;executionTime&quot;: &quot;19.889389ms&quot;,
161 &quot;resultCount&quot;: 1,
162 &quot;resultSize&quot;: 15
163 }
164}
165</pre></div></div>
166
167<p><b>Command (<a name="deferred" id="deferred">deferred result delivery</a>)</b></p>
168
169<div>
170<div>
171<pre class="source">$ curl -v --data-urlencode &quot;statement=select 1;&quot; \
172 --data mode=deferred \
173 http://localhost:19002/query/service
174</pre></div></div>
175
176<p><b>Sample response</b></p>
177
178<div>
179<div>
180<pre class="source">&gt; POST /query/service HTTP/1.1
181&gt; Host: localhost:19002
182&gt; User-Agent: curl/7.43.0
183&gt; Accept: */*
184&gt; Content-Length: 37
185&gt; Content-Type: application/x-www-form-urlencoded
186&gt;
187&lt; HTTP/1.1 200 OK
188&lt; transfer-encoding: chunked
189&lt; connection: keep-alive
190&lt; content-type: application/json; charset=utf-8
191&lt;
192{
193 &quot;requestID&quot;: &quot;6df7afb4-5f83-49b6-8c4b-f11ec84c4d7e&quot;,
194 &quot;signature&quot;: &quot;*&quot;,
195 &quot;handle&quot;: &quot;http://localhost:19002/query/service/result/7-0&quot;,
196 &quot;status&quot;: &quot;success&quot;,
197 &quot;metrics&quot;: {
198 &quot;elapsedTime&quot;: &quot;12.270570ms&quot;,
199 &quot;executionTime&quot;: &quot;11.948343ms&quot;,
200 &quot;resultCount&quot;: 0,
201 &quot;resultSize&quot;: 0
202 }
203}
204</pre></div></div>
205
206<p><b>Command (<a name="async" id="async>">async result delivery</a>)</b></p>
207
208<div>
209<div>
210<pre class="source">$ curl -v --data-urlencode &quot;statement=select 1;&quot; \
211 --data mode=async \
212 http://localhost:19002/query/service
213</pre></div></div>
214
215<p><b>Sample response</b></p>
216
217<div>
218<div>
219<pre class="source">&gt; POST /query/service HTTP/1.1
220&gt; Host: localhost:19002
221&gt; User-Agent: curl/7.43.0
222&gt; Accept: */*
223&gt; Content-Length: 34
224&gt; Content-Type: application/x-www-form-urlencoded
225&gt;
226&lt; HTTP/1.1 200 OK
227&lt; transfer-encoding: chunked
228&lt; connection: keep-alive
229&lt; content-type: application/json; charset=utf-8
230&lt;
231{
232 &quot;requestID&quot;: &quot;c5858420-d821-4c0c-81a4-2364386827c2&quot;,
233 &quot;signature&quot;: &quot;*&quot;,
234 &quot;status&quot;: &quot;running&quot;,
235 &quot;handle&quot;: &quot;http://localhost:19002/query/service/status/9-0&quot;,
236 &quot;metrics&quot;: {
237 &quot;elapsedTime&quot;: &quot;9.727006ms&quot;,
238 &quot;executionTime&quot;: &quot;9.402282ms&quot;,
239 &quot;resultCount&quot;: 0,
240 &quot;resultSize&quot;: 0
241 }
242}
243</pre></div></div>
244</div>
245<div class="section">
246<h2><a name="GET_.2Fquery.2Fservice.2Fstatus_.5BBack_to_TOC.5D"></a><a name="querystatus" id="querystatus">GET /query/service/status</a><font size="4"> <a href="#toc">[Back to TOC]</a></font></h2>
247<p><b>Description</b> Returns status of an <tt>async</tt> query request. The response is a JSON object that has a similar structure to the responses for the <a href="#queryservice">/query/service</a> endpoint. Possible status values for the status are <tt>running</tt>, <tt>success</tt>, <tt>timeout</tt>, <tt>failed</tt>, and <tt>fatal</tt>. If the status value is <tt>success</tt>, the response also contains a handle to the <a href="#queryresult">result</a>. URLs for this endpoint are usually not constructed by the application, they are simply extracted from the <tt>handle</tt> field of the response to a request to the <a href="#queryservice">/query/service</a> endpoint.</p>
248<p><b>Command</b></p>
249<p>This example shows a request/reponse for the (opaque) status handle that was returned by the <a href="#async">async result delivery</a> example.</p>
250
251<div>
252<div>
253<pre class="source">$ curl -v http://localhost:19002/query/service/status/9-0
254</pre></div></div>
255
256<p><b>Sample response</b></p>
257
258<div>
259<div>
260<pre class="source">&gt; GET /query/service/status/9-0 HTTP/1.1
261&gt; Host: localhost:19002
262&gt; User-Agent: curl/7.43.0
263&gt; Accept: */*
264&gt;
265&lt; HTTP/1.1 200 OK
266&lt; transfer-encoding: chunked
267&lt; connection: keep-alive
268&lt; content-type: application/json; charset=utf-8
269&lt;
270{
271 &quot;status&quot;: &quot;success&quot;,
272 &quot;handle&quot;: &quot;http://localhost:19002/query/service/result/9-0&quot;
273}
274</pre></div></div>
275</div>
276<div class="section">
277<h2><a name="GET_.2Fquery.2Fservice.2Fresult_.5BBack_to_TOC.5D"></a><a name="queryresult" id="queryresult">GET /query/service/result</a><font size="4"> <a href="#toc">[Back to TOC]</a></font></h2>
278<p><b>Description</b> Returns result set for an <tt>async</tt> or <tt>deferred</tt> query request. The response is a plain result without a wrapping JSON object. URLs for this endpoint are usually not constructed by the application, they are simply extracted from the <tt>handle</tt> field of the response to a request to the <a href="#queryservice">/query/service</a> or the <a href="#querystatus">/query/service/status</a> endpoint.</p>
279<p><b>Command</b></p>
280<p>This example shows a request/reponse for the (opaque) result handle that was returned by the <a href="#deferred">deferred result delivery</a> example.</p>
281
282<div>
283<div>
284<pre class="source">$ curl -v http://localhost:19002/query/service/result/7-0
285</pre></div></div>
286
287<p><b>Sample response</b></p>
288
289<div>
290<div>
291<pre class="source">&gt; GET /query/service/result/7-0 HTTP/1.1
292&gt; Host: localhost:19002
293&gt; User-Agent: curl/7.43.0
294&gt; Accept: */*
295&gt;
296&lt; HTTP/1.1 200 OK
297&lt; transfer-encoding: chunked
298&lt; connection: keep-alive
299&lt; content-type: application/json
300&lt;
301[ { &quot;$1&quot;: 1 }
302 ]
303</pre></div></div></div>
304 </div>
305 </div>
306 </div>
307 <hr/>
308 <footer>
309 <div class="container-fluid">
310 <div class="row-fluid">
311<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache
312 feather logo, and the Apache AsterixDB project logo are either
313 registered trademarks or trademarks of The Apache Software
314 Foundation in the United States and other countries.
315 All other marks mentioned may be trademarks or registered
316 trademarks of their respective owners.
317 </div>
318 </div>
319 </div>
320 </footer>
321 </body>
322</html>