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

    • 1: new born collection
    • 2: unloaded
    • 3: loaded
    • 4: in the process of being unloaded
    • 5: deleted
    • 6: loading

Every other status indicates a corrupted collection.

  • type: The type of the collection as number.
    • 2: document collection (normal case)
    • 3: edges collection
  • isSystem: If true then the collection is a system collection.

Return codes

  • 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 (required): The name of the collection.

  • 400: If the collection-name is missing, then a HTTP 400 is returned.

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

HTTP 200

  • **:

Examples

Using an identifier:

shell> curl --header 'accept: application/json' --dump - http://localhost:8529/_api/collection/70465/properties

HTTP/1.1 OK
content-type: application/json
location: /_api/collection/70465/properties
x-content-type-options: nosniff

Show response body

Using a name:

shell> curl --header 'accept: application/json' --dump - http://localhost:8529/_api/collection/products/properties

HTTP/1.1 OK
content-type: application/json
location: /_api/collection/products/properties
x-content-type-options: nosniff

Show response body

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

Return codes

  • 400: If the collection-name is missing, then a HTTP 400 is returned.

  • 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 OK
content-type: application/json
location: /_api/collection/products/count
x-content-type-options: nosniff

Show response body

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 (required): The name of the collection.

In addition to the above, the result also contains the number of documents and additional statistical information about the collection.

HTTP 200 Returns information about the collection:

  • count: The number of documents currently present in the collection.

  • figures: metrics of the collection

    • indexes:
    • count: The total number of indexes defined for the collection, including the pre-defined indexes (e.g. primary index).

    • size: The total memory allocated for indexes in bytes.
  • 400: If the collection-name is missing, then a HTTP 400 is returned.

  • 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 OK
content-type: application/json
location: /_api/collection/products/figures
x-content-type-options: nosniff

Show response body

Return responsible shard for a document

Return the responsible shard for a document

PUT /_api/collection/{collection-name}/responsibleShard

Path Parameters

  • collection-name (required): The name of the collection.

Request Body (json)

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.

Return codes

  • 200: Returns the ID of the responsible shard.

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

  • 404: If the collection-name is unknown, then an HTTP 404 is returned.

  • 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 OK
content-type: application/json
location: /_api/collection/testCollection/responsibleShard
x-content-type-options: nosniff

Show response body

Return the shard ids of a collection

Return the shard ids of a collection

GET /_api/collection/{collection-name}/shards

Path Parameters

  • collection-name (required): The name of the collection.

Query Parameters

  • details (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.

Return codes

  • 200: Returns the collection’s shards.

  • 400: If the collection-name is missing, then a HTTP 400 is returned.

  • 404: If the collection-name is unknown, then an HTTP 404 is returned.

  • 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 OK
content-type: application/json
location: /_api/collection/testCollection/shards
x-content-type-options: nosniff

"{\"error\":false,\"code\":200,\"shards\":[\"s2000052\",\"s2000053\",\"s2000054\"],\"keyOptions\":{\"allowUserKeys\":true,\"type\":\"traditional\"},\"isDisjoint\":false,\"minReplicationFactor\":1,\"isSystem\":false,\"name\":\"testCollection\",\"cacheEnabled\":false,\"id\":\"2000051\",\"isSmartChild\":false,\"globallyUniqueId\":\"c2000051/\",\"schema\":null,\"type\":2,\"status\":3,\"minRevision\":1666485402862616576,\"numberOfShards\":3,\"statusString\":\"loaded\",\"waitForSync\":false,\"isSmart\":false,\"shardKeys\":[\"_key\"],\"shardingStrategy\":\"hash\",\"replicationFactor\":1,\"syncByRevision\":true,\"usesRevisionsAsDocumentIds\":true,\"writeConcern\":1}"

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 OK
content-type: application/json
location: /_api/collection/testCollection/shards
x-content-type-options: nosniff

"{\"error\":false,\"code\":200,\"shards\":{\"s2000048\":[\"PRMR-65b87e24-5608-4ad2-a4a5-13d930932903\"],\"s2000049\":[\"PRMR-74cf8ffd-85d4-42d7-b8f2-7e52ba8c8bc5\"],\"s2000050\":[\"PRMR-65b87e24-5608-4ad2-a4a5-13d930932903\"]},\"keyOptions\":{\"allowUserKeys\":true,\"type\":\"traditional\"},\"isDisjoint\":false,\"minReplicationFactor\":1,\"isSystem\":false,\"name\":\"testCollection\",\"cacheEnabled\":false,\"id\":\"2000047\",\"isSmartChild\":false,\"globallyUniqueId\":\"c2000047/\",\"schema\":null,\"type\":2,\"status\":3,\"minRevision\":1666485402829062144,\"numberOfShards\":3,\"statusString\":\"loaded\",\"waitForSync\":false,\"isSmart\":false,\"shardKeys\":[\"_key\"],\"shardingStrategy\":\"hash\",\"replicationFactor\":1,\"syncByRevision\":true,\"usesRevisionsAsDocumentIds\":true,\"writeConcern\":1}"

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 (required): The name of the collection.

In addition to the above, the result will also contain the collection’s 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.

Return codes

  • 400: If the collection-name is missing, then a HTTP 400 is returned.

  • 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 OK
content-type: application/json
location: /_api/collection/products/revision
x-content-type-options: nosniff

Show response body

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 (required): The name of the collection.

Query Parameters

  • withRevisions (optional): Whether or not to include document revision ids in the checksum calculation.

  • withData (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.

Note: this method is not available in a cluster.

Return codes

  • 400: If the collection-name is missing, then a HTTP 400 is returned.

  • 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 OK
content-type: application/json
location: /_api/collection/products/checksum
x-content-type-options: nosniff

Show response body

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 OK
content-type: application/json
location: /_api/collection/products/checksum
x-content-type-options: nosniff

Show response body

reads all collections

returns all collections

GET /_api/collection

Accessing collections by their numeric ID is deprecated from version 3.4.0 on. You should reference them via their names instead.

Query Parameters

  • excludeSystem (optional): Whether or not system collections should be excluded from the result.

Returns an object with an attribute collections containing an array of all collection descriptions. The same information is also available in the names as an object with the collection names as keys.

By providing the optional query parameter excludeSystem with a value of true, all system collections will be excluded from the response.

Return codes

  • 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 OK
content-type: application/json
x-content-type-options: nosniff

Show response body