ArangoDB

REST Interface for storing key-value pairs

Create a new key-value pair in the data store.

Creates a new key-value pair with the given key, the data passed in content and optional attributes passed in the header. If a key-value pair with the same key exists in the data store, the request returns an error.

POST /_api/key/collection-name/key

Optional Attributes:

  • x-voc-expires Expiry-date for this key-value pair.
  • x-voc-extended A JSON-object of one or more attributes to be attached to the key-value pair.
  • TODO binary data

If the document was created successfully, then a HTTP 201 is returned.

If the collection-name is unknown, then a HTTP 404 is returned.

If the key is used, then a HTTP 404 is returned.

Examples

Create a key-value pair

  POST /_api/key/example_collection/example_key1 HTTP/1.1
  Host: localhost:9000
  x-voc-expires: 2011-09-29T08:00:00Z
  x-voc-extended: {"option1":35,"option2":"x"}
  Content-Length: 2
  
  12

Response (Success)

  HTTP/1.1 201 Created
  connection: Keep-Alive
  content-type: application/json
  server: triagens GmbH High-Performance HTTP Server
  content-length: 62

  {"saved":true,"_id":"155630:9500735","error":false,"code":201}

Response (Failure)

  HTTP/1.1 404 Bad Request
  content-type: application/json
  connection: Keep-Alive
  server: triagens GmbH High-Performance HTTP Server
  content-length: 75

  {"error":true,"code":404,"errorNum":41304,"errorMessage":"Use PUT to change value"}

Creates or changes the value for a given key.

Sets the value associated with key to the new data passed in content.

PUT /_api/key/collection-name/key

Optional parameter:

  • ?create=1 When set to 1 database will create keys if they do not exist. When set to 0 (default) it will return an error if a key does not exist.

If the document was updated successfully, then a HTTP 202 is returned.

If the collection-name is unknown, then a HTTP 404 is returned.

If the key is not found and ?create=0, then a HTTP 404 is returned.

Examples

Update a key-value pair

  PUT /_api/key/example_collection/example_key1 HTTP/1.1
  Host: localhost:9000
  x-voc-expires: 2011-09-29T08:00:00Z
  x-voc-extended: {"option1":35,"option2":"x"}
  Content-Length: 2

  13

Response (Success)

  HTTP/1.1 202 Accepted
  connection: Keep-Alive
  content-type: application/json
  server: triagens GmbH High-Performance HTTP Server
  content-length: 41

  {"changed":true,"error":false,"code":202}

Response (Failure)

  HTTP/1.1 404 Bad Request
  ...

  {"error":true,"code":404,"errorNum":41404,"errorMessage":"Key value pair not found"}

Returns the value associated with a given key.

Returns the value associated with the key in content. The Attributes of the key-value pair are returned in the header.

GET /_api/key/collection-name/key

If the document was found, then a HTTP 200 is returned.

If the collection-name is unknown, then a HTTP 404 is returned.

If the key is not found, then a HTTP 404 is returned.

Examples

Get a key-value pair

  GET /_api/key/example_collection/example_key1 HTTP/1.1
  Host: localhost:9000

Response (Success) with attributes

  HTTP/1.1 200 OK
  x-voc-created: 2010-09-15T09:35:01Z
  x-voc-expires: 2011-09-29T08:00:00Z
  x-voc-extended: {"option1":35,"option2":"x"}
  ...

  13

Response (Failure)

  HTTP/1.1 404 Bad Request
  ...

  {"error":true,"code":404,"errorNum":41404,"errorMessage":"Key value pair not found"}

This function deletes a key-value pair from the data store.

Deletes the key-value pair with key from the store. Deletions cannot be undone!

DELETE /_api/key/collection-name/key

This function does not support any header parameters.

If the document was found and deleted, then a HTTP 200 is returned.

If the collection-name is unknown, then a HTTP 404 is returned.

If the key is not found, then a HTTP 404 is returned.

Examples

Delete a key-value pair

  DELETE /_api/key/example_collection/example_key1 HTTP/1.1
  Host: localhost:9000

Response (Success)

  HTTP/1.1 200 OK
  ...
  
  {"removed":true,"error":false,"code":202}

Response (Failure)

  HTTP/1.1 404 Bad Request
  ...
  
  {"error":true,"code":404,"errorNum":41404,"errorMessage":"Key value pair not found"}

This function returns all keys matching a given prefix.

Retrieves all values that begin with key and returns them as a JSON-array in content.

GET /_api/keys/collection-name/prefix

prefix (=beginning of word) to search for. Note that any /-characters contained in key are considered part of the key and have no special meaning.

TODO Optional parameter:

  • ?filter=Filter Expression Return only those keys that match the given filter expression (have certain attributes). Please note that the filter expression has to be URL-encoded

If the collection-name is unknown, then a HTTP 404 is returned.

Examples

Find keys by prefix

  GET /_api/keys/example_collection/example_key HTTP/1.1
  Host: localhost:9000

Response (Success)

  HTTP/1.1 200 OK
  ...

  ["example_keyboard","example_keystone"]

Response (Failure)

  HTTP/1.1 404 Bad Request
  ...

  {"error":true,"code":404,"errorNum":41404,"errorMessage":"Collection not found"}