Getting Information about a Collection
Return information about a collection
returns a collection
GET /_api/collection/{collection-name}
Accessing collections by their numeric ID is deprecated from version 3.4.0 on. You should reference them via their names instead.
Path Parameters
- collection-name (string, required): The name of the collection.
The result is an object describing the collection with the following attributes:
-
id: The identifier of the collection.
-
name: The name of the collection.
-
status: The status of the collection as number.
- 3: loaded
- 5: deleted
Every other status indicates a corrupted collection.
- type: The type of the collection as number.
- 2: document collection (normal case)
- 3: edge collection
- isSystem: If true then the collection is a system collection.
Responses
HTTP 404: If the collection-name is unknown, then a HTTP 404 is returned.
Read properties of a collection
reads the properties of the specified collection
GET /_api/collection/{collection-name}/properties
Accessing collections by their numeric ID is deprecated from version 3.4.0 on. You should reference them via their names instead.
Path Parameters
- collection-name (string, required): The name of the collection.
Responses
HTTP 400: If the collection-name is missing, then a HTTP 400 is returned.
HTTP 404: If the collection-name is unknown, then a HTTP 404 is returned.
HTTP 200:
-
waitForSync (boolean): If
true
, creating, changing, or removing documents waits until the data has been synchronized to disk. -
schema (object): An object that specifies the collection-level schema for documents.
-
computedValues (array): A list of objects, each representing a computed value.
-
name (string): The name of the target attribute.
-
expression (string): An AQL
RETURN
operation with an expression that computes the desired value. -
overwrite (boolean): Whether the computed value takes precedence over a user-provided or existing attribute.
-
computeOn (array of strings): An array of strings that defines on which write operations the value is computed. The possible values are
"insert"
,"update"
, and"replace"
. -
keepNull (boolean): Whether the target attribute is set if the expression evaluates to
null
. -
failOnWarning (boolean): Whether the write operation fails if the expression produces a warning.
-
-
keyOptions (object): An object which contains key generation options.
- type (string):
Specifies the type of the key generator. Possible values:
"traditional"
"autoincrement"
"uuid"
"padded"
-
allowUserKeys (boolean): If set to
true
, then you are allowed to supply own key values in the_key
attribute of a document. If set tofalse
, then the key generator is solely responsible for generating keys and an error is raised if you supply own key values in the_key
attribute of documents. -
increment (integer): The increment value for the
autoincrement
key generator. Not used for other key generator types. -
offset (integer): The initial offset value for the
autoincrement
key generator. Not used for other key generator types. - lastValue (integer):
The current offset value of the
autoincrement
orpadded
key generator. This is an internal property for restoring dumps properly.
- type (string):
Specifies the type of the key generator. Possible values:
-
cacheEnabled (boolean): Whether the in-memory hash cache for documents is enabled for this collection.
-
numberOfShards (integer): The number of shards of the collection. (cluster only)
-
shardKeys (array of strings): Contains the names of document attributes that are used to determine the target shard for documents. (cluster only)
-
replicationFactor (integer): Contains how many copies of each shard are kept on different DB-Servers. It is an integer number in the range of 1-10 or the string
"satellite"
for a SatelliteCollection (Enterprise Edition only). (cluster only) -
writeConcern (integer): Determines how many copies of each shard are required to be in sync on the different DB-Servers. If there are less then these many copies in the cluster a shard will refuse to write. Writes to shards with enough up-to-date copies will succeed at the same time however. The value of
writeConcern
cannot be larger thanreplicationFactor
. (cluster only) -
shardingStrategy (string): The sharding strategy selected for the collection. (cluster only)
Possible values:
"community-compat"
"enterprise-compat"
"enterprise-smart-edge-compat"
"hash"
"enterprise-hash-smart-edge"
"enterprise-hex-smart-vertex"
-
distributeShardsLike (string): The name of another collection. This collection uses the
replicationFactor
,numberOfShards
andshardingStrategy
properties of the other collection and the shards of this collection are distributed in the same way as the shards of the other collection. -
isSmart (boolean): Whether the collection is used in a SmartGraph or EnterpriseGraph (Enterprise Edition only). This is an internal property. (cluster only)
-
isDisjoint (boolean): Whether the SmartGraph or EnterpriseGraph this collection belongs to is disjoint (Enterprise Edition only). This is an internal property. (cluster only)
-
smartGraphAttribute (string): The attribute that is used for sharding: vertices with the same value of this attribute are placed in the same shard. All vertices are required to have this attribute set and it has to be a string. Edges derive the attribute from their connected vertices (Enterprise Edition only). (cluster only)
-
smartJoinAttribute (string): Determines an attribute of the collection that must contain the shard key value of the referred-to SmartJoin collection (Enterprise Edition only). (cluster only)
-
name (string): The name of this collection.
-
id (string): A unique identifier of the collection (deprecated).
- type (integer):
The type of the collection:
0
: “unknown”2
: regular document collection3
: edge collection
-
isSystem (boolean): Whether the collection is a system collection. Collection names that starts with an underscore are usually system collections.
-
syncByRevision (boolean): Whether the newer revision-based replication protocol is enabled for this collection. This is an internal property.
-
globallyUniqueId (string): A unique identifier of the collection. This is an internal property.
Examples
Using an identifier:
shell> curl --header 'accept: application/json' --dump - http://localhost:8529/_api/collection/68965/properties
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: 445
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
location: /_db/_system/_api/collection/68965/properties
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Using a name:
shell> curl --header 'accept: application/json' --dump - http://localhost:8529/_api/collection/products/properties
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: 445
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
location: /_db/_system/_api/collection/products/properties
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Return number of documents in a collection
Counts the documents in a collection
GET /_api/collection/{collection-name}/count
Accessing collections by their numeric ID is deprecated from version 3.4.0 on. You should reference them via their names instead.
Path Parameters
- collection-name (string, required): The name of the collection.
In addition to the above, the result also contains the number of documents. Note that this will always load the collection into memory.
- count: The number of documents inside the collection.
Responses
HTTP 400: If the collection-name is missing, then a HTTP 400 is returned.
HTTP 404: If the collection-name is unknown, then a HTTP 404 is returned.
Examples
Requesting the number of documents:
shell> curl --header 'accept: application/json' --dump - http://localhost:8529/_api/collection/products/count
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: 461
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
location: /_db/_system/_api/collection/products/count
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Return statistics for a collection
Fetch the statistics of a collection
GET /_api/collection/{collection-name}/figures
Accessing collections by their numeric ID is deprecated from version 3.4.0 on. You should reference them via their names instead.
Path Parameters
- collection-name (string, required): The name of the collection.
Query Parameters
- details (boolean, optional):
Setting
details
totrue
will return extended storage engine-specific details to the figures. The details are intended for debugging ArangoDB itself and their format is subject to change. By default,details
is set tofalse
, so no details are returned and the behavior is identical to previous versions of ArangoDB. Please note that requestingdetails
may cause additional load and thus have an impact on performace.
In addition to the above, the result also contains the number of documents and additional statistical information about the collection.
Responses
HTTP 200: Returns information about the collection:
-
count (integer): The number of documents currently present in the collection.
-
figures (object): metrics of the collection
-
indexes (object):
-
count (integer): The total number of indexes defined for the collection, including the pre-defined indexes (e.g. primary index).
-
size (integer): The total memory allocated for indexes in bytes.
-
-
HTTP 400: If the collection-name is missing, then a HTTP 400 is returned.
HTTP 404: If the collection-name is unknown, then a HTTP 404 is returned.
Examples
Using an identifier and requesting the figures of the collection:
shell> curl --header 'accept: application/json' --dump - http://localhost:8529/_api/collection/products/figures
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: 573
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
location: /_db/_system/_api/collection/products/figures
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
shell> curl --header 'accept: application/json' --dump - http://localhost:8529/_api/collection/products/figures?details=true
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: 644
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
location: /_db/_system/_api/collection/products/figures
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Return responsible shard for a document
Return the responsible shard for a document
PUT /_api/collection/{collection-name}/responsibleShard
Path Parameters
- collection-name (string, required): The name of the collection.
Request Body
(json, required)
The body must consist of a JSON object with at least the shard key attributes set to some values.
Returns the ID of the shard that is responsible for the given document (if the document exists) or that would be responsible if such document existed.
The request must body must contain a JSON document with at least the collection’s shard key attributes set to some values.
The response is a JSON object with a shardId attribute, which will contain the ID of the responsible shard.
Note : This method is only available in a cluster Coordinator.
Responses
HTTP 200: Returns the ID of the responsible shard.
HTTP 400: If the collection-name is missing, then a HTTP 400 is returned. Additionally, if not all of the collection’s shard key attributes are present in the input document, then a HTTP 400 is returned as well.
HTTP 404: If the collection-name is unknown, then an HTTP 404 is returned.
HTTP 501: HTTP 501 is returned if the method is called on a single server.
Examples
shell> curl -X PUT --header 'accept: application/json' --data-binary @- --dump - http://localhost:8529/_api/collection/testCollection/responsibleShard <<EOF
{"_key":"testkey","value":23}
EOF
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: 45
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
location: /_db/_system/_api/collection/testCollection/responsibleShard
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Return the shard ids of a collection
Return the shard ids of a collection
GET /_api/collection/{collection-name}/shards
Path Parameters
- collection-name (string, required): The name of the collection.
Query Parameters
- details (boolean, optional): If set to true, the return value will also contain the responsible servers for the collections’ shards.
By default returns a JSON array with the shard IDs of the collection.
If the details
parameter is set to true
, it will return a JSON object with the
shard IDs as object attribute keys, and the responsible servers for each shard mapped to them.
In the detailed response, the leader shards will be first in the arrays.
Note : This method is only available in a cluster Coordinator.
Responses
HTTP 200: Returns the collection’s shards.
HTTP 400: If the collection-name is missing, then a HTTP 400 is returned.
HTTP 404: If the collection-name is unknown, then an HTTP 404 is returned.
HTTP 501: HTTP 501 is returned if the method is called on a single server.
Examples
Retrieves the list of shards:
shell> curl --header 'accept: application/json' --dump - http://localhost:8529/_api/collection/testCollection/shards
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: 593
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
location: /_db/_system/_api/collection/testCollection/shards
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,\"shards\":[\"s10062\",\"s10063\",\"s10064\"],\"writeConcern\":1,\"waitForSync\":false,\"usesRevisionsAsDocumentIds\":true,\"syncByRevision\":true,\"shardingStrategy\":\"hash\",\"schema\":null,\"numberOfShards\":3,\"minReplicationFactor\":1,\"id\":\"10061\",\"isSmartChild\":false,\"name\":\"testCollection\",\"statusString\":\"loaded\",\"isSmart\":false,\"replicationFactor\":2,\"type\":2,\"status\":3,\"cacheEnabled\":false,\"isSystem\":false,\"computedValues\":null,\"internalValidatorType\":0,\"globallyUniqueId\":\"c10061/\",\"shardKeys\":[\"_key\"],\"isDisjoint\":false,\"keyOptions\":{\"allowUserKeys\":true,\"type\":\"traditional\"}}"
Retrieves the list of shards with the responsible servers:
shell> curl --header 'accept: application/json' --dump - http://localhost:8529/_api/collection/testCollection/shards?details=true
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: 863
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
location: /_db/_system/_api/collection/testCollection/shards
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,\"shards\":{\"s10056\":[\"PRMR-77fe6a3b-70d1-4cd6-b5ec-c5d07618c233\",\"PRMR-ac9b5680-1703-4be3-ac7d-3b295df564d1\"],\"s10057\":[\"PRMR-ac9b5680-1703-4be3-ac7d-3b295df564d1\",\"PRMR-77fe6a3b-70d1-4cd6-b5ec-c5d07618c233\"],\"s10058\":[\"PRMR-77fe6a3b-70d1-4cd6-b5ec-c5d07618c233\",\"PRMR-ac9b5680-1703-4be3-ac7d-3b295df564d1\"]},\"writeConcern\":1,\"waitForSync\":false,\"usesRevisionsAsDocumentIds\":true,\"syncByRevision\":true,\"shardingStrategy\":\"hash\",\"schema\":null,\"numberOfShards\":3,\"minReplicationFactor\":1,\"id\":\"10055\",\"isSmartChild\":false,\"name\":\"testCollection\",\"statusString\":\"loaded\",\"isSmart\":false,\"replicationFactor\":2,\"type\":2,\"status\":3,\"cacheEnabled\":false,\"isSystem\":false,\"computedValues\":null,\"internalValidatorType\":0,\"globallyUniqueId\":\"c10055/\",\"shardKeys\":[\"_key\"],\"isDisjoint\":false,\"keyOptions\":{\"allowUserKeys\":true,\"type\":\"traditional\"}}"
Return collection revision id
Retrieve the collections revision id
GET /_api/collection/{collection-name}/revision
Accessing collections by their numeric ID is deprecated from version 3.4.0 on. You should reference them via their names instead.
Path Parameters
- collection-name (string, required): The name of the collection.
The response will contain the collection’s latest used revision id. The revision id is a server-generated string that clients can use to check whether data in a collection has changed since the last revision check.
- revision: The collection revision id as a string.
Responses
HTTP 400: If the collection-name is missing, then a HTTP 400 is returned.
HTTP 404: If the collection-name is unknown, then a HTTP 404 is returned.
Examples
Retrieving the revision of a collection
shell> curl --header 'accept: application/json' --dump - http://localhost:8529/_api/collection/products/revision
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: 462
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
location: /_db/_system/_api/collection/products/revision
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Return checksum for the collection
returns a checksum for the specified collection
GET /_api/collection/{collection-name}/checksum
Accessing collections by their numeric ID is deprecated from version 3.4.0 on. You should reference them via their names instead.
Path Parameters
- collection-name (string, required): The name of the collection.
Query Parameters
-
withRevisions (boolean, optional): Whether or not to include document revision ids in the checksum calculation.
-
withData (boolean, optional): Whether or not to include document body data in the checksum calculation.
Will calculate a checksum of the meta-data (keys and optionally revision ids) and optionally the document data in the collection.
The checksum can be used to compare if two collections on different ArangoDB instances contain the same contents. The current revision of the collection is returned too so one can make sure the checksums are calculated for the same state of data.
By default, the checksum will only be calculated on the _key system attribute of the documents contained in the collection. For edge collections, the system attributes _from and _to will also be included in the calculation.
By setting the optional query parameter withRevisions to true, then revision ids (_rev system attributes) are included in the checksumming.
By providing the optional query parameter withData with a value of true, the user-defined document attributes will be included in the calculation too. Note: Including user-defined attributes will make the checksumming slower.
The response is a JSON object with the following attributes:
-
checksum: The calculated checksum as a number.
-
revision: The collection revision id as a string.
Responses
HTTP 400: If the collection-name is missing, then a HTTP 400 is returned.
HTTP 404: If the collection-name is unknown, then a HTTP 404 is returned.
Examples
Retrieving the checksum of a collection:
shell> curl --header 'accept: application/json' --dump - http://localhost:8529/_api/collection/products/checksum
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: 194
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
location: /_db/_system/_api/collection/products/checksum
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
Retrieving the checksum of a collection including the collection data, but not the revisions:
shell> curl --header 'accept: application/json' --dump - http://localhost:8529/_api/collection/products/checksum?withRevisions=false&withData=true
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: 194
content-security-policy: frame-ancestors 'self'; form-action 'self';
expires: 0
location: /_db/_system/_api/collection/products/checksum
pragma: no-cache
server: ArangoDB
strict-transport-security: max-age=31536000 ; includeSubDomains
x-arango-queue-time-seconds: 0.000000
x-content-type-options: nosniff
reads all collections
returns all collections
GET /_api/collection
Query Parameters
- excludeSystem (boolean, optional): Whether or not system collections should be excluded from the result.
Returns an object with an attribute result containing an array of all collection descriptions.
By providing the optional query parameter excludeSystem with a value of true, all system collections will be excluded from the response.
Responses
HTTP 200: The list of collections
Examples
Return information about all collections:
shell> curl --header 'accept: application/json' --dump - http://localhost:8529/_api/collection
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: 1422
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