A library for interactions.py allowing runtime API structures
Project description
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:
Also make sure to install an ASGI server:
- Uvicorn:
pip install interactions-restful[uvicorn]
- Hypercorn:
pip install interactions-restful[hypercorn]
- 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
import interactions
from fastapi import FastAPI
from interactions_restful.backends.fastapi import FastAPIHandler
app = FastAPI()
client = interactions.Client(token="token")
FastAPIHandler(client, app)
client.load_extension("api")
Extension file
api.py
import interactions
from interactions_restful import route
class 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
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.
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
Built Distribution
File details
Details for the file interactions-restful-2.0.0.tar.gz
.
File metadata
- Download URL: interactions-restful-2.0.0.tar.gz
- Upload date:
- Size: 17.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2dee6048418853ec39594ec371f124cacf59a8a84ccf98f3a2e080e910e0d85a |
|
MD5 | 6d491437cba2b28f97bcccda39d6e04b |
|
BLAKE2b-256 | d4f10134b8e107835b31592a7579f1b5af678d8e0d442fea00732d013d5a013f |
File details
Details for the file interactions_restful-2.0.0-py3-none-any.whl
.
File metadata
- Download URL: interactions_restful-2.0.0-py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2345216763931725f8be81eba8bf5a7f6b8f9e1dd0d10f42947a561d9ff4e7f4 |
|
MD5 | 73741283eb56690153941e63d90f7f04 |
|
BLAKE2b-256 | 3e2dae71cb4d3fa219dacba5f7f3c5d10cc1002f3d2223d0fe6a9ae9c3c834d3 |