Usage¶
This guide will walk you through how to use the Quotes API to generate customizable quote images
Starting the API¶
To start using the Quotes API, ensure that you have followed the Installation Guide and have the FastAPI server running. Once the server is up and running, you can interact with the API using the following endpoint:
Endpoint:
/generateMethod:
POSTDescription: Generates a quote image based on the provided input
Example POST Request¶
Here is an example of a POST request to generate a quote image:
curl -X POST "http://127.0.0.1:1337/generate" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{
"text": "This is a sample quote",
"author": {
"id": 1,
"name": "John Doe"
}
}
]
}'
Request Structure¶
In the body of the POST request, you need to provide a JSON object with the following fields:
{
"messages": [
{
"text": "This is a quote",
"author": {
"id": 1,
"name": "Author Name",
"avatar": "optional base64 image",
"rank": "optional rank",
"via_bot": "optional bot name"
},
"reply": {
"id": 2,
"name": "Optional Reply Name",
"text": "Optional reply text"
},
"media": "optional base64 image"
}
],
"quote_color": "#000000",
"text_color": "white"
}
Field Definitions¶
The following table describes the fields that you can include in the POST request based on the models:
Field |
Type |
Description |
|---|---|---|
messages |
List of Quote |
Required. A list of |
text_color |
String |
Optional. Text color for the quote. If not provided, the default value from the configuration will be used |
quote_color |
String |
Optional. Background color for the quote. If not provided, the default value from the configuration will be used |
Quote fields¶
The Quote object contains the following fields:
Field |
Type |
Description |
|---|---|---|
text |
String |
Optional. The main quote text for the message. If not provided, the message will only display the media or reply if they exist |
media |
String (Base64) |
Optional. Base64-encoded image attached to the quote (e.g., for sharing images or pictures in the quote) |
entities |
List of Entity |
Optional. List of formatting entities applied to the text, such as bold, italic, underline, and others |
author |
Author |
Required. Object representing the |
reply |
Reply |
Optional. Object representing the reply to the message |
Entity fields¶
The Entity object represents formatting applied to portions of the text (bold, italic, underline, etc.) and contains the following fields:
offset |
Integer |
Required. The position in the text where the formatting starts |
|---|---|---|
length |
Integer |
Required. The number of characters that the formatting applies to |
type |
String (Literal) |
Required. The type of formatting applied to the text |