fake-api-server


Namefake-api-server JSON
Version 0.4.0 PyPI version JSON
download
home_pagehttps://github.com/Chisanan232/PyMock-Server
SummaryπŸ•ΈπŸ€–πŸ‘Ί A Python tool to fake API server, e.g., RESTful API server, easily and humanly without any coding.
upload_time2025-02-07 00:03:59
maintainerNone
docs_urlNone
authorLiu, Bryant
requires_python<3.13,>=3.8
license MIT License Copyright (c) 2022 Bryant Liu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords mock api mock server mock api server web server
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            <h1 align="center">
  PyFake-API-Server
</h1>

<p align="center">
  <a href="https://pypi.org/project/fake-api-server">
    <img src="https://img.shields.io/pypi/v/fake-api-server?color=%23099cec&amp;label=PyPI&amp;logo=pypi&amp;logoColor=white" alt="PyPI package version">
  </a>
  <a href="https://github.com/Chisanan232/PyFake-API-Server/releases">
    <img src="https://img.shields.io/github/release/Chisanan232/PyFake-API-Server.svg?label=Release&logo=github" alt="GitHub release version">
  </a>
  <a href="https://github.com/Chisanan232/PyFake-API-Server/actions/workflows/ci.yaml">
    <img src="https://github.com/Chisanan232/PyFake-API-Server/actions/workflows/ci.yaml/badge.svg" alt="CI/CD status">
  </a>
  <a href="https://codecov.io/gh/Chisanan232/PyFake-API-Server">
    <img src="https://codecov.io/gh/Chisanan232/PyFake-API-Server/graph/badge.svg?token=r5HJxg9KhN" alt="Test coverage">
  </a>
  <a href="https://results.pre-commit.ci/latest/github/Chisanan232/PyFake-API-Server/master">
    <img src="https://results.pre-commit.ci/badge/github/Chisanan232/PyFake-API-Server/master.svg" alt="Pre-Commit building state">
  </a>
  <a href="https://sonarcloud.io/summary/new_code?id=Chisanan232_PyFake-API-Server">
    <img src="https://sonarcloud.io/api/project_badges/measure?project=Chisanan232_PyFake-API-Server&metric=alert_status" alt="Code quality level">
  </a>
  <a href="https://chisanan232.github.io/PyFake-API-Server/stable/">
    <img src="https://github.com/Chisanan232/PyFake-API-Server/actions/workflows/documentation.yaml/badge.svg" alt="documentation CI status">
  </a>
  <a href="https://opensource.org/licenses/MIT">
    <img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="Software license">
  </a>

</p>

<img align="center" src="https://raw.githubusercontent.com/Chisanan232/PyFake-API-Server/refs/heads/master/docs/_images/pyfake-api-server_demonstration.gif" alt="pyfake-api-server demonstration" />

<p align="center">
  <em>PyFake-API-Server</em> is a Python tool to fake API server easily and humanly without any coding.
</p>

