Skip to content

marle3003/mokapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4,337 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mokapi

Mock APIs Across Protocols. Test Faster. Ship Better.

Github release Build status Codecov branch MIT License

Download · Documentation

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.json

Then test your mock:

curl http://localhost/api/v3/pet/1 -H 'Accept: application/json'

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 Mokapi Web UI

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:

More examples mokapi.io/resources

Documentation

Support the Project

If Mokapi helps your team ship faster, consider supporting development:

Buy Me A Coffee

License

MIT License - see LICENSE for details.

Links