Http Interface

REST Interfaces

Sleepy Mongoose (Python)

Sleepy Mongoose is a full featured REST interface for MongoDB which is available as a separate project.

MongoDB Rest (Node.js)

MongoDB Rest is an alpha REST interface to MongoDB, which uses the MongoDB Node Native driver.

HTTP Console

MongoDB provides a simple http interface listing information of interest to administrators. This interface may be accessed at the port with numeric value 1000 more than the configured mongod port; the default port for the http interface is 28017. To access the http interface an administrator may, for example, point a browser to http://localhost:28017 if mongod is running with the default port on the local machine.

Here is a description of the informational elements of the http interface:

element description
db version database version information
git hash database version developer tag
sys info mongod compilation environment
dblocked indicates whether the primary mongod mutex is held
uptime time since this mongod instance was started
assertions any software assertions that have been raised by this mongod instance
replInfo information about replication configuration
currentOp most recent client request
# databases number of databases that have been accessed by this mongod instance
curclient last database accessed by this mongod instance
Cursors describes outstanding client cursors
master whether this mongod instance has been designated a master
slave whether this mongod instance has been designated a slave
initialSyncCompleted whether this slave or repl pair node has completed an initial clone of the mongod instance it is replicating
DBTOP Displays the total time the mongod instance has devoted to each listed collection, as well as the percentage of available time devoted to each listed collection recently and the number of reads, writes, and total calls made recently
dt Timing information about the primary mongod mutex

HTTP Console Security

If security is configured for a mongod instance, authentication is required for a client to access the http interface from another machine.

Simple REST Interface

The mongod process includes a simple read-only (no support for insert/update/remove) REST interface for convenience.  For full REST capabilities we recommend using an external tool such as Sleepy.Mongoose.

v1.4+: This interface is disabled by default. Use --rest on the command line to enable.

To get the contents of a collection (note the trailing slash):

http://127.0.0.1:28017/databaseName/collectionName/

To add a limit:

http://127.0.0.1:28017/databaseName/collectionName/?limit=-10

To skip:

http://127.0.0.1:28017/databaseName/collectionName/?skip=5

To query for {a : 1}:

http://127.0.0.1:28017/databaseName/collectionName/?filter_a=1

Separate conditions with an &:

http://127.0.0.1:28017/databaseName/collectionName/?filter_a=1&limit=-10

Same as db.$cmd.findOne({listDatabase:1}) on the "admin" database in the shell:

http://localhost:28017/admin/$cmd/?filter_listDatabases=1&limit=1

To count documents in a collection:

http://host:port/db/$cmd/?filter_count=collection&limit=1

JSON in the simple REST interface

The simple ReST interface uses strict JSON (as opposed to the shell, which uses Dates, regular expressions, etc.). To display non-JSON types, the web interface wraps them in objects and uses the key for the type. For example:

# ObjectIds just become strings
"_id" : "4a8acf6e7fbadc242de5b4f3"

# dates
"date" : { "$date" : 1250609897802 }

# regular expressions
"match" : { "$regex" : "foo", "$options" : "ig" }

The code type has not been implemented yet and causes the DB to crash if you try to display it in the browser.

See Mongo Extended JSON for details.

See Also


Labels

server server Delete
rest rest Delete
web web Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

PLEASE POST QUESTIONS IN THE USER GROUPS FORUM. Post non-question comments and helpful hints here.

blog comments powered by Disqus