Skip to content
324 lines (238 sloc) 10 KB
.. _http-interface:
HTTP Interface
.. default-domain:: mongodb
.. contents:: On this page
:backlinks: none
:depth: 1
:class: twocols
.. _rest-interface:
REST Interfaces
Eve (Python)
`Eve <>`_ is an open source Python REST API framework designed for human beings. It
allows to effortlessly build and deploy highly customizable, fully featured
RESTful Web Services powered by MongoDB.
The codebase is thoroughly tested under Python 2.6, 2.7, 3.3, 3.4 and PyPy.
All you need to bring your REST Web Service online is a MongoDB database, a
configuration file and a launch script. Overall, you will find that configuring
and fine-tuning your API is a very simple process.
- Emphasis on REST
- Full range of CRUD operations
- Customizable resource endpoints
- Customizable, multiple item endpoints
- Filtering and Sorting
- Pagination
- JSON and XML Rendering
- Conditional Requests
- Data Integrity and Concurrency Control
- Bulk Inserts
- Data Validation
- Extensible Data Validation
- Resource-level Cache Control
- API Versioning
- Document Versioning
- Authentication
- ... and (a lot) more.
RESTHeart (Java)
`RESTHeart <>`_ Java REST API server for
MongoDB, built on top of `Undertow <>`_ non-blocking
- CRUD operations API on your data;
- Data model operations API: create databases, collections, indexes
and the data structure;
- Super easy setup, with convention over configuration approach;
- Pluggable security with User Management and ACL;
- `HAL <>`_ hypermedia type;
- Super lightweight: pipeline architecture, ~6Mb footprint,
~200Mb RAM peek usage, starts in milliseconds;
- High throughput: very small overhead on MongoDB performance;
- Horizontally scalable: fully stateless architecture supporting
MongoDB replica sets and shards;
- Built on top of `Undertow <>`_ non-blocking HTTP server;
- Embeds the excellent `HAL browser
by Mike Kelly (the author of the HAL specifications);
- Supports `Cross-Origin Resource Sharing
<>`_ (CORS) so that your one-page web
application can deal with RESTHeart running on a different
domain. In other words, CORS is an evolution of `JSONP
- Ideal as AngularJS (or any other MVW Javascript framework) back-end.
DrowsyDromedary (Ruby)
`DrowsyDromedary <>`_
is a REST layer for MongoDB based on Ruby.
Crest (Node.jS)
`Crest <>`_ is a REST API Server for
MongoDB built in node.js using the
`MongoDB Node Native driver
`AMID <>`_ is a REST
interface for MongoDB. Written in Node.js, supports multi-threading
and a modular architecture to perform custom search operation.
AMID also provides an optional extjs GUI for queries: `AMIDGUI
Mongodb Java REST server
`Mongodb Java REST server <>`_
based on `Jetty <>`_.
`Kule <>`_ is a customizable REST
interface for MongoDB based on Python.
`DreamFactory <>`_ is an open source backend
with a REST API for MongoDB. `DreamFactory on GitHub <>`_.
HTTP Interfaces
Sleepy Mongoose (Python)
`Sleepy Mongoose <>`_
is a full featured HTTP interface for MongoDB.
HTTP Status Interface
.. deprecated:: 3.2
Starting in 3.2, MongoDB deprecates the HTTP interface.
MongoDB provides a simple HTTP interface listing information of interest
to administrators. If you enable the interface with the ``--rest``
option to :program:`mongod`, you may access it via a port that is
1000 more than the configured :program:`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 :program:`mongod` is running with the default port on the
local machine.
.. image:: /figures/http-interface-console.png
Here is a description of the informational elements of the HTTP
.. list-table::
:header-rows: 1
* - **element**
- **description**
* - db version
- database version information
* - git hash
- database version developer tag
* - sys info
- :program:`mongod` compilation environment
* - dblocked
- indicates whether the primary :program:`mongod` mutex is held
* - uptime
- time since this :program:`mongod` instance was started
* - assertions
- any software assertions that have been raised by this :program:`mongod` instance
* - replInfo
- information about replication configuration
* - currentOp
- most recent client request
* - # databases
- number of databases that have been accessed by this :program:`mongod` instance
* - curclient
- last database accessed by this :program:`mongod` instance
* - Cursors
- describes outstanding client cursors
* - master
- whether this :program:`mongod` instance has been designated a master
* - slave
- whether this :program:`mongod` instance has been designated a slave
* - initialSyncCompleted
- whether this slave or repl pair node has completed an initial
clone of the :program:`mongod` instance it is replicating
- Displays the total time the :program:`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 :program:`mongod` mutex
HTTP Status Interface Security
.. warning:: Ensure that the HTTP status interface, the REST API, and
the JSON API are all disabled in production environments to prevent
potential data exposure and vulnerability to attackers.
See :ref:`Security and MongoDB API Interfaces <http-interface-security>`
If security is configured for a :program:`mongod` instance,
authentication is required for a client to access the HTTP status interface
from another machine.
.. note::
While MongoDB Enterprise does support Kerberos authentication,
Kerberos is not supported by the HTTP status interface in any
version of MongoDB.
.. versionchanged:: 3.0
Neither the HTTP status interface nor the REST API support the
:ref:`SCRAM-SHA-1 <authentication-scram-sha-1>` challenge-response
user authentication mechanism introduced in version 3.0.
The :program:`mongod` process includes a simple REST API as a convenience. With no support for
insert, update, or remove operations, it is generally used
for monitoring, alert scripts, and administrative tasks. For full REST
capabilities, consider using an external :ref:`REST Interface <rest-interface>` such as
`Sleepy.Mongoose <>`_.
**v1.4+**: This API is disabled by default, as it could provide unauthenticated access to data.
Use ``--rest`` on the command line to enable, but be aware of security implications.
To get the contents of a collection (note the trailing slash):
.. code-block:: sh
To add a limit:
.. code-block:: sh
To skip:
.. code-block:: sh
To query for ``{a : 1}``:
.. code-block:: sh
Separate conditions with an ``&``:
.. code-block:: sh
Same as ``db.$cmd.findOne({listDatabase:1})`` on the ``admin`` database
in the shell:
.. code-block:: sh
To count documents in a collection:
.. code-block:: sh
JSON in the simple REST API
The simple REST API 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:
.. code-block:: sh
# 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 :manual:`Mongo Extended JSON </reference/mongodb-extended-json/>`
for details.
Replica Set Admin UI
The :program:`mongod` process includes a simple administrative UI for checking the
status of a replica set.
To use, first enable ``--rest`` from the :program:`mongod` command line. The rest port
is the db port plus 1000 (thus, the default is ``28017``). Be sure this port
is secure before enabling this.
Then you can navigate to ``http://<hostname>:28017/`` in your web
browser. Once there, click Replica Set Status
(`/_replSet <>`_) to move to the Replica
Set Status page.
.. image:: /figures/http-interface-rs.png
See Also
- :manual:`Monitoring Database Systems </administration/monitoring/>`
- |mms-home| for seamless automation, backup, and monitoring.
.. include:: /includes/replacement-mms.rst
Jump to Line
Something went wrong with that request. Please try again.