RESTHeart, the REST API Server for MongoDB

Maurizio Turatti
SoftInstigate Team
Published in
2 min readMar 9, 2017

Summary

RESTHeart leverages MongoDB’s document-oriented nature, creating an automatic mapping between MongoDB’s internal storage of data and a graph of externally accessible HTTP resources, implementing a model of interaction compliant with an HATEOAS (Hypermedia as the Engine of Application State) representation, where the state of a client process is entirely driven by HTTP verbs like GET, POST, PUT, PATCH, DELETE, etc.

RESTHeart is implemented in Java 8, on top of Red Hat’s Undertow HTTP server. The code is fully open-source and freely available on Github.

What it does

RESTHeart seamlessly connects to MongoDB to securely expose dbs and collections to the Web. Any authorized client (authentication and authorization are provided out-of-the-box) can interact with MongoDB via RESTHeart secure API.

Documents are read with the GET verb, created and modified with PUT, POST and PATCH verbs and deleted with the DELETE verb.

Data is exchanged as JSON (actually the standard hal+json mediatype).

HAL is a simple format that gives a consistent and easy way to hyperlink between resources in your API.

The following picture depicts a simple usage scenario: a mobile blog reader application sends a GET /blog/posts request to retrive the paginated list of posts.

A typical usage scenario

Capabilities

Rapid Development

  • No server side development is required in most of the cases for your Web and Mobile Applications.
  • The Setup is simple, with a convention over configuration approach; Docker images and Vagrant boxes are also available.
  • Access Control and Schema Check are provided out of the box.

Production ready

Fast & Light

  • High throughput, check the performance tests.
  • Lightweight ~10Mb footprint, low RAM usage, starts in ~1 sec.
  • Horizontally Scalable with Stateless Architecture and full support for MongoDB replica sets and shards.
  • Easy integration with DaaS such as mLab and Compose.
  • µService: it does one thing and it does it well.

Try it

There’s a online demo instance, with a database exposing a single collection. Have a look at http://restheart.org/try.html

References

News [June 2021]

In addition to the established REST API, the latest RESTHeart v6 introduces full GraphQL and Websocket APIs for MongoDB!

--

--