Skip to main content

Socket.io for FastAPI with AsyncAPI documentation

Project description

fastapi-sio

FastAPI library Socket.io Uses AsyncAPI Current state

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

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

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!

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.

Documentation & Reference

Refer to the /docs 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

Feel free to open a PR to add your project or company to this list.

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

fastapi_sio-0.6.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

fastapi_sio-0.6.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_sio-0.6.0.tar.gz.

File metadata

  • Download URL: fastapi_sio-0.6.0.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Darwin/23.5.0

File hashes

Hashes for fastapi_sio-0.6.0.tar.gz
Algorithm Hash digest
SHA256 7218dabdc953d0646cd25ae9db579d80016975d0831fc99e8e245ae796c32cd7
MD5 63c7fbd399e697457dad92125734c8ea
BLAKE2b-256 ed987cf50980096ac79269cc5217ae7ea7224738c7108e1cad2236f08b78600e

See more details on using hashes here.

File details

Details for the file fastapi_sio-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: fastapi_sio-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Darwin/23.5.0

File hashes

Hashes for fastapi_sio-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f97c32da12f32aa9de177503ff2b79fa720174d6c30ab52bdbff379892b4ed5
MD5 bb3e4fa810be39a300472a0da7621f06
BLAKE2b-256 3203fa19ed82216c566b356b3db8798108fd713d8eb066c1b820b43e4361fa92

See more details on using hashes here.

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