{"id":14979105,"url":"https://github.com/lonode/fastwapi","last_synced_at":"2025-10-29T05:45:14.514Z","repository":{"id":175537549,"uuid":"654047702","full_name":"lonode/FastWAPI","owner":"lonode","description":"FastWAPI is a simple lightweight Websocket framework based on Starlette, which provide easy-to-use Python decorator to parse JSON incoming message.","archived":false,"fork":false,"pushed_at":"2023-06-15T11:34:58.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-14T04:08:38.739Z","etag":null,"topics":["api","fastapi","json","pydantic","starlette","websocket"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lonode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-15T09:25:39.000Z","updated_at":"2023-06-15T11:43:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"cfbf621e-23c3-4031-8275-8f4a40716097","html_url":"https://github.com/lonode/FastWAPI","commit_stats":{"total_commits":8,"total_committers":2,"mean_commits":4.0,"dds":0.5,"last_synced_commit":"051825dafab7edd1229699db46a9e11e11ce2036"},"previous_names":["lonode/wapi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lonode%2FFastWAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lonode%2FFastWAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lonode%2FFastWAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lonode%2FFastWAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lonode","download_url":"https://codeload.github.com/lonode/FastWAPI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241717711,"owners_count":20008434,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","fastapi","json","pydantic","starlette","websocket"],"created_at":"2024-09-24T13:59:14.050Z","updated_at":"2025-10-29T05:45:09.479Z","avatar_url":"https://github.com/lonode.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Description\r\n\r\nFastWAPI is a simple lightweight Websocket framework based on Starlette, which provide easy-to-use Python decorator to parse JSON incoming message.  \r\n\r\nIt's in the same spirit as _FastAPI_, where each decorator map to an HTTP path. But here, each decorator map to a Pydantic object, and each object map to a function. \r\n\r\n# Installation\r\n\r\n`pip install fastwapi`\r\n# Disclaimer\r\n\r\n - The module is available, but far from finished \u0026 polished, please do not use it in production.\r\n\r\n# Roadmap \r\n\r\n- Add authent middleware\r\n- Add background job to asynchrounosly send JSON to the client\r\n\r\n# Usage \r\n\r\nSee example/main.py for complete code.\r\n\r\nGetting started in three steps :\r\n\r\n#### Instanciates the framework and declare the Websocket HTTP endpoint.  \r\n\r\n```python\r\nimport uvicorn\r\nfrom fastwapi import FastWAPI, WebSocket\r\nfrom pydantic import BaseModel\r\n\r\napp = FastWAPI(endpoint=\"/ws\")\r\n\r\n```\r\n\r\n#### Define Pyndantic model, for incoming and outgoing messages.\r\n\r\n```python\r\nclass CM(BaseModel):\r\n    counter: int\r\n\r\nclass SD(BaseModel):\r\n    name: str\r\n```\r\n\r\n#### Map each Pydantic model to your function.\r\n\r\n```python\r\n@app.parse(CM)\r\nasync def parse_CM(websocket: WebSocket, data: CM):\r\n    print(\"RECEIVED CM : \", data)\r\n    await websocket.send_json(data.dict())\r\n\r\n@app.parse(SD)\r\nasync def parse_SD(websocket: WebSocket, data: CM):\r\n    print(\"RECEIVED SD : \", data)\r\n    await websocket.send_json(data.dict())\r\n```\r\n\r\n## Launch your app\r\n\r\nEither through command line \"uvicorn main:app\" or directly inside the python file :\r\n\r\n```python\r\nif __name__ == \"__main__\":\r\n    uvicorn.run(\"main:app\", port=5000, log_level=\"info\")\r\n```\r\n\r\nTo test your app, you need a websocket client. You can use Postman, or [wscat](https://github.com/websockets/wscat) :\r\n\r\n![wscat demo](https://github.com/lonode/FastWAPI/assets/32384862/ebc1f354-b673-48e7-b85e-881a343e35a2)\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flonode%2Ffastwapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flonode%2Ffastwapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flonode%2Ffastwapi/lists"}