fastapi-sio


Namefastapi-sio JSON
Version 0.4.0 PyPI version JSON
download
home_page
SummarySocket.io for FastAPI with AsyncAPI documentation
upload_time2023-12-29 13:03:22
maintainer
docs_urlNone
authorMarian Hlavac
requires_python>=3.10,<4.0
licenseApache-2.0
keywords fastapi socket.io asyncapi
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # fastapi-sio

![FastAPI library](https://img.shields.io/badge/-FastAPI-009688?logo=fastapi&logoColor=white)
![Socket.io](https://img.shields.io/badge/-Socket.io-black?logo=socket.io&logoColor=white)
![Uses AsyncAPI](https://img.shields.io/badge/-AsyncAPI-4f8fbe)
![Current state](https://img.shields.io/badge/status-in_development-orange)

**Socket.io FastAPI integration library with first-class documentation using AsyncAPI**

The usage of the library is very familiar to the experience you‘re used to in FastAPI. Automatic documentation, type hints everywhere and heavy use of Pydantic.

## Features

- First-class generated specification & documentation
- Uses [python_socketio](https://python-socketio.readthedocs.io/en/latest/) underneath
- Fully typed using pydantic, including the [AsyncAPI spec](./fastapi_sio/schemas/asyncapi.py)
- Streamlined emit to clients ([learn more in docs](./docs/emitting.md))
- Forces strictly to emit correct data type  ([see the example](./docs/example.md))

## What‘s Missing?
  
- [ ] Serve AsyncAPI studio at /sio/docs
    - Unfortunately, AsyncAPI studio doesn‘t work the same way as Swagger UI, there is currently no way to use CDN hosted built package and supply only single html file and URL with spec JSON
- [ ] Support for more obscure fields of AsyncAPI, such as `traits`, ...

## Usage Example

```python
fastapi_app = FastAPI()
sio_app = FastAPISIO(app=fastapi_app)

purr_channel = sio_app.create_emitter(
    "purrs",
    model=PurrModel,
    summary="Channel for purrs",
    description="Receive any purrs here!",
)

@sio_app.on(
    "rubs",
    model=BellyRubModel,
    summary="Channel for belly rubs",
    description="Send your belly rubs through here!",
)
async def handle_rub(sid, data):
    await purr_channel.emit(
        PurrModel(loudness=2, detail="Purr for all listeners")
    )
    return "Ack to the one who rubbed"
```

👉 [Check out the example AsyncAPI documentation output!](https://studio.asyncapi.com/?url=https://raw.githubusercontent.com/marianhlavac/fastapi-sio/master/examples/from_readme_asyncapi.json)

By default (you can change these values):
 - the Socket.io endpoint path is **`/sio/socket.io`** (the `socket.io` part is set automatically by some clients)
 - The AsyncAPI spec file is at **`/sio/docs/asyncapi.json`**

Find more in the [examples](/docs/examples.md).

## Documentation & Reference

Refer to the [/docs](./docs/index.md) directory to learn how to use this library in your project.

_TODO: This documentation will be hosted on Github Pages in the near future, hopefully._


## Contribution

...

## Used by

<a href="https://dronetag.cz"><img src="https://dronetag.cz/assets/logo-full.svg" height="32" /></a>

[Feel free to open a PR](https://github.com/marianhlavac/fastapi-sio/pulls) to add your project or company to this list.
            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "fastapi-sio",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "fastapi,socket.io,asyncapi",
    "author": "Marian Hlavac",
    "author_email": "m@marianhlavac.cz",
    "download_url": "https://files.pythonhosted.org/packages/b0/a1/d476a0b172e1718d3e946528ac51291e27cdeba17fc359c6b3e8365111c3/fastapi_sio-0.4.0.tar.gz",
    "platform": null,
    "description": "# fastapi-sio\n\n![FastAPI library](https://img.shields.io/badge/-FastAPI-009688?logo=fastapi&logoColor=white)\n![Socket.io](https://img.shields.io/badge/-Socket.io-black?logo=socket.io&logoColor=white)\n![Uses AsyncAPI](https://img.shields.io/badge/-AsyncAPI-4f8fbe)\n![Current state](https://img.shields.io/badge/status-in_development-orange)\n\n**Socket.io FastAPI integration library with first-class documentation using AsyncAPI**\n\nThe usage of the library is very familiar to the experience you\u2018re used to in FastAPI. Automatic documentation, type hints everywhere and heavy use of Pydantic.\n\n## Features\n\n- First-class generated specification & documentation\n- Uses [python_socketio](https://python-socketio.readthedocs.io/en/latest/) underneath\n- Fully typed using pydantic, including the [AsyncAPI spec](./fastapi_sio/schemas/asyncapi.py)\n- Streamlined emit to clients ([learn more in docs](./docs/emitting.md))\n- Forces strictly to emit correct data type  ([see the example](./docs/example.md))\n\n## What\u2018s Missing?\n  \n- [ ] Serve AsyncAPI studio at /sio/docs\n    - Unfortunately, AsyncAPI studio doesn\u2018t work the same way as Swagger UI, there is currently no way to use CDN hosted built package and supply only single html file and URL with spec JSON\n- [ ] Support for more obscure fields of AsyncAPI, such as `traits`, ...\n\n## Usage Example\n\n```python\nfastapi_app = FastAPI()\nsio_app = FastAPISIO(app=fastapi_app)\n\npurr_channel = sio_app.create_emitter(\n    \"purrs\",\n    model=PurrModel,\n    summary=\"Channel for purrs\",\n    description=\"Receive any purrs here!\",\n)\n\n@sio_app.on(\n    \"rubs\",\n    model=BellyRubModel,\n    summary=\"Channel for belly rubs\",\n    description=\"Send your belly rubs through here!\",\n)\nasync def handle_rub(sid, data):\n    await purr_channel.emit(\n        PurrModel(loudness=2, detail=\"Purr for all listeners\")\n    )\n    return \"Ack to the one who rubbed\"\n```\n\n\ud83d\udc49 [Check out the example AsyncAPI documentation output!](https://studio.asyncapi.com/?url=https://raw.githubusercontent.com/marianhlavac/fastapi-sio/master/examples/from_readme_asyncapi.json)\n\nBy default (you can change these values):\n - the Socket.io endpoint path is **`/sio/socket.io`** (the `socket.io` part is set automatically by some clients)\n - The AsyncAPI spec file is at **`/sio/docs/asyncapi.json`**\n\nFind more in the [examples](/docs/examples.md).\n\n## Documentation & Reference\n\nRefer to the [/docs](./docs/index.md) directory to learn how to use this library in your project.\n\n_TODO: This documentation will be hosted on Github Pages in the near future, hopefully._\n\n\n## Contribution\n\n...\n\n## Used by\n\n<a href=\"https://dronetag.cz\"><img src=\"https://dronetag.cz/assets/logo-full.svg\" height=\"32\" /></a>\n\n[Feel free to open a PR](https://github.com/marianhlavac/fastapi-sio/pulls) to add your project or company to this list.",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Socket.io for FastAPI with AsyncAPI documentation",
    "version": "0.4.0",
    "project_urls": null,
    "split_keywords": [
        "fastapi",
        "socket.io",
        "asyncapi"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d8f75019657458934bc4f464ba91a8261e90a9ccbdfca97222e10c39125bcdc2",
                "md5": "165dff7209536d0b73e39dce2092c1bc",
                "sha256": "30a76093c5cd300ae4a078455d86d2de7ba2c34acd95a1517609a9d203c608f3"
            },
            "downloads": -1,
            "filename": "fastapi_sio-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "165dff7209536d0b73e39dce2092c1bc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 11514,
            "upload_time": "2023-12-29T13:03:20",
            "upload_time_iso_8601": "2023-12-29T13:03:20.240989Z",
            "url": "https://files.pythonhosted.org/packages/d8/f7/5019657458934bc4f464ba91a8261e90a9ccbdfca97222e10c39125bcdc2/fastapi_sio-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b0a1d476a0b172e1718d3e946528ac51291e27cdeba17fc359c6b3e8365111c3",
                "md5": "40fa38002958aa4ada7e11bda9f59328",
                "sha256": "e244ce28b760ca0a34947c2c0dfd5c28bbb67c63d5501f4826283c75706c352e"
            },
            "downloads": -1,
            "filename": "fastapi_sio-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "40fa38002958aa4ada7e11bda9f59328",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 10949,
            "upload_time": "2023-12-29T13:03:22",
            "upload_time_iso_8601": "2023-12-29T13:03:22.189743Z",
            "url": "https://files.pythonhosted.org/packages/b0/a1/d476a0b172e1718d3e946528ac51291e27cdeba17fc359c6b3e8365111c3/fastapi_sio-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-29 13:03:22",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "fastapi-sio"
}
        
Elapsed time: 0.15944s