Skip to content

Fl1yd/Quotes

Repository files navigation


Quotes API: Quote Image Generator

What is this?

Quotes API is a FastAPI-based service that allows users to generate visually appealing quote images resembling Telegram messages

Installing

Before installing Quotes API, ensure you have Poetry installed. 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 install

Rendering 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 chromium

Note: --with-deps uses apt and needs root, so it is meant for Debian/Ubuntu hosts. On other systems install the Chromium dependencies manually and run poetry run playwright install chromium

Docker

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-api

Usage

To use Quotes API, start the FastAPI application:

poetry run python3 -m app

On 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

API Endpoints

Quotes API provides the following endpoint for generating quote images:

  • Generate quote image: Use the POST /generate endpoint to generate a quote image. You need to provide a Messages object with the required data
{
    "messages": [
        {
            "text": "This is a quote",
            "author": {
                "id": 1,
                "name": "Author Name"
            }
        }
    ],
    "quote_color": "#000000",
    "text_color": "white"
}

Configuration

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

License

Quotes API is licensed under the MIT License

About

✨ Service for generating quote images using Jinja2 templates

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors