Skip to main content

Yet another way to build APIs using AIOHTTP framework

Project description

aioapi

Build Status codecov PyPI PyPI - Downloads GitHub

Yet another way to build APIs using AIOHTTP framework.

Follow documentation to know what you can do with AIOAPI.

Installation

$ pip install aioapi

Usage & Examples

Below you can find a simple, but powerful example of AIOAPI library usage:

import aioapi as api
from aioapi import Body, PathParam
from aioapi.middlewares import validation_error_middleware
from aiohttp import web
from pydantic import BaseModel


class User(BaseModel):
    name: str
    age: int = 42


async def hello_body(user_id: PathParam[int], body: Body[User]):
    user = body.cleaned
    return web.json_response(
        {"id": user_id.cleaned, "name": user.name, "age": user.age}
    )


def main():
    app = web.Application()

    app.add_routes([api.post("/hello/{user_id}", hello_body)])
    app.middlewares.append(validation_error_middleware)

    web.run_app(app)


if __name__ == "__main__":
    main()

And there are also more examples of usage at examples/ directory.

To run them use command below:

$ make example

Contributing

To work on the AIOAPI codebase, you'll want to clone the project locally and install the required dependencies via poetry:

$ git clone git@github.com:Gr1N/aioapi.git
$ make install

To run tests and linters use command below:

$ make lint && make test

If you want to run only tests or linters you can explicitly specify what you want to run, e.g.:

$ make lint-black

Milestones

If you're interesting in project's future you can find milestones and plans at projects page.

License

AIOAPI is licensed under the MIT license. See the license file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aioapi-0.3.0a0.tar.gz (8.5 kB view hashes)

Uploaded Source

Built Distribution

aioapi-0.3.0a0-py3-none-any.whl (9.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page