{ "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" }, { "reason": "The server will respond with HTTP 404 in case a non-existing collection is accessed in the query. ", "code": "404" }, { "reason": "The server will respond with HTTP 405 if an unsupported HTTP method is used. ", "code": "405" } ], "parameters": [ { "dataType": "Json", "paramType": "body", "required": "true", "name": "query", "description": "A JSON object describing the query and query parameters. " } ], "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 in the result set should be returned in the \"count\" attribute of the result (optional). Calculating the \"count\" attribute might in the future have a performance impact for some queries so this option is turned off by default, and \"count\" is only returned when requested.

- 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).

- options: key/value list of extra options for the query (optional).

The following options are supported at the moment:

- fullCount: if set to true and the query contains a LIMIT clause, then the result will contain an extra attribute extra with a sub-attribute fullCount. This sub-attribute will contain the number of documents in the result before the last LIMIT in the query was applied. It can be used to count the number of documents that match certain filter criteria, but only return a subset of them, in one go. It is thus similar to MySQL's SQL_CALC_FOUND_ROWS hint. Note that setting the option will disable a few LIMIT optimisations and may lead to more documents being processed, and thus make queries run longer. Note that the fullCount sub-attribute will only be present in the result if the query has a LIMIT clause and the LIMIT clause is actually used in the query.

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 returned 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 for the cursor 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)

- extra: an optional JSON object with extra information about the query result

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 the manual 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/55263655\", \n      \"_rev\" : \"55263655\", \n      \"_key\" : \"55263655\", \n      \"hello2\" : \"world1\" \n    }, \n    { \n      \"_id\" : \"products/54870439\", \n      \"_rev\" : \"54870439\", \n      \"_key\" : \"54870439\", \n      \"hello1\" : \"world1\" \n    } \n  ], \n  \"hasMore\" : false, \n  \"count\" : 2, \n  \"error\" : false, \n  \"code\" : 201 \n}\n\n

Executes a query and extracts part of the result:

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/56312231\", \n      \"_rev\" : \"56312231\", \n      \"_key\" : \"56312231\", \n      \"hello1\" : \"world1\" \n    }, \n    { \n      \"_id\" : \"products/57688487\", \n      \"_rev\" : \"57688487\", \n      \"_key\" : \"57688487\", \n      \"hello5\" : \"world1\" \n    } \n  ], \n  \"hasMore\" : true, \n  \"id\" : \"57885095\", \n  \"count\" : 5, \n  \"error\" : false, \n  \"code\" : 201 \n}\n\n

Using a query option:

unix> curl -X POST --data @- --dump - http://localhost:8529/_api/cursor\n{\"query\":\"FOR i IN 1..1000 FILTER i > 500 LIMIT 10 RETURN i\",\"count\":true,\"options\":{\"fullCount\":true}}\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\n\n{ \n  \"result\" : [ \n    501, \n    502, \n    503, \n    504, \n    505, \n    506, \n    507, \n    508, \n    509, \n    510 \n  ], \n  \"hasMore\" : false, \n  \"count\" : 10, \n  \"extra\" : { \n    \"fullCount\" : 500 \n  }, \n  \"error\" : false, \n  \"code\" : 201 \n}\n\n

Bad queries: Missing body:

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

Unknown collection:

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 404 Not Found\ncontent-type: application/json; charset=utf-8\n\n{ \n  \"error\" : true, \n  \"code\" : 404, \n  \"errorNum\" : 1203, \n  \"errorMessage\" : \"cannot execute query: collection not found: 'unknowncoll'\" \n}\n\n

", "nickname": "createsACursor" } ], "path": "/_api/cursor" }, { "operations": [ { "errorResponses": [ { "reason": "The server will respond with HTTP 200 in case of success. ", "code": "200" }, { "reason": "If the cursor identifier is ommitted, the server will respond with HTTP 404. ", "code": "400" }, { "reason": "If no cursor with the specified identifier can be found, the server will respond with HTTP 404. ", "code": "404" } ], "parameters": [ { "dataType": "String", "paramType": "path", "required": "true", "name": "cursor-identifier", "description": "The name of the cursor " } ], "notes": "

If the cursor is still alive, returns an object with the following attributes.

- id: the cursor-identifier- result: a list of documents for the current batch- hasMore: false if this was the last batch- count: if present the total number of elements

Note that even if hasMore returns true, the next call might still return no documents. If, however, hasMore is false, then the cursor is exhausted. Once the hasMore attribute has a value of false, the client can stop.

", "summary": "reads next batch from a cursor", "httpMethod": "PUT", "examples": "Valid request for next batch:

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/60440999\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\n\n{ \n  \"result\" : [ \n    { \n      \"_id\" : \"products/59916711\", \n      \"_rev\" : \"59916711\", \n      \"_key\" : \"59916711\", \n      \"hello4\" : \"world1\" \n    }, \n    { \n      \"_id\" : \"products/59261351\", \n      \"_rev\" : \"59261351\", \n      \"_key\" : \"59261351\", \n      \"hello2\" : \"world1\" \n    } \n  ], \n  \"hasMore\" : true, \n  \"id\" : \"60440999\", \n  \"count\" : 5, \n  \"error\" : false, \n  \"code\" : 200 \n}\n\n

Missing identifier

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

Unknown identifier

unix> curl -X PUT --dump - http://localhost:8529/_api/cursor/123123\n\nHTTP/1.1 404 Not Found\ncontent-type: application/json; charset=utf-8\n\n{ \n  \"error\" : true, \n  \"code\" : 404, \n  \"errorNum\" : 1600, \n  \"errorMessage\" : \"cursor not found\" \n}\n\n

", "nickname": "readsNextBatchFromACursor" } ], "path": "/_api/cursor/{cursor-identifier}" }, { "operations": [ { "errorResponses": [ { "reason": "is returned if the server is aware of the cursor. ", "code": "202" }, { "reason": "is returned if the server is not aware of the cursor. It is also returned if a cursor is used after it has been destroyed. ", "code": "404" } ], "parameters": [ { "dataType": "String", "paramType": "path", "required": "true", "name": "cursor-identifier", "description": "The name of the cursor " } ], "notes": "Deletes the cursor and frees the resources associated with it.

The cursor will automatically be destroyed on the server when the client has retrieved all documents from it. The client can also explicitly destroy the cursor at any earlier time using an HTTP DELETE request. The cursor id must be included as part of the URL.

Note: the server will also destroy abandoned cursors automatically after a certain server-controlled timeout to avoid resource leakage.

", "summary": "deletes a cursor", "httpMethod": "DELETE", "examples": "

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/61751719\", \n      \"_rev\" : \"61751719\", \n      \"_key\" : \"61751719\", \n      \"hello2\" : \"world1\" \n    }, \n    { \n      \"_id\" : \"products/62079399\", \n      \"_rev\" : \"62079399\", \n      \"_key\" : \"62079399\", \n      \"hello3\" : \"world1\" \n    } \n  ], \n  \"hasMore\" : true, \n  \"id\" : \"62931367\", \n  \"count\" : 5, \n  \"error\" : false, \n  \"code\" : 201 \n}\n\nunix> curl -X DELETE --dump - http://localhost:8529/_api/cursor/62931367\n\n

", "nickname": "deletesACursor" } ], "path": "/_api/cursor/{cursor-identifier}" } ] }