Navigation

Get Available Databases for a MongoDB Process

Info With Circle IconCreated with Sketch.Note

Groups and projects are synonymous terms. Your {GROUP-ID} is the same as your project ID. For existing groups, your group/project ID remains the same. The resource and corresponding endpoints use the term groups.

Get the available databases for a Atlas MongoDB Process. A Atlas MongoDB process can be either a mongod or mongos.

The Atlas API authenticates using HTTP Digest Authentication. Provide a programmatic API public key and corresponding private key as the username and password when constructing the HTTP request.

To learn how to configure API access for an Atlas project, see Configure Atlas API Access.

https://cloud.mongodb.com/api/atlas/v1.0

GET api/atlas/v1.0/groups/{GROUP-ID}/processes/{HOST}:{PORT}/databases
ParameterRequired/OptionalDescription
GROUP-IDRequiredID of the project that owns this Atlas MongoDB process.
HOSTRequiredThe hostname of the machine running the Atlas MongoDB process.
PORTRequiredThe port to which the Atlas MongoDB process listens.
FieldRequired/OptionalDescription
pageNumOptional.

The page to return.

Defaults to 1.

itemsPerPageOptional.

Number of items to return per page, up to a maximum of 500.

Defaults to 100.

includeCountOptional.

A boolean that specifies whether or not to include the totalCount field in the response.

Defaults to true.

envelopeOptional.

A boolean that specifies whether or not to wrap the response in an envelope.

Defaults to false.

prettyOptional.

A boolean that specifies whether or not to return a "pretty-printed" JSON document.

Defaults to false.

This endpoint does not use HTTP request body parameters.

If you set the query element envelope to true, the response is wrapped by the content object.

The HTTP response returns a JSON document that includes the following objects:

results Array
Each object in the results array represents a single database for the MongoDB process.
NameTypeDescription
databaseNamestringName of the database. You can use the value to retrieve measurements for the database.
linksarrayAn array containing a single document with the following format:
{
"href" : "https://cloud.mongodb.com/api/atlas/v1.0/groups/{GROUP-ID}/processes/{HOST}:{PORT}/databases/{DATABASE-ID}",
"rel" : "self"
}
You can use the href value to retrieve measurements for the database.See Linking for more information on links.
links Array
An array of documents, representing a link to one or more sub-resources and/or related resources such as list pagination. See Linking for more information.
totalCount
The total number of items in the result set. This value may be higher than the number of objects in the results array if the entire result set is paginated.

Replace the information in brackets {} with your own Atlas information to execute this example request:

curl -u "<ATLAS-USERNAME>:<API-KEY>" --digest -i "https://cloud.mongodb.com/api/atlas/v1.0/groups/{GROUP-ID}/processes/{HOST}:{PORT}/databases?pretty=true"
{
"links":[
{
"href":"https://cloud.mongodb.com/api/atlas/v1.0/groups/12345678/processes/shard-00-00.mongodb.net:27017/databases?pageNum=1&itemsPerPage=100",
"rel":"self"
}
],
"results":[
{
"databaseName":"local",
"links":[
{
"href":"https://cloud.mongodb.com/api/atlas/v1.0/groups/12345678/processes/shard-00-00.mongodb.net:27017/databases/local",
"rel":"self"
}
]
},
{
"databaseName":"foobar",
"links":[
{
"href":"https://cloud.mongodb.com/api/atlas/v1.0/groups/12345678/processes/shard-00-00.mongodb.net:27017/databases/foobar",
"rel":"self"
}
]
}
],
"totalCount":2
}
Give Feedback