Metadata-Version: 2.4
Name: Flask-JSONRPC
Version: 4.0.0
Summary: Adds JSONRPC support to Flask.
Project-URL: Donate, https://github.com/sponsors/nycholas
Project-URL: Documentation, https://flask-jsonrpc.readthedocs.io/
Project-URL: Source Code, https://github.com/cenobites/flask-jsonrpc
Project-URL: Issue Tracker, https://github.com/cenobites/flask-jsonrpc/issues/
Project-URL: Website, https://flask-jsonrpc.readthedocs.io/
Author-email: Nycholas Oliveira <nycholas@cenobit.es>
Maintainer-email: "Cenobit Technologies Inc." <hi@cenobit.es>
License: Copyright (c) 2012-2024, Cenobit Technologies, Inc. http://cenobit.es/
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
         * Redistributions of source code must retain the above copyright notice,
           this list of conditions and the following disclaimer.
         * Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
         * Neither the name of the Cenobit Technologies, Inc. nor the names of
           its contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
        LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
        CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
        SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
        INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
        CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
        ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
        POSSIBILITY OF SUCH DAMAGE.
License-File: LICENSE.txt
Keywords: flask,flask-extensions,jsonrpc
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: Free Threading :: 1 - Unstable
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Requires-Python: >=3.10
Requires-Dist: annotated-types==0.7.0
Requires-Dist: eval-type-backport==0.3.1
Requires-Dist: flask<4.0,>=3.0.0
Requires-Dist: pydantic!=1.8,!=1.8.1,!=2.0.0,!=2.0.1,!=2.1.0,<3.0.0,>=1.7.4
Requires-Dist: typeguard==4.4.4
Requires-Dist: typing-extensions>=4.3.0
Requires-Dist: typing-inspect==0.9.0
Provides-Extra: async
Requires-Dist: flask[async]<4.0,>=3.0.0; extra == 'async'
Provides-Extra: dotenv
Requires-Dist: flask[dotenv]<4.0,>=3.0.0; extra == 'dotenv'
Description-Content-Type: text/markdown

![Release Status](https://github.com/cenobites/flask-jsonrpc/actions/workflows/release.yml/badge.svg)
![Tests Status](https://github.com/cenobites/flask-jsonrpc/actions/workflows/tests.yml/badge.svg?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/cenobites/flask-jsonrpc/badge.svg?branch=master)](https://coveralls.io/github/cenobites/flask-jsonrpc?branch=master)
[![Documentation Status](https://readthedocs.org/projects/flask-jsonrpc/badge/?version=latest)](https://flask-jsonrpc.readthedocs.io/en/latest/?badge=latest)
# Flask JSON-RPC

Basic JSON-RPC implementation for your Flask-powered sites.

Some reasons you might want to use:

* Simple, powerful, flexible, and pythonic API.
* Support [JSON-RPC 2.0](https://www.jsonrpc.org/specification "JSON-RPC 2.0") version.
* Support Python 3.10 or later.
* Experimental support to [Mypyc](https://mypyc.readthedocs.io/en/latest/introduction.html), it compiles Python modules to C extensions.
* The web browsable API.
* Run-time type checking functions defined with [PEP 484](https://www.python.org/dev/peps/pep-0484/ "PEP 484") argument (and return) type annotations.
* Extensive [documentation](https://flask-jsonrpc.readthedocs.io/en/latest/), and great community support.

There is a live example API for testing purposes, [available here](https://flask-jsonrpc.cenobit.es/api/browse/#/ "Web browsable API").

**Below:** *Screenshot from the browsable API*

![Web browsable API](https://f.cloud.github.com/assets/298350/1575590/203c595a-5150-11e3-99a0-4a6fd9bcbe52.png "Web browsable API")

### Adding Flask JSON-RPC to your application

1. Installation

```console
$ pip install Flask-JSONRPC
```

or

```console
$ git clone git://github.com/cenobites/flask-jsonrpc.git
$ cd flask-jsonrpc
$ python setup.py install
```


2. Getting Started

Create your application and initialize the Flask-JSONRPC.

```python
from flask import Flask
from flask_jsonrpc import JSONRPC

app = Flask("application")
jsonrpc = JSONRPC(app, "/api", enable_web_browsable_api=True)
```

Write JSON-RPC methods.

```python
@jsonrpc.method("App.index")
def index() -> str:
    return "Welcome to Flask JSON-RPC"
```

All code of example [run.py](https://github.com/cenobites/flask-jsonrpc/blob/master/run.py).


3. Running

```console
$ python run.py
 * Running on http://0.0.0.0:5000/
```

4. Testing

```console
$ curl -i -X POST \
   -H "Content-Type: application/json; indent=4" \
   -d '{
    "jsonrpc": "2.0",
    "method": "App.index",
    "params": {},
    "id": "1"
}' http://localhost:5000/api

HTTP/1.0 200 OK
Content-Type: application/json
Content-Length: 77
Server: Werkzeug/0.8.3 Python/2.7.3
Date: Fri, 14 Dec 2012 19:26:56 GMT

{
  "jsonrpc": "2.0",
  "id": "1",
  "result": "Welcome to Flask JSON-RPC"
}
```


### References

* [http://docs.python.org/](http://docs.python.org/)
* [https://flask.palletsprojects.com/](https://flask.palletsprojects.com/)
* [http://www.jsonrpc.org/](http://www.jsonrpc.org/)