> [!NOTE]
> It names **_PyMock-API_** before version **0.2.0**.
>
> [![PyPI](https://img.shields.io/pypi/v/PyMock-API?color=%23099cec&amp;label=PyPI&amp;logo=pypi&amp;logoColor=white)](https://pypi.org/project/PyMock-API)

[Overview](#overview) | [Python versions support](#Python-versions-support) | [Quickly Start](#quickly-start) | [Documentation](#documentation)
<hr>


## 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](https://img.shields.io/pypi/pyversions/fake-api-server.svg?logo=python&logoColor=FBE072)](https://pypi.org/project/fake-api-server)


## 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](#install-command-line-tool)
* [Configure](#configure-setting-to-mock-target-apis)
* [Run](#run-command-to-set-up-application)

### 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``.

```console
>>> 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:

```console
>>> 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:

```console
>>> 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:

```yaml
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!

```console
>>> mock 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``:

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

## Documentation

The [documentation](https://chisanan232.github.io/PyFake-API-Server/stable/) contains more details, demonstrations and anything you need about **_PyFake-API-Server_**.

* [Getting start](https://chisanan232.github.io/PyFake-API-Server/stable/getting-started/version-requirements/) helps you start to prepare environment, install dependencies and configure the detail settings with explanation in detail.
    * What [requirement](https://chisanan232.github.io/PyFake-API-Server/stable/getting-started/version-requirements/) I need to prepare?
    * How can I [install](https://chisanan232.github.io/PyFake-API-Server/stable/getting-started/installation/) it?
    * How to [configure the details of API](https://chisanan232.github.io/PyFake-API-Server/stable/getting-started/configure-your-api/)?
    * I have configuration right now. How can I [set up a mock server](https://chisanan232.github.io/PyFake-API-Server/stable/getting-started/setup-web-server/)?
* Want to learn more how to use it?
    * What exactly feature it can use by [command lines](https://chisanan232.github.io/PyFake-API-Server/stable/command-line-usage/)?
    * Want to know more [magic settings](https://chisanan232.github.io/PyFake-API-Server/stable/configure-references/config-basic-info/) to mock API?
* Want to contribute to this project?
    * I face something [issue](https://chisanan232.github.io/PyFake-API-Server/stable/development/contributing/reporting-a-bug/) it cannot work finely!
    * I want to [wish a feature or something change](https://chisanan232.github.io/PyFake-API-Server/stable/development/contributing/requesting-a-feature/).
    * If you're interested in **_PyFake-API-Server_** and have any ideas want to design it, even implement it, it's very welcome to [contribute](https://chisanan232.github.io/PyFake-API-Server/stable/development/contributing/join_in_developing/) **_PyFake-API-Server_**!
* About the [release notes](https://chisanan232.github.io/PyFake-API-Server/latest/release_note/).


## Coding style and following rules

**_PyFake-API-Server_** follows coding styles **_black_** and **_PyLint_** to control code quality.

[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![linting: pylint](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/pylint-dev/pylint)


## Downloading state

**_PyFake-API-Server_** still a young open source which keep growing. Here's its download state:

[![Downloads](https://pepy.tech/badge/fake-api-server)](https://pepy.tech/project/fake-api-server)
[![Downloads](https://pepy.tech/badge/fake-api-server/month)](https://pepy.tech/project/fake-api-server)


## License

[MIT License](./LICENSE)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Chisanan232/PyMock-Server",
    "name": "fake-api-server",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.13,>=3.8",
    "maintainer_email": null,
    "keywords": "mock, API, mock server, mock API server, web, server",
    "author": "Liu, Bryant",
    "author_email": "chi10211201@cycu.org.tw",
    "download_url": "https://files.pythonhosted.org/packages/93/2a/aa6603530cae939eb09b635cfff0344437595e10411ccca49f66a38bd873/fake_api_server-0.4.0.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">\n  PyFake-API-Server\n</h1>\n\n<p align=\"center\">\n  <a href=\"https://pypi.org/project/fake-api-server\">\n    <img src=\"https://img.shields.io/pypi/v/fake-api-server?color=%23099cec&amp;label=PyPI&amp;logo=pypi&amp;logoColor=white\" alt=\"PyPI package version\">\n  </a>\n  <a href=\"https://github.com/Chisanan232/PyFake-API-Server/releases\">\n    <img src=\"https://img.shields.io/github/release/Chisanan232/PyFake-API-Server.svg?label=Release&logo=github\" alt=\"GitHub release version\">\n  </a>\n  <a href=\"https://github.com/Chisanan232/PyFake-API-Server/actions/workflows/ci.yaml\">\n    <img src=\"https://github.com/Chisanan232/PyFake-API-Server/actions/workflows/ci.yaml/badge.svg\" alt=\"CI/CD status\">\n  </a>\n  <a href=\"https://codecov.io/gh/Chisanan232/PyFake-API-Server\">\n    <img src=\"https://codecov.io/gh/Chisanan232/PyFake-API-Server/graph/badge.svg?token=r5HJxg9KhN\" alt=\"Test coverage\">\n  </a>\n  <a href=\"https://results.pre-commit.ci/latest/github/Chisanan232/PyFake-API-Server/master\">\n    <img src=\"https://results.pre-commit.ci/badge/github/Chisanan232/PyFake-API-Server/master.svg\" alt=\"Pre-Commit building state\">\n  </a>\n  <a href=\"https://sonarcloud.io/summary/new_code?id=Chisanan232_PyFake-API-Server\">\n    <img src=\"https://sonarcloud.io/api/project_badges/measure?project=Chisanan232_PyFake-API-Server&metric=alert_status\" alt=\"Code quality level\">\n  </a>\n  <a href=\"https://chisanan232.github.io/PyFake-API-Server/stable/\">\n    <img src=\"https://github.com/Chisanan232/PyFake-API-Server/actions/workflows/documentation.yaml/badge.svg\" alt=\"documentation CI status\">\n  </a>\n  <a href=\"https://opensource.org/licenses/MIT\">\n    <img src=\"https://img.shields.io/badge/License-MIT-yellow.svg\" alt=\"Software license\">\n  </a>\n\n</p>\n\n<img align=\"center\" src=\"https://raw.githubusercontent.com/Chisanan232/PyFake-API-Server/refs/heads/master/docs/_images/pyfake-api-server_demonstration.gif\" alt=\"pyfake-api-server demonstration\" />\n\n<p align=\"center\">\n  <em>PyFake-API-Server</em> is a Python tool to fake API server easily and humanly without any coding.\n</p>\n\n> [!NOTE]\n> It names **_PyMock-API_** before version **0.2.0**.\n>\n> [![PyPI](https://img.shields.io/pypi/v/PyMock-API?color=%23099cec&amp;label=PyPI&amp;logo=pypi&amp;logoColor=white)](https://pypi.org/project/PyMock-API)\n\n[Overview](#overview) | [Python versions support](#Python-versions-support) | [Quickly Start](#quickly-start) | [Documentation](#documentation)\n<hr>\n\n\n## Overview\n\nDo you ever have experience about needing to set up a very simple application and write some APIs with hardcode response again and again\nfor developing Font-End site? **_PyFake-API-Server_** provides a command line tool to let developers could quickly and easily set up application\nto mock APIs with configuration only.\n\n\n## Python versions support\n\nThe code base of **_PyFake-API-Server_** to set up an application still depends on third party Python package, i.e., **_Flask_**, **_FastAPI_**,\netc. So the Python versions it supports also be affected by them, e.g., **_Flask_** only supports Python version 3.8 up currently. So\n**_PyFake-API-Server_** also only supports version Python 3.8 up.\n\n[![Supported Versions](https://img.shields.io/pypi/pyversions/fake-api-server.svg?logo=python&logoColor=FBE072)](https://pypi.org/project/fake-api-server)\n\n\n## Quickly Start\n\nHere section would lead you quickly start to set up your first one application by **_PyFake-API-Server_** for mocking API server easily.\n\nIn basically, it has 3 steps: install the package, configure settings about the APIs for mocking and run command.\n\n* [Install](#install-command-line-tool)\n* [Configure](#configure-setting-to-mock-target-apis)\n* [Run](#run-command-to-set-up-application)\n\n### Install command line tool\n\nFirst of all, we need to install the command line tool and the way to install is same as installing Python package by ``pip``.\n\n```console\n>>> pip install fake-api-server\n```\n\nIf the runtime environment has installed some Python web framework, e.g., **_Flask_**, you also could install **_PyFake-API-Server_**\nwith one specific option as following:\n\n```console\n>>> pip install \"fake-api-server[flask]\"\n```\n\nThen it would only install the lowest Python dependencies you need.\n\nAfter you done above step, please make sure the command line tool feature should work finely by below command:\n\n```console\n>>> fake --help\n```\n\n> **Note**\n>\n> Please take a look at option _--app-type_ (this option is in subcommand **_mock run_**) of the command line tool. Its option\n> value could be ``auto``, ``flask`` or ``fastapi``. It means that **_PyFake-API-Server_** only supports 2 Python web frameworks: **_Flask_**\n> and **_FastAPI_**.\n\n### Configure setting to mock target APIs\n\nNow, we have the command line tool. Let's configure the settings it needs to set up application to mock API.\n\nThe configuration format of **_PyFake-API-Server_** to use is **YAML**. So let's write below settings in YAML file:\n\n```yaml\nmocked_apis:\n  foo:\n    url: '/foo'\n    http:\n      request:\n        method: 'GET'\n      response:\n        strategy: string\n        value: 'This is Foo API.'\n```\n\n### Run command to set up application\n\nNow, both of the command line tool and configuration have been already. So let's try to run the command to set up application!\n\n```console\n>>> mock rest-server run -c <your configuration path>\n```\n\nYou would see some log messages in terminal and that is the log of web server by one specific Python web framework.\n\nAnd you could test the API by ``curl``:\n\n```console\n>>> curl http://127.0.0.1:9672/foo\n\"This is Foo home API.\"%\n```\n\n## Documentation\n\nThe [documentation](https://chisanan232.github.io/PyFake-API-Server/stable/) contains more details, demonstrations and anything you need about **_PyFake-API-Server_**.\n\n* [Getting start](https://chisanan232.github.io/PyFake-API-Server/stable/getting-started/version-requirements/) helps you start to prepare environment, install dependencies and configure the detail settings with explanation in detail.\n    * What [requirement](https://chisanan232.github.io/PyFake-API-Server/stable/getting-started/version-requirements/) I need to prepare?\n    * How can I [install](https://chisanan232.github.io/PyFake-API-Server/stable/getting-started/installation/) it?\n    * How to [configure the details of API](https://chisanan232.github.io/PyFake-API-Server/stable/getting-started/configure-your-api/)?\n    * I have configuration right now. How can I [set up a mock server](https://chisanan232.github.io/PyFake-API-Server/stable/getting-started/setup-web-server/)?\n* Want to learn more how to use it?\n    * What exactly feature it can use by [command lines](https://chisanan232.github.io/PyFake-API-Server/stable/command-line-usage/)?\n    * Want to know more [magic settings](https://chisanan232.github.io/PyFake-API-Server/stable/configure-references/config-basic-info/) to mock API?\n* Want to contribute to this project?\n    * I face something [issue](https://chisanan232.github.io/PyFake-API-Server/stable/development/contributing/reporting-a-bug/) it cannot work finely!\n    * I want to [wish a feature or something change](https://chisanan232.github.io/PyFake-API-Server/stable/development/contributing/requesting-a-feature/).\n    * If you're interested in **_PyFake-API-Server_** and have any ideas want to design it, even implement it, it's very welcome to [contribute](https://chisanan232.github.io/PyFake-API-Server/stable/development/contributing/join_in_developing/) **_PyFake-API-Server_**!\n* About the [release notes](https://chisanan232.github.io/PyFake-API-Server/latest/release_note/).\n\n\n## Coding style and following rules\n\n**_PyFake-API-Server_** follows coding styles **_black_** and **_PyLint_** to control code quality.\n\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![linting: pylint](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/pylint-dev/pylint)\n\n\n## Downloading state\n\n**_PyFake-API-Server_** still a young open source which keep growing. Here's its download state:\n\n[![Downloads](https://pepy.tech/badge/fake-api-server)](https://pepy.tech/project/fake-api-server)\n[![Downloads](https://pepy.tech/badge/fake-api-server/month)](https://pepy.tech/project/fake-api-server)\n\n\n## License\n\n[MIT License](./LICENSE)\n",
    "bugtrack_url": null,
    "license": "\nMIT License\n\nCopyright (c) 2022 Bryant Liu\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n",
    "summary": "\ud83d\udd78\ud83e\udd16\ud83d\udc7a A Python tool to fake API server, e.g., RESTful API server, easily and humanly without any coding.",
    "version": "0.4.0",
    "project_urls": {
        "Changelog": "https://chisanan232.github.io/PyMock-Server/latest/release_note/",
        "Documentation": "https://chisanan232.github.io/PyMock-Server/stable/",
        "Homepage": "https://github.com/Chisanan232/PyMock-Server",
        "Project Management": "https://app.clickup.com/9018752317/v/f/90183126979/90182605225",
        "Repository": "https://github.com/Chisanan232/PyMock-Server"
    },
    "split_keywords": [
        "mock",
        " api",
        " mock server",
        " mock api server",
        " web",
        " server"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ef96c98f1c2efa6010c9b90d47e0ab6b18e25f1f9af3b2167be23965c53e6c41",
                "md5": "d9bd5da659f3b71e5dff477c43150f7f",
                "sha256": "c39474bae653484b7c9e9ba9edacae11f149acd6aa4ec24e4ffd55029aa31e9c"
            },
            "downloads": -1,
            "filename": "fake_api_server-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d9bd5da659f3b71e5dff477c43150f7f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.13,>=3.8",
            "size": 131141,
            "upload_time": "2025-02-07T00:03:57",
            "upload_time_iso_8601": "2025-02-07T00:03:57.274123Z",
            "url": "https://files.pythonhosted.org/packages/ef/96/c98f1c2efa6010c9b90d47e0ab6b18e25f1f9af3b2167be23965c53e6c41/fake_api_server-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "932aaa6603530cae939eb09b635cfff0344437595e10411ccca49f66a38bd873",
                "md5": "f6f8001bbcd05456ec98aac1169cc699",
                "sha256": "b0953bb65883d7ea4deb64aaf815dbc83d8b0adc88f959c88a5221e456061514"
            },
            "downloads": -1,
            "filename": "fake_api_server-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f6f8001bbcd05456ec98aac1169cc699",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.13,>=3.8",
            "size": 85209,
            "upload_time": "2025-02-07T00:03:59",
            "upload_time_iso_8601": "2025-02-07T00:03:59.090273Z",
            "url": "https://files.pythonhosted.org/packages/93/2a/aa6603530cae939eb09b635cfff0344437595e10411ccca49f66a38bd873/fake_api_server-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-07 00:03:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Chisanan232",
    "github_project": "PyMock-Server",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "fake-api-server"
}
        
Elapsed time: 1.16897s