Mock REST APIs from JSON with zero coding within seconds.
Complete Documentation - For detailed usage, advanced features, and examples.
If you're a macOS Homebrew user, then you can install mocks
from homebrew-tap.
brew install mocks-rs/tap/mocks
If you're a Rust programmer, mocks
can be installed with cargo
.
cargo install mocks
If you're a Node.js user, you can install mocks
globally with npm
.
npm install -g mocks
Alternatively, you can run mocks
without installing using npx
.
npx @mocks-rs/mocks init storage.json
npx @mocks-rs/mocks run storage.json
Create a JSON file using the init
command:
mocks init storage.json
This creates a storage.json
file with sample data. Use the --empty
option to create an empty structure:
mocks init --empty storage.json
Start the mock server using your JSON file:
mocks run storage.json
Example JSON structure:
{
"posts": [
{ "id": "01J7BAKH37HPG116ZRRFKHBDGB", "title": "first post", "views": 100 },
{ "id": "01J7BAKH37GE8B688PT4RC7TP4", "title": "second post", "views": 10 }
],
"profile": { "id": "01J7BAQE1GMD78FN3J0FJCNS8T", "name": "mocks" }
}
This automatically creates REST endpoints:
curl http://localhost:3000/posts
curl http://localhost:3000/posts/01J7BAKH37HPG116ZRRFKHBDGB
curl http://localhost:3000/profile
For detailed information about available routes, query parameters, advanced configuration, and more features, visit the complete documentation.
For development information, see DEVELOPMENT.md.
This project is licensed under the MIT license.