go-mokapi
v0.39.0
Published
Easy and flexible API mocking
Maintainers
Readme
What is Mokapi?
Mokapi is an open-source API mocking tool that lets you develop and test without waiting for backends. Mock REST APIs, Kafka topics, LDAP directories, and SMTP servers using OpenAPI and AsyncAPI specifications.
Perfect for:
- Frontend developers building UIs before backends exist
- QA teams testing edge cases, errors, and timeouts
- DevOps engineers running reliable CI/CD tests without external dependencies
- API designers prototyping and validating contracts early
Quick Start
Try Instantly
npx go-mokapi https://petstore3.swagger.io/api/v3/openapi.jsonThen test your mock:
curl http://localhost/api/v3/pet/1 -H 'Accept: application/json'Install Globally
npm install -g go-mokapi
mokapi https://petstore3.swagger.io/api/v3/openapi.jsonOther Installation Methods
Check other installation methods here
Key Features
Multi-Protocol Support
Mock HTTP/HTTPS, Apache Kafka, LDAP, and SMTP — all from a single tool.
Specification-Driven
Uses OpenAPI and AsyncAPI specs as the source of truth. Your mocks stay aligned with your API contracts.
Dynamic Behavior with JavaScript
Control responses, simulate errors, add delays, or create complex workflows using embedded JavaScript:
import { on } from 'mokapi'
export default function() {
on('http', (request, response) => {
// Return 404 for specific IDs
if (request.path.petId === '999') {
response.statusCode = 404
return
}
// Customize response data
response.data.name = 'Custom Pet Name'
})
}Everything as Code
Version control your mocks alongside your code. Run them in CI/CD pipelines. No UI configuration required.
Configuration Patching
Override parts of your OpenAPI spec without modifying the original file. Perfect for testing different scenarios.
Built-in Dashboard
Visualize requests, responses, and logs in real-time at http://localhost:8080
Multiple Providers
Load specs from local files, HTTP URLs, Git repositories, or NPM packages.
Common Use Cases
Frontend Development
Mock backend APIs while building UIs. Test loading states, errors, and edge cases without waiting for real endpoints.
API Testing
Simulate timeouts, 500 errors, rate limits, and malformed responses. Test how your application handles failures.
CI/CD Integration
Run fast, reliable tests without external dependencies. No flaky tests due to network issues or unavailable services.
Contract Validation
Validate that your requests and responses match your OpenAPI specification. Catch breaking changes early.
Example Tutorials
Explore tutorials that walk you through mocking different protocols and scenarios:
Get started with REST API
Mock a REST API using OpenAPI specificationMock Kafka with AsyncAPI
Simulate Kafka topics and validate message producersMock LDAP Authentication
Test authentication flows without a real LDAP serverMock SMTP Mail Servers
Test email workflows without sending real messagesCI/CD Integration with GitHub Actions
Run Mokapi in automated test pipelines
More examples mokapi.io/resources
Documentation
- Getting Started Guide
- HTTP/REST API Documentation
- Kafka Documentation
- LDAP Documentation
- SMTP/Mail Documentation
- JavaScript API Reference
- Configuration Guide
Support the Project
If Mokapi helps your team ship faster, consider supporting development:
License
MIT License - see LICENSE for details.
Links
- Website: mokapi.io
- GitHub: github.com/marle3003/mokapi
- NPM Package: npmjs.com/package/go-mokapi
- Documentation: mokapi.io/docs
- Tutorials: mokapi.io/resources/tutorials
- Blog: mokapi.io/resources/blogs
