API Mock Server

# api-mock-server - API Mock服务器

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "API Mock Server" with this command: npx skills add kaiyuelv/api-mock-server

api-mock-server - API Mock服务器

Metadata

FieldValue
Nameapi-mock-server
Slugapi-mock-server
Version1.0.0
Homepagehttps://github.com/openclaw/api-mock-server
Categorydevelopment
Tagsapi, mock, server, testing, stub, http, rest, json

Description

English

A lightweight API mock server for rapid prototyping and testing. Define routes with JSON/JSON Schema responses, support dynamic data generation, request validation, latency simulation, and webhook simulation.

中文

轻量级API Mock服务器,用于快速原型开发和测试。支持JSON/JSON Schema响应定义、动态数据生成、请求验证、延迟模拟和Webhook模拟。

Requirements

  • Python 3.8+
  • Flask >= 2.3.0
  • Faker >= 19.0.0
  • jsonschema >= 4.17.0
  • requests >= 2.31.0

Configuration

Environment Variables

MOCK_PORT=3000
MOCK_HOST=0.0.0.0
MOCK_LATENCY=0

Usage

Define Routes

from api_mock_server import MockServer

server = MockServer(port=3000)

# Simple JSON response
server.get("/users", {"users": [{"id": 1, "name": "Alice"}]})

# Dynamic response with path params
server.get("/users/{id}", lambda req: {
    "id": req.params["id"],
    "name": f"User_{req.params['id']}"
})

# POST with validation
server.post("/users", 
    response={"id": 123, "created": True},
    validate_schema={
        "type": "object",
        "required": ["name", "email"],
        "properties": {
            "name": {"type": "string"},
            "email": {"type": "string", "format": "email"}
        }
    }
)

server.start()

Load from Config File

from api_mock_server import MockServer

server = MockServer.from_config("mock-routes.json")
server.start()

API Reference

MockServer

  • get(path, response) - Define GET route
  • post(path, response, validate_schema) - Define POST route
  • put(path, response) - Define PUT route
  • delete(path, response) - Define DELETE route
  • patch(path, response) - Define PATCH route
  • from_config(path) - Load routes from JSON config
  • start() - Start the server
  • stop() - Stop the server

MockRequest

  • params - URL path parameters
  • query - Query string parameters
  • body - Request body
  • headers - Request headers

Examples

See examples/ directory for complete examples.

Testing

cd /root/.openclaw/workspace/skills/api-mock-server
python -m pytest tests/ -v

License

MIT License

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

Smart API Connector

Connect to any REST API using the agent's built-in web_fetch. Handles authentication headers, JSON payloads, error parsing, and retries. Use when: user wants...

Registry SourceRecently Updated
2380Profile unavailable
General

MLX Audio Server

Local 24x7 OpenAI-compatible API server for STT/TTS, powered by MLX on your Mac.

Registry SourceRecently Updated
2.6K0Profile unavailable
General

Wolai API 技能

Wolai API skill — 操作 wolai 笔记(块/页面/数据库)/ Wolai API Skill - Operate wolai notes (blocks, pages, database) via REST API

Registry SourceRecently Updated
3630Profile unavailable
General

Api Quick Tester

API 快速测试工具。一键测试 REST/GraphQL API,生成测试报告,模拟请求。适合前端/后端开发者。

Registry Source
1740Profile unavailable