HTTP interface for databases
The HTTP API for databases lets you create and delete databases, list available databases, and get information about specific databases
The HTTP interface for databases provides operations to create and drop
individual databases. These are mapped to the standard POST and DELETE
HTTP methods. There is also the GET method to retrieve an array of existing
databases.
_system database and none of the other databases.Addresses of databases
Any operation triggered via ArangoDB’s RESTful HTTP API is executed in the
context of exactly one database. The database name is read from the first part
of the request URI path (e.g. /_db/mydb/...). If the request URI does not
contain a database name, it defaults to /_db/_system.
To explicitly specify the database in a request, the request URI must contain the database name at the beginning of the path:
http://localhost:8529/_db/mydb/...
The ... placeholder is the actual path to the accessed resource. In the example,
the resource is accessed in the context of the mydb database. Actual URLs in
the context of mydb could look like this:
http://localhost:8529/_db/mydb/_api/version
http://localhost:8529/_db/mydb/_api/document/test/12345
http://localhost:8529/_db/mydb/myapp/get
_system database as the context.Special characters in database names must be properly URL-encoded, e.g.
a + b = c needs to be encoded as a%20%2B%20b%20%3D%20c:
http://localhost:8529/_db/a%20%2B%20b%20%3D%20c/_api/version
Database names containing Unicode must be properly NFC-normalized . Non-NFC-normalized names are rejected by the server.
Manage databases
Get information about the current database
Retrieves the properties of the current database
The response is a JSON object with the following attributes:
name: the name of the current databaseid: the id of the current databasepath: the filesystem path of the current databaseisSystem: whether or not the current database is the_systemdatabasesharding: the default sharding method for collections created in this databasereplicationFactor: the default replication factor for collections in this databasewriteConcern: the default write concern for collections in this database
Examples
curl --header 'accept: application/json' --dump - 'http://localhost:8529/_api/database/current'Show output
HTTP/1.1 200 OK
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 93
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
{
"error" : false,
"code" : 200,
"result" : {
"id" : "1",
"name" : "_system",
"isSystem" : true,
"path" : "none"
}
}List the accessible databases
Examples
curl --header 'accept: application/json' --dump - 'http://localhost:8529/_api/database/user'Show output
HTTP/1.1 200 OK
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 47
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
{
"error" : false,
"code" : 200,
"result" : [
"_system"
]
}List all databases
Retrieves the list of all existing databases
_system database.Examples
curl --header 'accept: application/json' --dump - 'http://localhost:8529/_db/_system/_api/database'Show output
HTTP/1.1 200 OK
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 47
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
{
"error" : false,
"code" : 200,
"result" : [
"_system"
]
}Create a database
Creates a new database.
The response is a JSON object with the attribute result set to true.
_system database.name* string
Has to contain a valid database name. The name must conform to the selected naming convention for databases. If the name contains Unicode characters, the name must be NFC-normalized . Non-normalized names are rejected.
options object
Optional object which can contain the following attributes:
replicationFactor integer
Default replication factor for new collections created in this database. (cluster only)
Special values:
"satellite": Replicate the collection to every DB-Server1: Disable replication
You can configure the global default with the
--cluster.default-replication-factorstartup option.sharding string (default:
"")Possible values:
"","flexible","single"The sharding method to use for new collections in this database. (cluster only) Valid values are:
""or"flexible": Create a database where collections can be sharded independently."single": Create a OneShard database where all collections have a single shard and all leader shards are co-located on the same DB-Server.
writeConcern number
Default write concern for new collections created in this database. It determines how many copies of each shard are required to be in sync on the different DB-Servers. If there are less than these many copies in the cluster, a shard refuses to write. Writes to shards with enough up-to-date copies succeed at the same time, however. The value of
writeConcerncannot be greater thanreplicationFactor.For SatelliteCollections, the
writeConcernis automatically controlled to equal the number of DB-Servers and has a value of0. Otherwise, the default value is controlled by the--cluster.write-concernstartup option, which defaults to1. (cluster only)
users array of objects
An array of user objects. The users are granted Administrate permissions for the new database. Users that do not exist yet are created. If
usersis not specified or does not contain any users, the default userrootis used to ensure that the new database is accessible after it is created. Therootuser is created with an empty password should it not exist. Each user object can contain the following attributes:
Examples
Creating a database named example.
curl -X POST --header 'accept: application/json' --data-binary @- --dump - 'http://localhost:8529/_db/_system/_api/database' <<'EOF'
{
"name": "example",
"options": {
"sharding": "flexible",
"replicationFactor": 3
}
}
EOFShow output
HTTP/1.1 201 Created
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 40
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
{
"error" : false,
"code" : 201,
"result" : true
}Creating a database named mydb with two users, flexible sharding and
default replication factor of 3 for collections that will be part of
the newly created database.
curl -X POST --header 'accept: application/json' --data-binary @- --dump - 'http://localhost:8529/_db/_system/_api/database' <<'EOF'
{
"name": "mydb",
"users": [
{
"username": "admin",
"passwd": "secret",
"active": true
},
{
"username": "tester",
"passwd": "test001",
"active": false
}
]
}
EOFShow output
HTTP/1.1 201 Created
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 40
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
{
"error" : false,
"code" : 201,
"result" : true
}Drop a database
Drops the database along with all data stored in it.
_system database.
The _system database itself cannot be dropped.Examples
curl -X DELETE --header 'accept: application/json' --dump - 'http://localhost:8529/_db/_system/_api/database/example'Show output
HTTP/1.1 200 OK
content-type: application/json
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0
connection: Keep-Alive
content-length: 40
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
{
"error" : false,
"code" : 200,
"result" : true
}