Navigation

Get Available Databases for a MongoDB Process

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

The Atlas API uses HTTP Digest Authentication. Provide your Atlas username and group API key as the username and password when constructing the HTTP request.

For complete documentation on configuring API access for an Atlas group, see Configure Atlas API Access.

Base URL: https://cloud.mongodb.com/

Resource

GET api/atlas/v1.0/groups/{GROUP-ID}/processes/{HOST}:{PORT}/databases

Request Path Parameters

Parameter Required/Optional Description
GROUP-ID Required ID of the group that owns this Atlas MongoDB process.
HOST Required The hostname of the machine running the Atlas MongoDB process.
PORT Required The port to which the Atlas MongoDB process listens.

Request Query Parameters

Field Required/Optional Description
pageNum Optional.

The page to return.

Defaults to 1.

itemsPerPage Optional.

Maximum number of items to return per page.

Defaults to 100.

envelope Optional.

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

Defaults to false.

pretty Optional.

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

Defaults to false.

Request Body Parameters

This endpoint does not use HTTP request body parameters.

Response Elements

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.

Name Type Description
databaseName string Name of the database. You can use the value to retrieve measurements for the database.
links array

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

Example Request

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"

Example Response

{
   "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
}