Quotes API: Quote Image Generator
Quotes API is a FastAPI-based service that allows users to generate visually appealing quote images resembling Telegram messages
Before installing Quotes API, ensure you have
Poetryinstalled. You can install Poetry by following the Poetry installation guide
Once Poetry is installed, clone the repository and install dependencies:
git clone https://github.com/Fl1yd/Quotes
cd Quotes
poetry installRendering is done with headless Chromium via Playwright. After installing the Python dependencies, install the Chromium browser and its system libraries:
poetry run playwright install --with-deps chromiumNote:
--with-depsusesaptand needs root, so it is meant for Debian/Ubuntu hosts. On other systems install the Chromium dependencies manually and runpoetry run playwright install chromium
The image bundles Chromium and all its dependencies, so no host setup is required:
docker build -t quotes-api .
docker run --rm -p 1337:1337 quotes-apiTo use Quotes API, start the FastAPI application:
poetry run python3 -m appOn startup the app launches a single Chromium instance and keeps it warm for the whole process lifetime, so each request only renders a lightweight page.
The application will start on the port specified in the config.toml file (default is 1337). You can then access the API documentation at http://localhost:1337/docs
Quotes API provides the following endpoint for generating quote images:
- Generate quote image:
Use the
POST /generateendpoint to generate a quote image. You need to provide aMessagesobject with the required data
{
"messages": [
{
"text": "This is a quote",
"author": {
"id": 1,
"name": "Author Name"
}
}
],
"quote_color": "#000000",
"text_color": "white"
}Customize your application settings by updating the config.toml file:
[settings]
[settings.quote]
quality = 85
text_color = "white"
background_color = "#162330"
[settings.logging]
level = "INFO"
[settings.server]
port = 1337