Build REST APIs in Minutes, Not Days
JSON REST API is a lightweight, plugin-based framework that makes building REST APIs incredibly simple. With automatic validation, smart relationships, and native JSON:API support, you can focus on your business logic instead of boilerplate.
Why JSON REST API?
π Zero Configuration
Get a fully functional API running in under 5 minutes. No complex setup or configuration files needed.
π Plugin Architecture
Extend your API with powerful plugins. Authentication, validation, CORS, and more - just plug and play.
π Smart Relationships
Define relationships once and get automatic joins, nested queries, and eager loading out of the box.
β Built-in Validation
Schema-based validation ensures your data is always clean. No more manual validation code.
π¦ Multiple Storage Options
Start with in-memory storage for development, switch to MySQL for production. Same API, no code changes.
π― JSON:API Compliant
Follow industry standards with native JSON:API support. Compatible with any JSON:API client library.
π Microservices Ready
Build distributed systems with native microservices support. Multiple transports, service discovery, and more.
π CQRS Support
Implement Command Query Responsibility Segregation with event sourcing, projections, and sagas.
π API Gateway
Transform into an API gateway to orchestrate external services with circuit breakers and saga support.
Quick Example
import { createApi, Schema } from 'json-rest-api'
import express from 'express'
const app = express()
const api = createApi({
storage: 'memory',
http: { app }
})
api.addResource('users', new Schema({
name: { type: 'string', required: true },
email: { type: 'string', format: 'email' },
age: { type: 'number', min: 0 }
}))
app.listen(3000, () => {
console.log('API running at http://localhost:3000/api/users')
})
Thatβs it! You now have a fully functional REST API with:
GET /api/users
- List all usersGET /api/users/:id
- Get a specific userPOST /api/users
- Create a new userPATCH /api/users/:id
- Update a userDELETE /api/users/:id
- Delete a user
Try It Out
# Create a user
curl -X POST http://localhost:3000/api/users \
-H "Content-Type: application/json" \
-d '{"data":{"attributes":{"name":"Alice","email":"alice@example.com","age":28}}}'
# List all users
curl http://localhost:3000/api/users
# Get a specific user
curl http://localhost:3000/api/users/1
# Update a user
curl -X PATCH http://localhost:3000/api/users/1 \
-H "Content-Type: application/json" \
-d '{"data":{"attributes":{"age":29}}}'
# Delete a user
curl -X DELETE http://localhost:3000/api/users/1
Ready to Start?
Installation
npm install json-rest-api
Learn More
- Complete Guide - Everything you need to know
- API Reference - Detailed API documentation
- Tutorial - Step-by-step walkthrough
- GitHub - Source code and issues
Advanced Topics
- API Gateway - Orchestrate external services
- CLI Interface - Command-line interface for your API
Enterprise Features
- Enterprise Guide - Complete guide for enterprise teams
- Microservices Architecture - Build distributed systems
- CQRS Pattern - Command Query Responsibility Segregation
- Domain-Driven Design - DDD patterns and implementation