Skip to main content

PyFake-API-Server

PyPI package version GitHub release version CI/CD status Test coverage Pre-Commit building state Code quality level documentation CI status Software license

pyfake-api-server demonstration

PyFake-API-Server is a Python tool to fake API server easily and humanly without any coding.

[!NOTE] It names PyMock-API before version 0.2.0.

PyPI

Overview | Python versions support | Quickly Start | Documentation


Overview

Do you ever have experience about needing to set up a very simple application and write some APIs with hardcode response again and again for developing Font-End site? PyFake-API-Server provides a command line tool to let developers could quickly and easily set up application to mock APIs with configuration only.

Python versions support

The code base of PyFake-API-Server to set up an application still depends on third party Python package, i.e., Flask, FastAPI, etc. So the Python versions it supports also be affected by them, e.g., Flask only supports Python version 3.8 up currently. So PyFake-API-Server also only supports version Python 3.8 up.

Supported Versions

Quickly Start

Here section would lead you quickly start to set up your first one application by PyFake-API-Server for mocking API server easily.

In basically, it has 3 steps: install the package, configure settings about the APIs for mocking and run command.

Install command line tool

First of all, we need to install the command line tool and the way to install is same as installing Python package by pip.

>>> pip install fake-api-server

If the runtime environment has installed some Python web framework, e.g., Flask, you also could install PyFake-API-Server with one specific option as following:

>>> pip install "fake-api-server[flask]"

Then it would only install the lowest Python dependencies you need.

After you done above step, please make sure the command line tool feature should work finely by below command:

>>> fake --help

Note

Please take a look at option --app-type (this option is in subcommand mock run) of the command line tool. Its option value could be auto, flask or fastapi. It means that PyFake-API-Server only supports 2 Python web frameworks: Flask and FastAPI.

Configure setting to mock target APIs

Now, we have the command line tool. Let's configure the settings it needs to set up application to mock API.

The configuration format of PyFake-API-Server to use is YAML. So let's write below settings in YAML file:

mocked_apis:
  foo:
    url: '/foo'
    http:
      request:
        method: 'GET'
      response:
        strategy: string
        value: 'This is Foo API.'

Run command to set up application

Now, both of the command line tool and configuration have been already. So let's try to run the command to set up application!

>>> fake rest-server run -c <your configuration path>

You would see some log messages in terminal and that is the log of web server by one specific Python web framework.

And you could test the API by curl:

>>> curl http://127.0.0.1:9672/foo
"This is Foo home API."%

Documentation

The documentation contains more details, demonstrations and anything you need about PyFake-API-Server.

Coding style and following rules

PyFake-API-Server follows coding styles black and PyLint to control code quality.

Code style: black linting: pylint

Downloading state

PyFake-API-Server still a young open source which keep growing. Here's its download state:

Downloads Downloads

License

MIT License

Metadata

Release files for fake-api-server 0.4.1

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

Source distribution (sdist)

Source distribution for fake-api-server 0.4.1
File Size Uploaded
fake_api_server-0.4.1.tar.gz 85.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fake-api-server 0.4.1
File Interpreter ABI Platform
fake_api_server-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 216.9 kB

Release files / fake_api_server-0.4.1.tar.gz

Download URL fake_api_server-0.4.1.tar.gz
Size 85.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b9e53c4b6874a0f49f688a7a522d32960456bdc66975479d4cd7b57e501826c8
BLAKE2b-256 checksum
How to use checksums
7a897b56f09b4cc5586bd0c6fa23050c2cdbb97224314a7270a4fd56a6231aca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.10.16 Linux/6.8.0-1021-azure

Release files / fake_api_server-0.4.1-py3-none-any.whl

Download URL fake_api_server-0.4.1-py3-none-any.whl
Size 131.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db46199e972261c22e855d3aba48844c3fc2ca06f687c21f330deb50247a188f
BLAKE2b-256 checksum
How to use checksums
59f8d68a58eba2be4f6f039bebb2e475c4c51d99554ab86bf6216c21414b0fc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.10.16 Linux/6.8.0-1021-azure

Release history Release notifications | RSS feed

0.4.2

2 release files

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.2.0

2 release files

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