blob: b39682e9a67ad5ef6d64d36513a13008dd2df32b [file] [log] [blame]
<!DOCTYPE html>
<!--
| Generated by Apache Maven Doxia at 2018-02-09
| Rendered using Apache Maven Fluido Skin 1.3.0
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="Date-Revision-yyyymmdd" content="20180209" />
<meta http-equiv="Content-Language" content="en" />
<title>AsterixDB &#x2013; HTTP API to AsterixDB</title>
<link rel="stylesheet" href="./css/apache-maven-fluido-1.3.0.min.css" />
<link rel="stylesheet" href="./css/site.css" />
<link rel="stylesheet" href="./css/print.css" media="print" />
<script type="text/javascript" src="./js/apache-maven-fluido-1.3.0.min.js"></script>
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-41536543-1', 'uci.edu');
ga('send', 'pageview');</script>
</head>
<body class="topBarDisabled">
<div class="container-fluid">
<div id="banner">
<div class="pull-left">
<a href="./" id="bannerLeft">
<img src="images/asterixlogo.png" alt="AsterixDB"/>
</a>
</div>
<div class="pull-right"> </div>
<div class="clear"><hr/></div>
</div>
<div id="breadcrumbs">
<ul class="breadcrumb">
<li id="publishDate">Last Published: 2018-02-09</li>
<li id="projectVersion" class="pull-right">Version: 0.9.3</li>
<li class="divider pull-right">|</li>
<li class="pull-right"> <a href="index.html" title="Documentation Home">
Documentation Home</a>
</li>
</ul>
</div>
<div class="row-fluid">
<div id="leftColumn" class="span3">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Get Started - Installation</li>
<li>
<a href="ncservice.html" title="Option 1: using NCService">
<i class="none"></i>
Option 1: using NCService</a>
</li>
<li>
<a href="ansible.html" title="Option 2: using Ansible">
<i class="none"></i>
Option 2: using Ansible</a>
</li>
<li>
<a href="aws.html" title="Option 3: using Amazon Web Services">
<i class="none"></i>
Option 3: using Amazon Web Services</a>
</li>
<li>
<a href="yarn.html" title="Option 4: using YARN">
<i class="none"></i>
Option 4: using YARN</a>
</li>
<li>
<a href="install.html" title="Option 5: using Managix (deprecated)">
<i class="none"></i>
Option 5: using Managix (deprecated)</a>
</li>
<li class="nav-header">AsterixDB Primer</li>
<li>
<a href="sqlpp/primer-sqlpp.html" title="Option 1: using SQL++">
<i class="none"></i>
Option 1: using SQL++</a>
</li>
<li>
<a href="aql/primer.html" title="Option 2: using AQL">
<i class="none"></i>
Option 2: using AQL</a>
</li>
<li class="nav-header">Data Model</li>
<li>
<a href="datamodel.html" title="The Asterix Data Model">
<i class="none"></i>
The Asterix Data Model</a>
</li>
<li class="nav-header">Queries - SQL++</li>
<li>
<a href="sqlpp/manual.html" title="The SQL++ Query Language">
<i class="none"></i>
The SQL++ Query Language</a>
</li>
<li>
<a href="sqlpp/builtins.html" title="Builtin Functions">
<i class="none"></i>
Builtin Functions</a>
</li>
<li class="nav-header">Queries - AQL</li>
<li>
<a href="aql/manual.html" title="The Asterix Query Language (AQL)">
<i class="none"></i>
The Asterix Query Language (AQL)</a>
</li>
<li>
<a href="aql/builtins.html" title="Builtin Functions">
<i class="none"></i>
Builtin Functions</a>
</li>
<li class="nav-header">API/SDK</li>
<li class="active">
<a href="#"><i class="none"></i>HTTP API</a>
</li>
<li>
<a href="csv.html" title="CSV Output">
<i class="none"></i>
CSV Output</a>
</li>
<li class="nav-header">Advanced Features</li>
<li>
<a href="aql/fulltext.html" title="Support of Full-text Queries">
<i class="none"></i>
Support of Full-text Queries</a>
</li>
<li>
<a href="aql/externaldata.html" title="Accessing External Data">
<i class="none"></i>
Accessing External Data</a>
</li>
<li>
<a href="feeds/tutorial.html" title="Support for Data Ingestion">
<i class="none"></i>
Support for Data Ingestion</a>
</li>
<li>
<a href="udf.html" title="User Defined Functions">
<i class="none"></i>
User Defined Functions</a>
</li>
<li>
<a href="aql/filters.html" title="Filter-Based LSM Index Acceleration">
<i class="none"></i>
Filter-Based LSM Index Acceleration</a>
</li>
<li>
<a href="aql/similarity.html" title="Support of Similarity Queries">
<i class="none"></i>
Support of Similarity Queries</a>
</li>
</ul>
<hr class="divider" />
<div id="poweredBy">
<div class="clear"></div>
<div class="clear"></div>
<div class="clear"></div>
<a href="./" title="AsterixDB" class="builtBy">
<img class="builtBy" alt="AsterixDB" src="images/asterixlogo.png" />
</a>
</div>
</div>
</div>
<div id="bodyColumn" class="span9" >
<!-- ! Licensed to the Apache Software Foundation (ASF) under one
! or more contributor license agreements. See the NOTICE file
! distributed with this work for additional information
! regarding copyright ownership. The ASF licenses this file
! to you under the Apache License, Version 2.0 (the
! "License"); you may not use this file except in compliance
! with the License. You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing,
! software distributed under the License is distributed on an
! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
! KIND, either express or implied. See the License for the
! specific language governing permissions and limitations
! under the License.
! --><h1>HTTP API to AsterixDB</h1>
<div class="section">
<h2><a name="Table_of_Contents"></a><a name="toc" id="toc">Table of Contents</a></h2>
<ul>
<li><a href="#queryservice">Query Service API</a></li>
<li><a href="#querystatus">Query Status API</a></li>
<li><a href="#queryresult">Query Result API</a></li>
</ul></div>
<div class="section">
<h2><a name="POST_queryservice_Back_to_TOC"></a><a name="queryservice" id="queryservice">POST /query/service</a><font size="4"> <a href="#toc">[Back to TOC]</a></font></h2>
<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>
<p><b>Parameters</b></p>
<ul>
<li><tt>statement</tt> - Specifies at least one valid SQL++ statement to run. The statements need to be urlencoded. Required.</li>
<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>
<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>
<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>
</ul>
<p><b>Command (immediate result delivery)</b></p>
<div class="source">
<div class="source">
<pre>$ curl -v --data-urlencode &quot;statement=select 1;&quot; \
--data pretty=true \
--data client_context_id=xyz \
http://localhost:19002/query/service
</pre></div></div>
<p><b>Sample response</b></p>
<div class="source">
<div class="source">
<pre>&gt; POST /query/service HTTP/1.1
&gt; Host: localhost:19002
&gt; User-Agent: curl/7.43.0
&gt; Accept: */*
&gt; Content-Length: 57
&gt; Content-Type: application/x-www-form-urlencoded
&gt;
&lt; HTTP/1.1 200 OK
&lt; transfer-encoding: chunked
&lt; connection: keep-alive
&lt; content-type: application/json; charset=utf-8
&lt;
{
&quot;requestID&quot;: &quot;5f72e78c-482a-45bf-b174-6443c8273025&quot;,
&quot;clientContextID&quot;: &quot;xyz&quot;,
&quot;signature&quot;: &quot;*&quot;,
&quot;results&quot;: [ {
&quot;$1&quot; : 1
} ]
,
&quot;status&quot;: &quot;success&quot;,
&quot;metrics&quot;: {
&quot;elapsedTime&quot;: &quot;20.263371ms&quot;,
&quot;executionTime&quot;: &quot;19.889389ms&quot;,
&quot;resultCount&quot;: 1,
&quot;resultSize&quot;: 15
}
}
</pre></div></div>
<p><b>Command (<a name="deferred" id="deferred">deferred result delivery</a>)</b></p>
<div class="source">
<div class="source">
<pre>$ curl -v --data-urlencode &quot;statement=select 1;&quot; \
--data mode=deferred \
http://localhost:19002/query/service
</pre></div></div>
<p><b>Sample response</b></p>
<div class="source">
<div class="source">
<pre>&gt; POST /query/service HTTP/1.1
&gt; Host: localhost:19002
&gt; User-Agent: curl/7.43.0
&gt; Accept: */*
&gt; Content-Length: 37
&gt; Content-Type: application/x-www-form-urlencoded
&gt;
&lt; HTTP/1.1 200 OK
&lt; transfer-encoding: chunked
&lt; connection: keep-alive
&lt; content-type: application/json; charset=utf-8
&lt;
{
&quot;requestID&quot;: &quot;6df7afb4-5f83-49b6-8c4b-f11ec84c4d7e&quot;,
&quot;signature&quot;: &quot;*&quot;,
&quot;handle&quot;: &quot;http://localhost:19002/query/service/result/7-0&quot;,
&quot;status&quot;: &quot;success&quot;,
&quot;metrics&quot;: {
&quot;elapsedTime&quot;: &quot;12.270570ms&quot;,
&quot;executionTime&quot;: &quot;11.948343ms&quot;,
&quot;resultCount&quot;: 0,
&quot;resultSize&quot;: 0
}
}
</pre></div></div>
<p><b>Command (<a name="async" id="async>">async result delivery</a>)</b></p>
<div class="source">
<div class="source">
<pre>$ curl -v --data-urlencode &quot;statement=select 1;&quot; \
--data mode=async \
http://localhost:19002/query/service
</pre></div></div>
<p><b>Sample response</b></p>
<div class="source">
<div class="source">
<pre>&gt; POST /query/service HTTP/1.1
&gt; Host: localhost:19002
&gt; User-Agent: curl/7.43.0
&gt; Accept: */*
&gt; Content-Length: 34
&gt; Content-Type: application/x-www-form-urlencoded
&gt;
&lt; HTTP/1.1 200 OK
&lt; transfer-encoding: chunked
&lt; connection: keep-alive
&lt; content-type: application/json; charset=utf-8
&lt;
{
&quot;requestID&quot;: &quot;c5858420-d821-4c0c-81a4-2364386827c2&quot;,
&quot;signature&quot;: &quot;*&quot;,
&quot;status&quot;: &quot;running&quot;,
&quot;handle&quot;: &quot;http://localhost:19002/query/service/status/9-0&quot;,
&quot;metrics&quot;: {
&quot;elapsedTime&quot;: &quot;9.727006ms&quot;,
&quot;executionTime&quot;: &quot;9.402282ms&quot;,
&quot;resultCount&quot;: 0,
&quot;resultSize&quot;: 0
}
}
</pre></div></div></div>
<div class="section">
<h2><a name="GET_queryservicestatus_Back_to_TOC"></a><a name="querystatus" id="querystatus">GET /query/service/status</a><font size="4"> <a href="#toc">[Back to TOC]</a></font></h2>
<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>
<p><b>Command</b></p>
<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>
<div class="source">
<div class="source">
<pre>$ curl -v http://localhost:19002/query/service/status/9-0
</pre></div></div>
<p><b>Sample response</b></p>
<div class="source">
<div class="source">
<pre>&gt; GET /query/service/status/9-0 HTTP/1.1
&gt; Host: localhost:19002
&gt; User-Agent: curl/7.43.0
&gt; Accept: */*
&gt;
&lt; HTTP/1.1 200 OK
&lt; transfer-encoding: chunked
&lt; connection: keep-alive
&lt; content-type: application/json; charset=utf-8
&lt;
{
&quot;status&quot;: &quot;success&quot;,
&quot;handle&quot;: &quot;http://localhost:19002/query/service/result/9-0&quot;
}
</pre></div></div></div>
<div class="section">
<h2><a name="GET_queryserviceresult_Back_to_TOC"></a><a name="queryresult" id="queryresult">GET /query/service/result</a><font size="4"> <a href="#toc">[Back to TOC]</a></font></h2>
<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>
<p><b>Command</b></p>
<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>
<div class="source">
<div class="source">
<pre>$ curl -v http://localhost:19002/query/service/result/7-0
</pre></div></div>
<p><b>Sample response</b></p>
<div class="source">
<div class="source">
<pre>&gt; GET /query/service/result/7-0 HTTP/1.1
&gt; Host: localhost:19002
&gt; User-Agent: curl/7.43.0
&gt; Accept: */*
&gt;
&lt; HTTP/1.1 200 OK
&lt; transfer-encoding: chunked
&lt; connection: keep-alive
&lt; content-type: application/json
&lt;
[ { &quot;$1&quot;: 1 }
]
</pre></div></div></div>
</div>
</div>
</div>
<hr/>
<footer>
<div class="container-fluid">
<div class="row span12">Copyright &copy; 2018
<a href="https://www.apache.org/">The Apache Software Foundation</a>.
All Rights Reserved.
</div>
<?xml version="1.0" encoding="UTF-8"?>
<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache
feather logo, and the Apache AsterixDB project logo are either
registered trademarks or trademarks of The Apache Software
Foundation in the United States and other countries.
All other marks mentioned may be trademarks or registered
trademarks of their respective owners.</div>
</div>
</footer>
</body>
</html>