
MockAPI
Lightweight Local API Mock Server One binary Full-featured.
2 followers
Lightweight Local API Mock Server One binary Full-featured.
2 followers
MockAPI is a lightweight local API mock server for developers who want to move fast. šØ Web UI ā Dark theme interface to manage routes visually š„ Swagger Import ā Auto-generate mocks from OpenAPI specs š WebSocket & GraphQL ā Mock modern APIs š Proxy Mode ā Forward unmatched requests to real backend Perfect for: ⢠Frontend developers waiting for backend APIs ⢠Testing edge cases and error responses ⢠Prototyping and rapid development Open source and free. Built with Go.









As a full-stack developer, I work with APIs every day. Frontend waiting for backend, third-party API rate limits, microservice coordination... all these scenarios need mock data.
I've tried many mock tools, but something always felt off:
MockServer: Powerful but heavy, requires JVM
JSON Server: Lightweight but only REST, no dynamic responses
Postman Mock: Requires internet, paid for team collaboration
So I decided to build my own. The goal was simple:
Three months later, MockAPI was born.
Results at a Glance
Metric
Value
Runtime Dependencies
0
Installation
go install one command
Startup Time
< 100ms
Route Matching
24x faster
Memory Usage
94% less
Features:
ā REST Mock (dynamic routes, path params, wildcards, conditional responses)
ā GraphQL Mock
ā WebSocket Mock
ā gRPC-Web Mock
ā JavaScript scripting engine
ā Swagger/OpenAPI import
ā Built-in Web UI
ā Hot reload
Why Go?
I chose Go not because I only know Go (though that's partly true), but because it fits perfectly:
1. Zero Runtime Dependencies
Compile to a single binary. Users don't need Node.js, JVM, or any other runtime. Download and run.
2. Powerful Standard Library
Go's net/http is fast, encoding/json is sufficient, embed lets you embed the Web UI in the binary.
3. Cross-Platform Compilation
Compile once, run everywhere.
4. Simple Deployment
No complex dependencies, deploy without Docker.
Performance: From O(n) to O(1)
Initially, route matching was linear search. Performance degraded as routes increased.
Solution: RouteIndex
I designed a two-layer index structure:
Exact match: Direct map lookup, O(1)
Param routes: Grouped by prefix, reduces candidates
Wildcard routes: Grouped by method
Results
24x faster, 94% less memory. That's the power of choosing the right data structure.
Core Features
Dynamic Routes
Support :param and * wildcards.
JavaScript Engine
Generate dynamic responses with JavaScript when static isn't enough.
Swagger/OpenAPI Import
Import existing API docs, auto-generate mock routes.
Built-in Web UI
Manage in browser: http://localhost:8088/_ui
Features: Route management, visual editor, quick templates, request logs, real-time debugging.
Quick Start
Project Links
GitHub: https://github.com/fynntang/MockAPI
Website: https://mockapi.work
If this project helps you, please Star ā
Final Thoughts
Building MockAPI taught me:
Simplicity wins - Zero dependencies beats feature bloat
Performance early - Good data structures beat late optimization
Developer experience matters - CLI and Web UI improve usability
Test-driven - 26 tests let me sleep well
Happy Mocking! š¦