Skip to main content

Mock server

Simple mock server for REST and XML-RPC API

It can mock GET, POST, PUT, PATCH, DELETE and some more rarely used HTTP methods.

Build status at Travis CI: travis

DEMO

http://mockapi.org/__manage

Installation

Install with pip:

$ pip install mock-server

Or install with easy_install:

$ easy_install mock-server

And after run:

$ mock-server --dir=/path/to/api

It will be listening on port 8888 and wait for your HTTP requests.

Overview

For create mock for url path go to:


Mocked GET /user/tom:

$ curl -v -X GET http://mockapi.org/user/tom

> GET /user/tom HTTP/1.1
> Host: mockapi.org
> Accept: */*
>
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Content-Type: application/json; charset=utf-8
< Content-Length: 64
< Server: TornadoServer/2.4.1
<
{
    "name": "Tom",
    "surname": "Smith",
    "age": 22
}

Features

  • Mocking REST API.

  • Mocking RPC API (xml, json).

  • Upstream server proxy (proxy an existing api).

  • Variables in url path.

  • Simple api documentation (markdown).

  • Api authentication (HTTP Basic authentication).

Format

response content format: %METHOD%_%STATUS%.%FORMAT%

response headers format: %METHOD%_H_%STATUS%.%FORMAT%

root_dir/
    GET_200.json         # response content for GET /
    GET_H_200.json       # headers for GET /
    user/
        DELETE_404.xml   # response content for DELETE /user.xml?__statusCode=404
        POST_200.json    # response content for POST /user
        POST_H_200.json  # headers for POST /user

Bug report

If you have any trouble, report bug at GitHub Issue https://github.com/tomashanacek/mock-server/issues

History

0.3

  • upstream server proxy (proxy an existing api)

  • variables in url path

  • simple api documentation (markdown)

  • api authentication (HTTP Basic authentication)

  • manage interface improvements

No notes on earlier releases.

Release files for mock-server 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mock-server 0.3.0
File Size Uploaded
mock-server-0.3.0.tar.gz 453.9 kB Details

Release files / mock-server-0.3.0.tar.gz

Download URL mock-server-0.3.0.tar.gz
Size 453.9 kB
Tags Source
SHA-256 checksum
How to use checksums
589b87cd58392013156e16febdd8afcb2e33c1a0af89d0a1a72f569f091257cb
BLAKE2b-256 checksum
How to use checksums
efb26ab458c4d2b19d90c49d502d9100d6fcaa4f98dbce14a2f1b8ea0c830f5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.3.9

2 release files

0.3.8

2 release files

0.3.7

1 release file

0.3.6

1 release file

0.3.5

1 release file

0.3.4

1 release file

0.3.3

1 release file

0.3.2

1 release file

0.3.1

1 release file

This release

0.3.0 This release

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page