
Java and GraalVM Runtime for Microservices
With instant data persistence on MongoDB
Blazing fast Get your API in minutes Instant Data API on MongoDB Develop Web Services Deliver Content to the Web Handle users and permissions Proxy external resources Available as Docker image Stream real-time data with WebSockets Notify clients with Hooks Create Open Data solutions Threat protection at every layer
Build modern apps with RESTHeart
RESTHeart is an Open Source runtime highly suited for back end microservices. It leverages MongoDB to provide the data API out-of-the-box. Get the 80% common requirements out-of-the-box and easily extend the API for the 20%.
- Instant Data API with MongoDB
- Built-in Authentication and Authorization
- Elegant Java and Kotlin Framework to extend the API
Setup RESTHeart in minutes
RESTHeart is tailored for JVM, Docker and Kubernetes, crafted from the best of breed Java libraries and standards, designed to radically simplify server-side development and deployment.
- Ready-to-run stateless Microservice
- Available as binary and Docker container
- Deploy both on Cloud and on-premises

Clean and ready-to-use Data API for MongoDB
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.
$ 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!
$ 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.
const url = encodeURI('https://beta.mrest.io/demo/messages?filter={"from":"Bob"}&pagesize=2');
fetch(url, { headers: {'key':'demo'} })
.then(response => response.json())
.then(json => JSON.stringify(json, null, 2))
.then(docs => console.log(docs));
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.
public void printOutMessages() throws UnirestException {
var 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
var messages = resp.getBody().getArray();
// print out each message
messages.forEach(msg -> System.out.println(msg.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.
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
Our commitment
Elegant Java and Kotlin Framework to extend the API
Implement web services in minutes.
Implement a simple interface and deploy the web service by copying its jar file into the plugins directory.
More examples@RegisterPlugin(name = "greeterService",
description = "sends a greetings message",
defaultURI = "/greetings")
public class GreeterService implements JsonService {
@Override
public void handle(JsonRequest request, JsonResponse response) {
if (request.isGet()) {
var content = new JsonObject();
content.addProperty("message", "Hello World!");
response.setContent(content);
} else {
response.setStatusCode(400);
}
}
}
Implement plugins in Kotlin.
You can use Java and Kotlin to implement plugins.
Kotlin Service example@RegisterPlugin(name = "kotlinGreeterService",
description = "sends a greetings message, implemented in Kotlin",
defaultURI = "/greetings")
class GreeterServiceKt : JsonService {
override fun handle(request: JsonRequest?, response: JsonResponse?) {
if (request?.isGet!!) {
var greetings = JsonObject()
greetings.addProperty("msg", "Hello World!")
response?.content = greetings;
} else {
response?.statusCode = 400;
}
}
}
Snoop and modify requests at different stages of their lifecycle.
This interceptor applies to requests of the hello web service adding a timestamp to the response content.
Interceptor can be executed at different points of the request as defined
by the interceptPoint parameter of the annotation RegisterPlugin
@RegisterPlugin(name = "helloInterceptor",
description = "add a timestamp to the response of /hello",
interceptPoint = InterceptPoint.RESPONSE)
public class HelloInterceptor implements JsonInterceptor {
@Override
public void handle(JsonRequest request, JsonResponse response) throws Exception {
// add timestamp property to the response
response.getContent()
.getAsJsonObject()
.addProperty("timestamp", Instant.now().toString());
}
@Override
public boolean resolve(JsonRequest request, JsonResponse response) {
// apply for request handled by hello service
// when the response content is a JSON Object
return request.isHandledBy("hello")
&& response.getContent() != null
&& response.getContent().isJsonObject();
}
}

Introducing HTTP Shell
A new Open Source gem from SoftInstigate
More..Trusted by Startups and Corporations