Open Source REST API & GraphQL Server β Instant backend APIs with zero code required.
- What is RESTHeart?
- Architecture & Features
- Use Cases
- MongoDB Data API Replacement
- PostgreSQL Support via FerretDB
- Comparison with Similar Tools
- Quick Start
- API Examples
- Configuration
- Plugin Architecture
- Deployment
- Database Compatibility
- FAQ
- How does RESTHeart compare to Express.js + Mongoose?
- Can RESTHeart replace the deprecated MongoDB Data API?
- How does RESTHeart differ from Hasura or Prisma?
- Does RESTHeart scale for production?
- Do I need to write code?
- What's the license?
- Can I use it with MongoDB Atlas?
- Can I use RESTHeart with PostgreSQL?
- Community & Support
- Contributing
- License
RESTHeart is an open-source Java server that auto-generates REST, GraphQL, and WebSocket APIs from your database collections.
Core capabilities:
- REST API β Full CRUD operations, aggregations, filtering, sorting, pagination
- GraphQL β Auto-generated schema from MongoDB collections with queries, mutations, and subscriptions
- WebSocket β Real-time change streams and data synchronization
- Authentication β JWT, OAuth2, LDAP, and MongoDB-based user management
- Authorization β Role-based access control (RBAC) and declarative security policies
No code required for standard database operations. Write plugins in Java, JavaScript, or Python only when you need custom business logic.
Database support: MongoDB, MongoDB Atlas, Percona Server, AWS DocumentDB, Azure Cosmos DB, FerretDB.
Query MongoDB directly via HTTP:
const url = encodeURI('https://demo.restheart.org/messages?filter={"from":"Bob"}&pagesize=1');
fetch(url)
.then(response => response.json())
.then(json => console.log(JSON.stringify(json, null, 2)));π Complete documentation available at https://restheart.org/docs/
| Feature | Description |
|---|---|
| π§© Automatic API Generation | REST and GraphQL schemas generated from MongoDB collections β no manual endpoint definition |
| βοΈ Plugin System | Extend via Services, Interceptors, Initializers, and Providers β hot-reload support |
| π Security | Pluggable authentication (JWT, OAuth2, LDAP, custom) and ACL-based authorization |
| π¬ WebSockets | Native change stream support with automatic client synchronization |
| π Performance | Undertow NIO server with Java 21 Virtual Threads β 10K+ concurrent connections |
| π Polyglot | Java, Kotlin native support β JavaScript, TypeScript, Python via GraalVM |
| π Observability | Prometheus metrics, health endpoints, request/response logging |
| π§° Developer Tools | CLI for plugin development, Docker images, GraalVM native compilation |
| βοΈ Deployment | Stateless architecture β runs on VMs, containers, Kubernetes, or as native binary |
- Rapid API development β Skip boilerplate CRUD code, focus on business logic
- Mobile/web backends β REST and GraphQL APIs without Express.js/Fastify setup
- Real-time applications β WebSocket support for chat, notifications, live updates
- Legacy MongoDB modernization β Add modern APIs to existing databases without data migration
- MongoDB Data API replacement β Drop-in alternative for the deprecated MongoDB Atlas Data API with enhanced features
- Prototyping & MVPs β Functional backend in minutes for proof-of-concepts
- Microservices β Lightweight, stateless architecture with built-in API gateway features
- IoT data collection β Efficient resource usage, fast startup, edge deployment ready
- PostgreSQL with MongoDB API β Use MongoDB query syntax with PostgreSQL via FerretDB translation layer
MongoDB deprecated its Atlas Data API in September 2024. RESTHeart is a powerful, self-hosted alternative that provides everything the Data API offered β and much more.
| Feature | MongoDB Data API | RESTHeart |
|---|---|---|
| REST API | β Basic CRUD | β Full CRUD + aggregations |
| GraphQL | β | β Auto-generated |
| WebSocket | β | β Change streams |
| Hosting | Atlas only | Self-hosted or cloud |
| Authentication | API keys | JWT, OAuth2, LDAP, custom |
| Real-time | β | β Native support |
| Extensibility | β | β Plugin system |
| Status | Deprecated | Active development |
- No vendor lock-in β Works with MongoDB Atlas, self-hosted MongoDB, or compatible databases
- Enhanced features β GraphQL, WebSockets, advanced filtering, aggregation pipelines
- Better security β Multiple authentication mechanisms, fine-grained authorization
- Cost control β Self-hosted option eliminates per-request pricing
- Future-proof β Active open-source community and commercial support
π Read more: MongoDB Deprecates Data API - What's Next?
While RESTHeart is MongoDB-native, you can use it with PostgreSQL through FerretDB β an open-source MongoDB-compatible database that uses PostgreSQL as its storage engine.
Application β RESTHeart β FerretDB β PostgreSQL
(MongoDB API) (Translation Layer) (Storage)
FerretDB translates MongoDB wire protocol commands to SQL queries, allowing RESTHeart to:
- Provide MongoDB-style REST and GraphQL APIs
- Use MongoDB query syntax (filters, projections, aggregations)
- Store data in PostgreSQL tables
- Leverage PostgreSQL's ACID guarantees and ecosystem
β Good for:
- Teams familiar with MongoDB wanting PostgreSQL's reliability
- Organizations with PostgreSQL expertise and infrastructure
- Projects requiring PostgreSQL-specific features (full-text search, PostGIS)
- Gradual migration from MongoDB to PostgreSQL
- Some advanced MongoDB features not yet supported (check FerretDB compatibility)
- Performance characteristics differ from native MongoDB
- Change streams support depends on FerretDB version
π Complete tutorial: Getting Started with FerretDB and RESTHeart
| Feature | RESTHeart | Hasura | Prisma | PostGraphile | Parse |
|---|---|---|---|---|---|
| Target Database | MongoDB + compatible | PostgreSQL, MySQL, SQL Server, BigQuery | PostgreSQL, MySQL, SQL Server, SQLite, MongoDB*, CockroachDB | PostgreSQL | MongoDB, PostgreSQL |
| REST API | β Auto-generated | β | β Auto-generated | β Auto-generated | |
| GraphQL | β Auto-generated | β Auto-generated | β Auto-generated | β Auto-generated | |
| WebSocket/Subscriptions | β Native change streams | β GraphQL subscriptions | β | β Live Queries | |
| Built-in Auth | β JWT, OAuth2, LDAP | β JWT, webhooks | β | β Built-in user system, OAuth | |
| Architecture | API server (zero-code) | API server (zero-code) | ORM/Query builder | API server (zero-code) | Backend-as-a-Service |
| Primary Use Case | Instant APIs for MongoDB | Instant APIs for PostgreSQL | Type-safe database client | Instant APIs for PostgreSQL | Mobile/web app backend |
| Language | Java 21 | Haskell (core), TypeScript | TypeScript/Node.js | TypeScript/Node.js | Node.js |
| Runtime | JVM / GraalVM Native | Binary executable | Node.js (library) | Node.js | Node.js |
| License | AGPL / Commercial | Apache 2.0 | Apache 2.0 | MIT | Apache 2.0 |
Key differences:
- RESTHeart provides both REST and GraphQL APIs; Hasura and PostGraphile focus on GraphQL with optional REST endpoints
- Hasura's REST endpoints are "RESTified" - you manually create REST wrappers for GraphQL queries, not auto-generated from database schema
- Prisma is fundamentally different - it's a database client/ORM library, not a standalone API server. You use it to build your own API server
- Parse is a full Backend-as-a-Service (BaaS) platform with additional features like push notifications, file storage, and cloud functions
- PostGraphile is PostgreSQL-exclusive; RESTHeart is MongoDB-exclusive (with PostgreSQL via FerretDB); Hasura supports multiple SQL databases; Parse supports MongoDB and PostgreSQL
- RESTHeart uses Java Virtual Threads for high-concurrency workloads; others use Node.js async or compiled binaries
Start MongoDB and RESTHeart with Docker Compose:
curl https://raw.githubusercontent.com/SoftInstigate/restheart/master/docker-compose.yml \
--output docker-compose.yml && docker compose up --pull=always --attach restheartTest the deployment:
curl localhost:8080/pingRESTHeart is now running. APIs are available at http://localhost:8080/.
Docker images are automatically publishes on Docker Hub.
# Query with filters
curl 'http://localhost:8080/people?filter={"age":{"$gt":30}}'
# Pagination and sorting
curl 'http://localhost:8080/people?pagesize=10&page=1&sort={"name":1}'
# Projection (select specific fields)
curl 'http://localhost:8080/people?keys={"name":1,"age":1}'{
people(filter: "{'age': {'$gt': 30}}", pagesize: 5, sort: NAME_ASC) {
_id
name
age
email
}
}// Connect to change streams
const ws = new WebSocket("wss://demo.restheart.org/ws/messages");
// Receive updates when data changes
ws.onmessage = e => {
const update = JSON.parse(e.data);
console.log("Update:", update);
};
// Optional: filter updates
ws.send(JSON.stringify({
filter: { from: "Alice" }
}));Configuration via YAML file or RHO environment variable.
Key areas:
- π MongoDB Connection β Connection strings, replica sets, authentication
- π₯ User Management β Define users, roles, and permissions
- π Authentication β JWT, OAuth2, LDAP, custom mechanisms
- π‘οΈ Authorization β ACL rules, role-based access control
- π§ Plugin System β Register and configure custom extensions
- π Monitoring β Metrics collection, logging levels, health checks
Example:
mongo-uri: mongodb://localhost:27017
auth:
mechanism: basicAuth
users:
- userid: admin
password: secret
roles: [admin]
cors:
enabled: true
allow-origin: "*"π See the Configuration Guide for complete details.
Extend RESTHeart via plugins when you need custom logic beyond generated APIs.
Plugin Types:
- Services β Custom REST endpoints and APIs
- Interceptors β Modify requests/responses, add validation, logging
- Initializers β Run code at startup (database setup, caching)
- Providers β Dependency injection for shared components
Supported Languages:
- Java, Kotlin (native JVM support)
- JavaScript, TypeScript (via GraalVM)
- Python (via GraalVM)
@RegisterPlugin(
name = "greetings",
description = "A simple greeting service"
)
public class GreeterService implements JsonService {
@Override
public void handle(JsonRequest req, JsonResponse res) {
res.setContent(object()
.put("message", "Hello World!")
.put("timestamp", Instant.now()));
}
}export const options = {
name: "greetings",
description: "A simple greeting service"
}
export function handle(request, response) {
response.setContent(JSON.stringify({
message: 'Hello World!',
timestamp: new Date().toISOString()
}));
response.setContentTypeAsJson();
}π§ Use restheart-cli for plugin scaffolding, testing, and hot-reload during development.
docker pull softinstigate/restheart:latest
docker run -p 8080:8080 \
-v ./restheart.yml:/opt/restheart/etc/restheart.yml \
softinstigate/restheartStateless architecture supports horizontal scaling. Configure with ConfigMaps and Secrets.
Compile to native binary for faster startup (<1s) and lower memory footprint (~50MB):
./mvnw clean package -PnativeIdeal for serverless deployments (AWS Lambda, Cloud Run) and edge computing.
Managed service alternative: cloud.restheart.com
- Fully managed infrastructure
- Automatic scaling
- Monitoring and logging
- Enterprise SLAs
| Database | Support Level | Notes |
|---|---|---|
| β MongoDB | Full | All versions 3.6+ |
| β MongoDB Atlas | Full | Cloud-native support |
| β Percona Server | Full | Drop-in MongoDB replacement |
| βοΈ FerretDB | Partial | PostgreSQL-backed MongoDB alternative |
| βοΈ AWS DocumentDB | Partial | Most features work, some MongoDB 4.0+ features missing |
| βοΈ Azure Cosmos DB | Partial | MongoDB API compatibility layer |
Compatibility depends on MongoDB wire protocol implementation.
RESTHeart auto-generates APIs from MongoDB collections, eliminating the need for:
- Manual route definitions and controllers
- Request validation and error handling middleware
- Authentication/authorization setup
- WebSocket server configuration
You only write code for custom business logic via plugins.
Yes. RESTHeart is an excellent replacement for the MongoDB Atlas Data API (deprecated in September 2025). It provides:
- Full MongoDB REST API with filtering, sorting, pagination, and aggregations
- GraphQL support not available in the original Data API
- WebSocket/real-time capabilities via change streams
- Self-hosted control β no vendor lock-in
- Enhanced security with JWT, OAuth2, and custom authentication
- Plugin extensibility for custom business logic
Migration is straightforward since RESTHeart uses standard MongoDB connections and can connect to MongoDB Atlas or any MongoDB instance.
- Hasura/PostGraphile: PostgreSQL-focused, primarily GraphQL
- Prisma: ORM/query builder, not a standalone API server
- RESTHeart: MongoDB-native, generates both REST and GraphQL APIs
Yes. Architecture features:
- Stateless design enables horizontal scaling
- Java Virtual Threads handle 10K+ concurrent connections
- Used in production by Fortune 500 companies
- Clustering and load balancing support
No, for standard CRUD operations and queries. RESTHeart auto-generates all endpoints.
Yes, for custom business logic. Use the plugin system to add:
- Custom validation
- Business rules
- Third-party integrations
- Custom authentication flows
Dual-licensed:
- AGPL: Free, requires open-sourcing modifications if distributed
- Commercial: For proprietary applications, same features
Yes. RESTHeart connects to any MongoDB instance:
- MongoDB Atlas
- Self-hosted MongoDB
- Replica sets and sharded clusters
- AWS DocumentDB (partial compatibility)
- Azure Cosmos DB (partial compatibility)
Yes, via FerretDB. FerretDB is an open-source MongoDB-compatible database that uses PostgreSQL as its storage engine. It translates MongoDB wire protocol commands to SQL queries, allowing RESTHeart to work with PostgreSQL while maintaining MongoDB's document-oriented API and query language. This is ideal for organizations that want to use PostgreSQL's reliability and ecosystem while providing MongoDB-style APIs to their applications.
See our complete FerretDB tutorial for setup instructions.
- π Documentation β API reference and guides
- π€ Ask Sophia β AI documentation assistant
- π¬ Slack β Community chat
- π GitHub Issues β Bug reports and feature requests
- π‘ Stack Overflow β Tag:
restheart - π Book a Demo β Technical consultation
Contributions welcome. RESTHeart is open source (AGPL).
- Report bugs and request features via GitHub Issues
- Submit pull requests
- Improve documentation
- Share use cases
See CONTRIBUTING.md for guidelines.
Dual-licensed:
- AGPL v3 β Open source
- Commercial License β For proprietary applications
Same features in both licenses.
Commercial inquiries: [email protected]
Built with β€οΈ by SoftInstigate | GitHub | Website | Cloud