Since BaseX 10, results in the {{Code|rest}} namespace are returned unprefixed:
<syntaxhighlight pre lang="xml">
<!-- before -->
<rest:databases xmlns:rest="http://basex.org/rest"/>
<!-- before BaseX 10 -->
<databases xmlns="http://basex.org/rest"/>
</syntaxhighlightpre>
=URL Architecture=
:<code>http://localhost:8080/rest</code>
<syntaxhighlight pre lang="xml">
<databases xmlns="http://basex.org/rest">
<database resources="25742" size="43813599">articles</database>
...
</databases>
</syntaxhighlightpre>
The resources of a database (directories, resource metadata) are listed if a database and an optional directory path is specified:
:<code>http://localhost:8080/rest/articles</code>
<syntaxhighlight pre lang="xml">
<database name="articles" xmlns="http://basex.org/rest">
<dir>binaries</dir>
...
</database>
</syntaxhighlightpre>
If the path to a single resource is specified, the resource itself will be returned:
Create an empty database and return database information:
<syntaxhighlight pre lang="xml">
<commands>
<create-db name='db'/>
<info-db/>
</commands>
</syntaxhighlightpre>
Return the first five city names of the <b>factbook</b> database:
<syntaxhighlight pre lang="xml">
<rest xmlns="http://basex.org/rest">
<rest><![CDATA[ (//city/name)[position() <= 5] ]]></text>
</rest>
</syntaxhighlightpre>
Return string lengths of all text nodes that are found in the node that has been specified as initial context node:
<syntaxhighlight pre lang="xml">
<query>
<text>for $i in .//text() return string-length($i)</text>
</context>
</query>
</syntaxhighlightpre>
Return the registered database users encoded in <code>ISO-8859-1</code>:
<syntaxhighlight pre lang="xml">
<command>
<text>show users</text>
<parameter name='encoding' value='ISO-8859-1'/>
</command>
</syntaxhighlightpre>
Create a new database from the specified input and preserve all whitespaces:
<syntaxhighlight pre lang="xml">
<command>
<text>create db test http://files.basex.org/xml/xmark.xml</text>
<option name='chop' value='false'/>
</command>
</syntaxhighlightpre>
Bind value to the {{Code|$person}} variable and run query <code>find-person.xq</code>:
<syntaxhighlight pre lang="xml">
<run>
<variable name='person' value='Johannes Müller'/>
<text>find-person.xq</text>
</run>
</syntaxhighlightpre>
==PUT Method==
; Example
The request <code>http://localhost:8080/rest?run=multiply.xq&a=21&b=2</code> assigns two variables and invokes <code>multiply.xq</code>:<syntaxhighlight pre lang="'xquery"'>
(: XQuery file: multiply.xq :)
declare variable $a as xs:integer external;
declare variable $b as xs:integer external;
<mult>{ $a * $b }</mult>
</syntaxhighlightpre>
; Example
{{Announce|Updated with Version 11:}} Support for multiple values.
The request <code>http://localhost:8080/rest?run=sum.xq&n=3&n=4&n=5</code> assigns multiple values to the same variable:<syntaxhighlight pre lang="'xquery"'>
(: XQuery file: sum.xq :)
declare variable $n as xs:integer* external;
sum($n)
</syntaxhighlightpre>
The dollar sign can be omitted as long as the variable name does not equal a parameter keyword (e.g.: <code>method</code>).
If <code>query</code> or <code>run</code> is used as an operation, external variables can be specified via the <code><variable/></code> element:
<syntaxhighlight pre lang="xml">
<query xmlns="http://basex.org/rest">
<text><![CDATA[
<variable name="b" value="2"/>
</query>
</syntaxhighlightpre>
=Response=
<code>org.basex.util.Base64</code> can be used for that purpose:
<syntaxhighlight pre lang="java">
import java.net.*;
import org.basex.util.*;
}
}
</syntaxhighlightpre>
===Content-Types===
the connection (in this example we explicitly store the input file as raw):
<syntaxhighlight pre lang="java">
// store input as raw
conn.setRequestProperty("Content-Type", "application/octet-stream");
</syntaxhighlightpre>
See the [[REST#PUT Requests|PUT Requests]] section for a description of the possible content-types.
;Version 11.0
* Updated: [[#Request|Request]]: The extensions {{Code|.xq}} and {{Code|.bxs}} are successively attached to the supplied filename.
* Updated: [[#Assigning Variables|Assigning Variables]]: Support for multiple values.