{
"basePath": "/",
"swaggerVersion": "1.1",
"apiVersion": "0.1",
"apis": [
{
"operations": [
{
"errorResponses": [
{
"reason": "is returned if the result set can be created by the server. ",
"code": "201"
},
{
"reason": "is returned if the JSON representation is malformed or the query specification is missing from the request. ",
"code": "400"
}
],
"parameters": [
{
"dataType": "Json",
"paramType": "body",
"required": "true",
"name": "query",
"description": "The following attributes can be used inside the JSON object: - query: contains the query string to be executed (mandatory) - count: boolean flag that indicates whether the number of documents found should be returned as \"count\" attribute in the result set (optional). Calculating the \"count\" attribute might have a performance penalty for some queries so this option is turned off by default. - batchSize: maximum number of result documents to be transferred from the server to the client in one roundtrip (optional). If this attribute is not set, a server-controlled default value will be used. - bindVars: key/value list of bind parameters (optional). "
}
],
"notes": "The query details include the query string plus optional query options and bind parameters. These values need to be passed in a JSON representation in the body of the POST request.
The following attributes can be used inside the JSON object:
- query: contains the query string to be executed (mandatory)
- count: boolean flag that indicates whether the number of documents found should be returned as \"count\" attribute in the result set (optional). Calculating the \"count\" attribute might have a performance penalty for some queries so this option is turned off by default.
- batchSize: maximum number of result documents to be transferred from the server to the client in one roundtrip (optional). If this attribute is not set, a server-controlled default value will be used.
- bindVars: key/value list of bind parameters (optional).
If the result set can be created by the server, the server will respond with HTTP 201. The body of the response will contain a JSON object with the result set.
The JSON object has the following properties:
- error: boolean flag to indicate that an error occurred (false in this case)
- code: the HTTP status code
- result: an array of result documents (might be empty if query has no results)
- hasMore: a boolean indicator whether there are more results available on the server
- count: the total number of result documents available (only available if the query was executed with the count attribute set.
- id: id of temporary cursor created on the server (optional, see above)
If the JSON representation is malformed or the query specification is missing from the request, the server will respond with HTTP 400.
The body of the response will contain a JSON object with additional error details. The object has the following attributes:
- error: boolean flag to indicate that an error occurred (true in this case)
- code: the HTTP status code
- errorNum: the server error number
- errorMessage: a descriptive error message
If the query specification is complete, the server will process the query. If an error occurs during query processing, the server will respond with HTTP 400. Again, the body of the response will contain details about the error.
A list of query errors can be found @ref ArangoErrors here.
",
"summary": "creates a cursor",
"httpMethod": "POST",
"examples": "Executes a query and extract the result in a single go:
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/cursor\n{ \"query\" : \"FOR p IN products LIMIT 2 RETURN p\", \"count\" : true, \"batchSize\" : 2 }\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n \"result\" : [ \n { \n \"_id\" : \"products/134753500\", \n \"_rev\" : \"134753500\", \n \"_key\" : \"134753500\", \n \"hello1\" : \"world1\" \n }, \n { \n \"_id\" : \"products/135081180\", \n \"_rev\" : \"135081180\", \n \"_key\" : \"135081180\", \n \"hello2\" : \"world1\" \n } \n ], \n \"hasMore\" : false, \n \"count\" : 2, \n \"error\" : false, \n \"code\" : 201 \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/cursor\n{ \"query\" : \"FOR p IN products LIMIT 5 RETURN p\", \"count\" : true, \"batchSize\" : 2 }\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n \"result\" : [ \n { \n \"_id\" : \"products/165424348\", \n \"_rev\" : \"165424348\", \n \"_key\" : \"165424348\", \n \"hello4\" : \"world1\" \n }, \n { \n \"_id\" : \"products/165686492\", \n \"_rev\" : \"165686492\", \n \"_key\" : \"165686492\", \n \"hello5\" : \"world1\" \n } \n ], \n \"hasMore\" : true, \n \"id\" : \"165817564\", \n \"count\" : 5, \n \"error\" : false, \n \"code\" : 201 \n}\n\n
unix> curl -X POST --dump - http://localhost:8529/_api/cursor\n\nHTTP/1.1 400 Bad Request\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"code\" : 400, \n \"errorNum\" : 1502, \n \"errorMessage\" : \"query is empty\" \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/cursor\n{ \"query\" : \"FOR u IN unknowncoll LIMIT 2 RETURN u\", \"count\" : true, \"batchSize\" : 2 }\n\nHTTP/1.1 400 Bad Request\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"code\" : 400, \n \"errorNum\" : 1203, \n \"errorMessage\" : \"cannot execute query: collection not found\" \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/cursor\n{ \"query\" : \"FOR p IN products LIMIT 5 RETURN p\", \"count\" : true, \"batchSize\" : 2 }\n\nunix> curl -X PUT --dump - http://localhost:8529/_api/cursor/226962652\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\n\n{ \n \"result\" : [ \n { \n \"_id\" : \"products/226045148\", \n \"_rev\" : \"226045148\", \n \"_key\" : \"226045148\", \n \"hello2\" : \"world1\" \n }, \n { \n \"_id\" : \"products/225717468\", \n \"_rev\" : \"225717468\", \n \"_key\" : \"225717468\", \n \"hello1\" : \"world1\" \n } \n ], \n \"hasMore\" : true, \n \"id\" : \"226962652\", \n \"count\" : 5, \n \"error\" : false, \n \"code\" : 200 \n}\n\n
unix> curl -X PUT --dump - http://localhost:8529/_api/cursor\n\nHTTP/1.1 400 Bad Request\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"code\" : 400, \n \"errorNum\" : 400, \n \"errorMessage\" : \"bad parameter\" \n}\n\n
unix> curl -X PUT --dump - http://localhost:8529/_api/cursor/123123\n\nHTTP/1.1 400 Bad Request\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"code\" : 400, \n \"errorNum\" : 1600, \n \"errorMessage\" : \"cursor not found\" \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/cursor\n{ \"query\" : \"FOR p IN products LIMIT 5 RETURN p\", \"count\" : true, \"batchSize\" : 2 }\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n \"result\" : [ \n { \n \"_id\" : \"products/232074460\", \n \"_rev\" : \"232074460\", \n \"_key\" : \"232074460\", \n \"hello2\" : \"world1\" \n }, \n { \n \"_id\" : \"products/232336604\", \n \"_rev\" : \"232336604\", \n \"_key\" : \"232336604\", \n \"hello3\" : \"world1\" \n } \n ], \n \"hasMore\" : true, \n \"id\" : \"232991964\", \n \"count\" : 5, \n \"error\" : false, \n \"code\" : 201 \n}\n\nunix> curl -X DELETE --dump - http://localhost:8529/_api/cursor/232991964\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\n\n{ \n \"id\" : \"232991964\", \n \"error\" : false, \n \"code\" : 202 \n}\n\n