The REST API for MongoDB

Build applications faster, no coding required.

RESTHeart 4 is out!
RESTHeart 4

Use Cases

REST API for MongoDB

RESTHeart unlocks all the features of MongoDb via HTTP. Queries, Bulk Updates, GridFs, Aggregations, Map-reduce functions, Replica Sets, Shards, Indexing and many more are accessible via a simple RESTful API.

No server-side development is required so you can focus on building your Web or Mobile apps or Enterprise Integration System, as all the database logic is available out of the box.

RESTHeart also provides strong API & Web Security models for User Authentication, Authorization and Caching.

Content Management

RESTHeart allows to effectively manage and aggregate content and its metadata, such as images, comments, tags, categories, geolocalized data, audios and videos, delivering it via a solid REST API.

You can build Single Page Applications with Angular, React, Vue frameworks and iOS and Android Mobile apps much effectively, because you can focus on creating beautiful User Interfaces for your users.

RESTHeart is a perfect API provider for JAMstack Web architectures, where it fits much more naturally that any WordPress customization.

Open Data and IoT

RESTHeart is a perfect fit for Open Data and Internet of Things solutions. Data can be uploaded to RESTHeart via JSON calls or Excel's CSV files and made immediately available through the REST API.

RESTHeart also leverages MongoDb's Geospatial support and stores GeoJSON objects without the need to write complicated server-side code: geometries are then available to clients such as Google Maps via its API.

RESTHeart also handles the GTFS format for public transportation schedules thanks to a commercial plugin.

SUPPORTED BY THE COMMUNITY OR BY OUR PROFESSIONAL SERVICES

Our Professional Services can help you building RESTful APIs, data models, query optimizations, customizations and extensions, bug fixing, on cloud and on premises deployments, security and HA configurations.

PROFESSIONAL SERVICES

AVAILABLE UNDER OPEN SOURCE OR COMMERCIAL LICENSES

RESTHeart is distributed under the Open Source GNU AGPL v3 license. If the usage of our product under the AGPL does not satisfy your organization’s legal requirements, business-friendly commercial licenses are also available.

Commercial licenses

Trusted by Startups and Corporations

 

Query documents from the command line with httpie.

The GET request has two query parameters: filter to apply a query and pagesize to limit the response to two documents.
Here we use the brilliant httpie, a modern command line HTTP client.

More examples
$ http GET https://beta.mrest.io/demo/messages?filter='{"from":"Bob"}'\&pagesize=2 key:demo

HTTP/1.1 200 OK
# other response headers omitted

[
    {
        "_id": {
            "$oid": "5c50963e477870eb8258fa68"
        }, 
        "from": "Bob", 
        "message": "was here", 
        "timestamp": {
            "$date": 1548785214114
        }
    }, 
    {
        "_id": {
            "$oid": "5c50962f477870eb8258fa54"
        }, 
        "from": "Bob", 
        "message": "RESTHeart rocks", 
        "timestamp": {
            "$date": 1548785199983
        }
    }
]

Query documents from the command line with cURL.

The GET request has two query parameters: filter to apply a query (that needs to be encoded with --data-urlencode option since it contains the curly brackets) and pagesize to limit the response to two documents.
Here we use the immortal cURL!

More examples
    
$ curl --header "key:demo" -G --data-urlencode 'filter={"from":"Bob"}' https://beta.mrest.io/demo/messages?pagesize=2

[
    {
        "_id": {
            "$oid": "5c50963e477870eb8258fa68"
        }, 
        "from": "Bob", 
        "message": "was here", 
        "timestamp": {
            "$date": 1548785214114
        }
    }, 
    {
        "_id": {
            "$oid": "5c50962f477870eb8258fa54"
        }, 
        "from": "Bob", 
        "message": "RESTHeart rocks", 
        "timestamp": {
            "$date": 1548785199983
        }
    }
]

Query documents with JavaScript.

The GET request has two query parameters: filter to apply a query and pagesize to limit the response to two documents.
Here we use the fetch API.

Run it
const url = encodeURI('https://beta.mrest.io/demo/messages?filter={"from":"Bob"}&pagesize=2');

fetch(url, { headers: {'key':'demo'} })
  .then(response => response.json())
  .then(function(data) {
    console.log(JSON.stringify(data));
});

Query documents with Java.

The GET request has two query parameters: filter to apply a query and pagesize to limit the response to two documents.
Here we use the unirest java http library.

More examples
public void printOutMessages() throws UnirestException {
    HttpResponse<JsonNode> resp = Unirest.get("https://beta.mrest.io/demo/messages")
            .header("key", "demo")
            .queryString("filter", "{\"from\":\"Bob\"}")
            .queryString("pagesize", "2")
            .asJson();

    // get body as JSON array 
    JSONArray messages = resp.getBody().getArray();

    // print out each message
    messages.forEach(message -> System.out.println(message.toString()));
}

Query documents with Swift.

The GET request has two query parameters: filter to appy a query and pagesize to limit the response to two documents.
Here we use the JSONSerialization to parse the response body.

More examples
import UIKit
import PlaygroundSupport

var urlComponents = URLComponents(string: "https://beta.mrest.io/demo/messages")

// set the query parameters
var queryItems = [URLQueryItem]()
queryItems.append(URLQueryItem(name: "pagesize", value: "2"))
queryItems.append(URLQueryItem(name: "filter", value: "{\"from\":\"Bob\"}"))
urlComponents?.queryItems = queryItems

var urlRequest = URLRequest(url: (urlComponents?.url)!)

// set the key request header
urlRequest.setValue("demo", forHTTPHeaderField: "key")

// set request method
urlRequest.httpMethod = "GET"

URLSession.shared.dataTask(with: urlRequest) { (data, response, error) in
    guard let dataResponse = data, error == nil
    else {
        print(error?.localizedDescription ?? "Response Error")
        return
    }
    
    do {
        let jsonResponse = try JSONSerialization.jsonObject(with: dataResponse, options: [])
        print(jsonResponse)
    } catch let jsonError {
        print(jsonError)
    }
}.resume()

// only needed in playground
PlaygroundPage.current.needsIndefiniteExecution = true

Examples use mrest.io cloud service for RESTHeart that requires the api key.

Widely Adopted

Graph of RESTHeart Docker image's pulls