0

I am trying to use ArangoDB's HTTP interface to dump all collections belonging to a specific database.

I am able to view all available databases using the following command:

curl http://localhost:8529/_api/database

However, once I find a database name (for example, "test") I am unable to dump the collections belonging to this database. Ultimately, I would like to dump the collections for this database, and then all results within a chosen collection.

I have followed the documentation provided here: https://www.arangodb.com/docs/stable/http/general.html, however I am still unable to find the relevant documentation for this request.

1 Answer 1

2

You can get the list of all collections with

curl http://localhost:8529/_db/DBNAME/_api/collection

as is implied in this part of the documentation: https://www.arangodb.com/docs/stable/http/collection.html#address-of-a-collection

The rest of the interface works accordingly, e.g.

curl http://localhost:8529/_db/DBNAME/_api/collection/COLLNAME

to get information about a single collection (that is already included in the output of the first call).

You find the complete swagger documentation with just two clicks in the Web-Interface: enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks Tom, now that I have the collection name, how would I go about retrieving the IDs of the documents within that collection? The "lastValue" field in /_api/collection/{collection-name}/properties reveals the last document ID, but I would like to see all of them.
In the arangodb webinterface, there is for every database a 'Support'-Link in the left Navigation-Bar - there you find the swagger documentation for the HTTP-Api under the top-bar link 'Rest-API' - take a look at the PUT ​/_api​/document​/{collection}#get endpoint, or for more control, the AQL-Query/Cursor API.
What I would recommend is to use the POST /_db/<database>/_api/cursor endpoint with e.g the following payload: {"query":"FOR doc IN @@coll RETURN doc._id", "bindVars":{"@coll":"<collection>"}, "options":{"stream":true}}. It's a basic iteration over a collection and you can return the document IDs, keys, or whatever you need. Using a collection bind variable lets you reuse this request and all you need to change is the collection name in the bind parameters. The query streaming option is enabled to lazily calculate results as you request subsequent result batches.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.