Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/interactions-py/restful
An extension library for interactions.py allowing runtime API structures.
https://github.com/interactions-py/restful
api api-rest discord fastapi interactions python
Last synced: 3 months ago
JSON representation
An extension library for interactions.py allowing runtime API structures.
- Host: GitHub
- URL: https://github.com/interactions-py/restful
- Owner: interactions-py
- License: gpl-3.0
- Created: 2022-07-29T15:56:44.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-11T05:52:11.000Z (over 1 year ago)
- Last Synced: 2024-04-13T21:56:40.273Z (9 months ago)
- Topics: api, api-rest, discord, fastapi, interactions, python
- Language: Python
- Homepage:
- Size: 99.6 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# interactions restful
A library for interactions.py allowing runtime API structures
## Installation
Using pip:
`pip install interactions-restful`Using poetry:
`poetry add interactions-restful`Don't forget to specify backend you want to use:
- [FastAPI](https://fastapi.tiangolo.com/): `pip install interactions-restful[fastapi]`
- [Quart](https://pgjones.gitlab.io/quart/index.html): `pip install interactions-restful[quart]`Also make sure to install an ASGI server:
- [Uvicorn](https://www.uvicorn.org/): `pip install interactions-restful[uvicorn]`
- [Hypercorn](https://pgjones.gitlab.io/hypercorn/): `pip install interactions-restful[hypercorn]`
- [Daphne](https://github.com/django/daphne): `pip install interactions-restful[daphne]`You can also install both your backend and ASGI server at once, for example
`pip install interactions-restful[fastapi,uvicorn]`## Simple (FastAPI) example
### Main file
- `main.py````python
import interactions
from fastapi import FastAPI
from interactions_restful.backends.fastapi import FastAPIHandlerapp = FastAPI()
client = interactions.Client(token="token")
FastAPIHandler(client, app)client.load_extension("api")
```### Extension file
- `api.py````python
import interactions
from interactions_restful import routeclass MyAPI(interactions.Extension):
@route("GET", "/")
def index(self):
return {"status": "Hello, i.py"}@interactions.slash_command()
async def test_command(self, ctx):
await ctx.send("Hello, API")
```### Run
```bash
uvicorn main:app --reload
```## Backends
Currently, the library support only Quart and FastAPI as a backend for building an API, but if you don't want to use them you can create own backend.