ArangoDB v2.8 reached End of Life (EOL) and is no longer supported.

This documentation is outdated. Please see the most recent version here: Try latest

Database Management

This is an introduction to ArangoDB’s HTTP interface for managing databases.

The HTTP interface for databases provides operations to create and drop individual databases. These are mapped to the standard HTTP methods POST and DELETE. There is also the GET method to retrieve an array of existing databases.

Please note that all database management operations can only be accessed via the default database (_system) and none of the other databases.

Managing Databases using HTTP

Information of the database

retrieves information about the current database

GET /_api/database/current

Retrieves information about the current database
The response is a JSON object with the following attributes:

  • name: the name of the current database
  • id: the id of the current database
  • path: the filesystem path of the current database
  • isSystem: whether or not the current database is the _system database

    Return codes

    • 200: is returned if the information was retrieved successfully.

    • 400: is returned if the request is invalid.

    • 404: is returned if the database could not be found.

Examples

shell> curl --dump - http://localhost:8529/_api/database/current

HTTP/1.1 200 OK
content-type: application/json; charset=utf-8

show response body

List of accessible databases

retrieves a list of all databases the current user can access

GET /_api/database/user

Retrieves the list of all databases the current user can access without specifying a different username or password.

Return codes

  • 200: is returned if the list of database was compiled successfully.

  • 400: is returned if the request is invalid.

Examples

shell> curl --dump - http://localhost:8529/_api/database/user

HTTP/1.1 200 OK
content-type: application/json; charset=utf-8

show response body

List of databases

retrieves a list of all existing databases

GET /_api/database

Retrieves the list of all existing databases
Note: retrieving the list of databases is only possible from within the _system database.

Return codes

  • 200: is returned if the list of database was compiled successfully.

  • 400: is returned if the request is invalid.

  • 403: is returned if the request was not executed in the _system database.

Examples

shell> curl --dump - http://localhost:8529/_api/database

HTTP/1.1 200 OK
content-type: application/json; charset=utf-8

show response body

Create database

creates a new database

POST /_api/database

A JSON object with these properties is required:

  • name: Has to contain a valid database name.

  • username: The user name as a string. If users is not specified or does not contain any users, a default user root will be created with an empty string password. This ensures that the new database will be accessible after it is created.

  • passwd: The user password as a string. If not specified, it will default to an empty string.

  • active: A Flag indicating whether the user account should be activated or not. The default value is true.

  • extra: A JSON object with extra user information. The data contained in extra will be stored for the user but not be interpreted further by ArangoDB.

  • users: Has to be a list of user objects to initially create for the new database. Each user object can contain the following attributes:

    • username: Loginname of the user to be created
    • passwd: Password for the user
    • active: if False the user won’t be able to log into the database.
      Creates a new database
      The response is a JSON object with the attribute result set to true.
      Note: creating a new database is only possible from within the _system database.

      Return codes
  • 201: is returned if the database was created successfully.

  • 400: is returned if the request parameters are invalid or if a database with the specified name already exists.

  • 403: is returned if the request was not executed in the _system database.

  • 409: is returned if a database with the specified name already exists.

Examples
Creating a database named example.

shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/database <<EOF
{ 
  "name" : "example" 
}
EOF

HTTP/1.1 201 Created
content-type: application/json; charset=utf-8

show response body


Creating a database named mydb with two users.

shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/database <<EOF
{ 
  "name" : "mydb", 
  "users" : [ 
    { 
      "username" : "admin", 
      "passwd" : "secret", 
      "active" : true 
    }, 
    { 
      "username" : "tester", 
      "passwd" : "test001", 
      "active" : false 
    } 
  ] 
}
EOF

HTTP/1.1 201 Created
content-type: application/json; charset=utf-8

show response body

Drop database

drop an existing database

DELETE /_api/database/{database-name}

Path Parameters

  • database-name (required): The name of the database
    Drops the database along with all data stored in it.
    Note: dropping a database is only possible from within the _system database. The _system database itself cannot be dropped.

    Return codes

  • 200: is returned if the database was dropped successfully.

  • 400: is returned if the request is malformed.

  • 403: is returned if the request was not executed in the _system database.

  • 404: is returned if the database could not be found.

Examples

shell> curl -X DELETE --dump - http://localhost:8529/_api/database/example

HTTP/1.1 200 OK
content-type: application/json; charset=utf-8

show response body