Skip to content

Instantly share code, notes, and snippets.

@9Dave9
Created November 21, 2025 14:58
Show Gist options
  • Select an option

  • Save 9Dave9/2c92b0622c5ce34aa88d4f83a7b2ffd7 to your computer and use it in GitHub Desktop.

Select an option

Save 9Dave9/2c92b0622c5ce34aa88d4f83a7b2ffd7 to your computer and use it in GitHub Desktop.
openAPI-gradio.json
{
"openapi": "3.1.0",
"info": {
"title": "Gradio PaddleOCR Text Extraction API",
"description": "\n# PaddleOCR Text Extraction API\n\nA comprehensive web application for extracting text from images using PaddleOCR with AI-powered text cleanup.\n\n## Features\n\n* **Single Image Processing**: Extract text from individual images with column-based reading order\n* **Batch Processing**: Process entire folders of images in parallel\n* **AI-Powered Cleanup**: Automatic text correction using Ollama (dolphin3 model)\n* **Debug Tools**: Detailed OCR process visualization and analysis\n* **Playlists**: AI-powered image collections based on OCR text content\n* **Database Persistence**: MySQL integration for storing OCR results\n\n## Supported Image Formats\n\nJPG, JPEG, PNG, BMP, TIFF, TIF, WEBP\n\n## Main Interface\n\nThis API serves a Gradio web interface at the root path (`/`) with the following tabs:\n- **Single Image**: Upload and process individual images\n- **Batch Processing**: Manage batch OCR operations on folders\n- **Debug OCR Process**: Detailed extraction analysis and visualization\n- **Playlists**: Create and manage AI-powered image playlists\n\n## API Endpoints\n\n### Data Retrieval Endpoints\n\n* **GET /api/ocr-results** - Retrieve OCR results with pagination\n - Returns detected text, AI-cleaned text, and processing metadata\n - Supports filtering with limit and offset parameters\n - Includes processing status and error messages\n - **NEW: Processing time** - seconds taken to process each image\n \n* **GET /api/batches** - Retrieve batch processing records with pagination\n - Returns batch details including folder path and batch name\n - **NEW ENDPOINT**: Track batch processing progress\n - Includes processed and unprocessed image counts\n - Individual image processing times available via `/api/ocr-results`\n \n* **GET /api/batch/live** - Get currently processing batch\n - **NEW ENDPOINT**: Returns the UID of the batch currently being processed\n - Returns null if no batch is actively processing\n - Useful for monitoring active operations\n \n* **GET /api/batch/{uid}** - Get specific batch by UID\n - **NEW ENDPOINT**: Retrieve a single batch record by its unique identifier\n - Returns detailed batch information including statistics\n - Returns not found response if batch doesn't exist\n \n* **GET /api/playlists** - Retrieve playlists with pagination\n - Returns complete playlist details including image paths\n - Includes keywords and ideas/themes used for creation\n - Processing time data - timeseries showing image processing duration\n\n### Gradio API Endpoints\n\nAll Gradio functions are automatically exposed as API endpoints. You can:\n- Access interactive documentation at `/docs` (Swagger UI)\n- View alternative documentation at `/redoc` (ReDoc)\n- See Gradio-specific API docs by clicking \"Use via API\" in the web interface\n\n## Getting Started\n\n1. Navigate to the root path to access the web interface\n2. Use the \"Single Image\" tab to test OCR on a single image\n3. Use the \"Batch Processing\" tab for processing multiple images\n4. Access the API documentation at `/docs` for programmatic access\n ",
"contact": {
"name": "Gradio PaddleOCR App",
"url": "https://github.com/9Dave9/gradio-paddle-ocr-app"
},
"license": {
"name": "MIT",
"url": "https://opensource.org/licenses/MIT"
},
"version": "1.0.0"
},
"paths": {
"/api/ocr-results": {
"get": {
"tags": [
"ocr"
],
"summary": "Get OCR results",
"description": "Retrieve OCR results from the database with pagination support.\n \n **Features:**\n - Pagination with limit and offset\n - Returns detected text, AI-cleaned text, and processing metadata\n - Includes processing status and error messages\n - Links to batch folders via selected_directory_uid\n \n **Response includes:**\n - List of OCR results with full details\n - Total number of results available\n - Pagination parameters used\n \n **Example usage:**\n ```\n GET /api/ocr-results?limit=50&offset=0\n ```",
"operationId": "get_ocr_results_api_ocr_results_get",
"parameters": [
{
"name": "limit",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"maximum": 1000,
"minimum": 1,
"description": "Maximum number of results to return",
"default": 100,
"title": "Limit"
},
"description": "Maximum number of results to return"
},
{
"name": "offset",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"minimum": 0,
"description": "Number of results to skip",
"default": 0,
"title": "Offset"
},
"description": "Number of results to skip"
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OCRResultsResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/api/playlists": {
"get": {
"tags": [
"playlists"
],
"summary": "Get playlists",
"description": "Retrieve playlists from the database with pagination support.\n \n **Features:**\n - Pagination with limit and offset\n - Returns complete playlist details including image paths\n - Includes keywords and ideas/themes used for creation\n - **NEW: Processing time data** - timeseries data showing how long each image took to process\n \n **Processing Time Data Structure:**\n Each playlist includes `processing_time_data` as a list of objects:\n ```json\n [\n {\"image_path\": \"/path/to/image1.jpg\", \"seconds\": 5},\n {\"image_path\": \"/path/to/image2.jpg\", \"seconds\": 3}\n ]\n ```\n \n **Response includes:**\n - List of playlists with full details\n - Total number of playlists available\n - Pagination parameters used\n \n **Example usage:**\n ```\n GET /api/playlists?limit=20&offset=0\n ```",
"operationId": "get_playlists_api_playlists_get",
"parameters": [
{
"name": "limit",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"maximum": 1000,
"minimum": 1,
"description": "Maximum number of playlists to return",
"default": 100,
"title": "Limit"
},
"description": "Maximum number of playlists to return"
},
{
"name": "offset",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"minimum": 0,
"description": "Number of playlists to skip",
"default": 0,
"title": "Offset"
},
"description": "Number of playlists to skip"
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PlaylistsResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/api/batches": {
"get": {
"tags": [
"batches"
],
"summary": "Get batch processing records",
"description": "Retrieve batch processing records from the database with pagination support.\n \n **Features:**\n - Pagination with limit and offset\n - Returns batch details including folder path and batch name\n - Includes processed and unprocessed image counts\n - Includes creation timestamp\n \n **Batch Information:**\n Each batch record contains:\n - `uid`: Unique identifier for the batch\n - `folder_path`: Directory path containing images\n - `batch_name`: User-provided name for the batch\n - `created_at`: When the batch was first created\n - `unprocessed_images`: Number of images left to process\n - `processed_images`: Number of images already processed\n \n **Note:** Processing time for individual images is stored in the `ocr_results` table\n and can be accessed via the `/api/ocr-results` endpoint.\n \n **Response includes:**\n - List of batch records with full details\n - Total number of batches available\n - Pagination parameters used\n \n **Example usage:**\n ```\n GET /api/batches?limit=50&offset=0\n ```",
"operationId": "get_batches_api_batches_get",
"parameters": [
{
"name": "limit",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"maximum": 1000,
"minimum": 1,
"description": "Maximum number of batches to return",
"default": 100,
"title": "Limit"
},
"description": "Maximum number of batches to return"
},
{
"name": "offset",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"minimum": 0,
"description": "Number of batches to skip",
"default": 0,
"title": "Offset"
},
"description": "Number of batches to skip"
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/BatchesResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/api/batch/live": {
"get": {
"tags": [
"batches"
],
"summary": "Get currently processing batch",
"description": "Get the UID of the batch that is currently being processed.\n \n **Features:**\n - Returns the batch UID if a batch is currently being processed\n - Returns null if no batch is currently processing\n - Useful for monitoring active batch processing operations\n \n **Response includes:**\n - `processing`: Boolean indicating if a batch is currently being processed\n - `batch_uid`: UID of the batch being processed (null if none)\n - `message`: Human-readable status message\n \n **Example usage:**\n ```\n GET /api/batch/live\n ```\n \n **Sample Response (processing):**\n ```json\n {\n \"processing\": true,\n \"batch_uid\": 5,\n \"message\": \"Batch 5 is currently being processed\"\n }\n ```\n \n **Sample Response (idle):**\n ```json\n {\n \"processing\": false,\n \"batch_uid\": null,\n \"message\": \"No batch is currently being processed\"\n }\n ```",
"operationId": "get_live_batch_api_batch_live_get",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/LiveBatchResponse"
}
}
}
}
}
}
},
"/api/batch/{uid}": {
"get": {
"tags": [
"batches"
],
"summary": "Get specific batch by UID",
"description": "Retrieve a specific batch record by its unique identifier (UID).\n \n **Features:**\n - Returns detailed information for a specific batch\n - Includes all batch metadata and statistics\n - Returns 404-style response if batch not found\n \n **Path Parameters:**\n - `uid`: The unique identifier of the batch to retrieve\n \n **Response includes:**\n - `batch`: The batch record with all details (null if not found)\n - `found`: Boolean indicating if the batch was found\n \n **Example usage:**\n ```\n GET /api/batch/1\n ```\n \n **Sample Response (found):**\n ```json\n {\n \"batch\": {\n \"uid\": 1,\n \"folder_path\": \"/path/to/images\",\n \"batch_name\": \"Invoice Batch 1\",\n \"created_at\": \"2024-01-01 12:00:00\",\n \"unprocessed_images\": 5,\n \"processed_images\": 15\n },\n \"found\": true\n }\n ```\n \n **Sample Response (not found):**\n ```json\n {\n \"batch\": null,\n \"found\": false\n }\n ```",
"operationId": "get_batch_by_uid_api_batch__uid__get",
"parameters": [
{
"name": "uid",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"title": "Uid"
}
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SingleBatchResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
},
"put": {
"tags": [
"batches"
],
"summary": "Update a batch",
"description": "Update an existing batch record.\n \n **Features:**\n - Update batch name and/or folder path\n - Partial updates supported (provide only fields to update)\n - Validates folder path if provided\n \n **Path Parameters:**\n - `uid`: The unique identifier of the batch to update\n \n **Request Body:**\n - `batch_name`: Optional. New batch name\n - `folder_path`: Optional. New folder path\n \n **Response:**\n - `success`: Boolean indicating if update was successful\n - `message`: Human-readable message\n - `id`: UID of the updated batch\n \n **Example Request:**\n ```json\n {\n \"batch_name\": \"Updated Batch Name\"\n }\n ```\n \n **Example Response:**\n ```json\n {\n \"success\": true,\n \"message\": \"Batch updated successfully\",\n \"id\": 5\n }\n ```",
"operationId": "update_batch_api_batch__uid__put",
"parameters": [
{
"name": "uid",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"title": "Uid"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UpdateBatchRequest"
}
}
}
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateUpdateResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
},
"delete": {
"tags": [
"batches"
],
"summary": "Delete a batch",
"description": "Delete a batch from the database.\n \n **Features:**\n - Deletes batch record\n - Related OCR results have their batch reference set to NULL (not deleted)\n - Cannot be undone\n \n **Path Parameters:**\n - `uid`: The unique identifier of the batch to delete\n \n **Response:**\n - `success`: Boolean indicating if deletion was successful\n - `message`: Human-readable message\n \n **Example Response:**\n ```json\n {\n \"success\": true,\n \"message\": \"Batch deleted successfully\"\n }\n ```\n \n **Note:** This operation cannot be undone. OCR results remain in the database\n but will no longer be associated with this batch.",
"operationId": "delete_batch_api_batch__uid__delete",
"parameters": [
{
"name": "uid",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"title": "Uid"
}
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DeleteResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/api/batch": {
"post": {
"tags": [
"batches"
],
"summary": "Create a new batch",
"description": "Create a new batch processing record.\n \n **Features:**\n - Creates a new batch with folder path and optional name\n - Validates folder path exists\n - Returns the created batch UID\n \n **Request Body:**\n - `folder_path`: Required. Absolute path to folder containing images\n - `batch_name`: Optional. User-friendly name for the batch\n \n **Response:**\n - `success`: Boolean indicating if creation was successful\n - `message`: Human-readable message\n - `id`: UID of the created batch (null if failed)\n \n **Example Request:**\n ```json\n {\n \"folder_path\": \"/path/to/images\",\n \"batch_name\": \"Invoice Batch Q1\"\n }\n ```\n \n **Example Response:**\n ```json\n {\n \"success\": true,\n \"message\": \"Batch created successfully\",\n \"id\": 5\n }\n ```",
"operationId": "create_batch_api_batch_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateBatchRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateUpdateResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/api/batch/{uid}/stop": {
"post": {
"tags": [
"batches"
],
"summary": "Stop currently processing batch",
"description": "Stop the currently processing batch if it matches the provided UID.\n \n **Features:**\n - Stops batch processing for the specified batch\n - Only works if the batch is currently being processed\n - Safe to call even if batch is not processing\n \n **Path Parameters:**\n - `uid`: The unique identifier of the batch to stop\n \n **Response:**\n - `success`: Boolean indicating if stop was successful\n - `message`: Human-readable message explaining the result\n - `id`: UID of the batch\n \n **Example Response (success):**\n ```json\n {\n \"success\": true,\n \"message\": \"Batch processing stopped\",\n \"id\": 5\n }\n ```\n \n **Example Response (not processing):**\n ```json\n {\n \"success\": false,\n \"message\": \"Batch 5 is not currently being processed\",\n \"id\": 5\n }\n ```\n \n **Note:** This endpoint sets a flag to stop processing. The actual stop\n may take a few seconds as the current image finishes processing.",
"operationId": "stop_batch_api_batch__uid__stop_post",
"parameters": [
{
"name": "uid",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"title": "Uid"
}
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateUpdateResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/api/playlist": {
"post": {
"tags": [
"playlists"
],
"summary": "Create a new playlist",
"description": "Create a new playlist with images.\n \n **Features:**\n - Creates a playlist with specified images\n - Optional keywords and themes\n - Optional user association\n \n **Request Body:**\n - `playlist_name`: Required. Name of the playlist\n - `image_paths`: Required. List of image paths to include\n - `keywords`: Optional. Keywords associated with the playlist\n - `ideas_themes`: Optional. Ideas or themes for the playlist\n - `user`: Optional. User who created the playlist\n \n **Response:**\n - `success`: Boolean indicating if creation was successful\n - `message`: Human-readable message\n - `id`: ID of the created playlist (null if failed)\n \n **Example Request:**\n ```json\n {\n \"playlist_name\": \"Financial Documents Q1\",\n \"image_paths\": [\"/path/to/img1.jpg\", \"/path/to/img2.jpg\"],\n \"keywords\": \"invoice receipt\",\n \"ideas_themes\": \"Financial documents\"\n }\n ```\n \n **Example Response:**\n ```json\n {\n \"success\": true,\n \"message\": \"Playlist created successfully\",\n \"id\": 10\n }\n ```",
"operationId": "create_playlist_api_playlist_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreatePlaylistRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateUpdateResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/api/playlist/{id}": {
"put": {
"tags": [
"playlists"
],
"summary": "Update a playlist",
"description": "Update an existing playlist.\n \n **Features:**\n - Update playlist name, images, keywords, or themes\n - Partial updates supported (provide only fields to update)\n - Cannot update processing_time_data (read-only)\n \n **Path Parameters:**\n - `id`: The unique identifier of the playlist to update\n \n **Request Body:**\n - `playlist_name`: Optional. New playlist name\n - `image_paths`: Optional. New list of image paths\n - `keywords`: Optional. New keywords\n - `ideas_themes`: Optional. New ideas/themes\n \n **Response:**\n - `success`: Boolean indicating if update was successful\n - `message`: Human-readable message\n - `id`: ID of the updated playlist\n \n **Example Request:**\n ```json\n {\n \"playlist_name\": \"Updated Playlist Name\",\n \"keywords\": \"new keywords\"\n }\n ```\n \n **Example Response:**\n ```json\n {\n \"success\": true,\n \"message\": \"Playlist updated successfully\",\n \"id\": 10\n }\n ```",
"operationId": "update_playlist_api_playlist__id__put",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"title": "Id"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UpdatePlaylistRequest"
}
}
}
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateUpdateResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
},
"delete": {
"tags": [
"playlists"
],
"summary": "Delete a playlist",
"description": "Delete a playlist from the database.\n \n **Features:**\n - Deletes playlist record\n - Does not delete the actual images\n - Cannot be undone\n \n **Path Parameters:**\n - `id`: The unique identifier of the playlist to delete\n \n **Response:**\n - `success`: Boolean indicating if deletion was successful\n - `message`: Human-readable message\n \n **Example Response:**\n ```json\n {\n \"success\": true,\n \"message\": \"Playlist deleted successfully\"\n }\n ```\n \n **Note:** This operation cannot be undone. Only the playlist record is deleted,\n not the actual image files.",
"operationId": "delete_playlist_api_playlist__id__delete",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"title": "Id"
}
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DeleteResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/api/playlist/live": {
"get": {
"tags": [
"playlists"
],
"summary": "Get currently processing playlist",
"description": "Get the ID of the playlist that is currently being processed.\n \n **Features:**\n - Returns the playlist ID if a playlist is currently being processed\n - Returns null if no playlist is currently processing\n - Useful for monitoring active playlist processing operations\n \n **Response includes:**\n - `processing`: Boolean indicating if a playlist is currently being processed\n - `playlist_id`: ID of the playlist being processed (null if none)\n - `message`: Human-readable status message\n \n **Example usage:**\n ```\n GET /api/playlist/live\n ```\n \n **Sample Response (processing):**\n ```json\n {\n \"processing\": true,\n \"playlist_id\": 10,\n \"message\": \"Playlist 10 is currently being processed\"\n }\n ```\n \n **Sample Response (idle):**\n ```json\n {\n \"processing\": false,\n \"playlist_id\": null,\n \"message\": \"No playlist is currently being processed\"\n }\n ```",
"operationId": "get_live_playlist_api_playlist_live_get",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/LivePlaylistResponse"
}
}
}
}
}
}
},
"/api/playlist/{id}/start": {
"post": {
"tags": [
"playlists"
],
"summary": "Start processing a playlist",
"description": "Start or resume processing images in a playlist.\n \n **Features:**\n - Starts processing the images in the specified playlist\n - Re-processes all images in the playlist with OCR\n - Updates the database with new OCR results\n \n **Path Parameters:**\n - `id`: The unique identifier of the playlist to start processing\n \n **Response:**\n - `success`: Boolean indicating if start was successful\n - `message`: Human-readable message explaining the result\n - `id`: ID of the playlist\n \n **Example Response (success):**\n ```json\n {\n \"success\": true,\n \"message\": \"Playlist processing started\",\n \"id\": 10\n }\n ```\n \n **Example Response (already processing):**\n ```json\n {\n \"success\": false,\n \"message\": \"A playlist is already being processed\",\n \"id\": 10\n }\n ```\n \n **Note:** This is an asynchronous operation. Use GET /api/playlist/live \n to monitor the processing status.",
"operationId": "start_playlist_processing_api_playlist__id__start_post",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"title": "Id"
}
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateUpdateResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/api/playlist/{id}/stop": {
"post": {
"tags": [
"playlists"
],
"summary": "Stop currently processing playlist",
"description": "Stop the currently processing playlist if it matches the provided ID.\n \n **Features:**\n - Stops playlist processing for the specified playlist\n - Only works if the playlist is currently being processed\n - Safe to call even if playlist is not processing\n \n **Path Parameters:**\n - `id`: The unique identifier of the playlist to stop\n \n **Response:**\n - `success`: Boolean indicating if stop was successful\n - `message`: Human-readable message explaining the result\n - `id`: ID of the playlist\n \n **Example Response (success):**\n ```json\n {\n \"success\": true,\n \"message\": \"Playlist processing stopped\",\n \"id\": 10\n }\n ```\n \n **Example Response (not processing):**\n ```json\n {\n \"success\": false,\n \"message\": \"Playlist 10 is not currently being processed\",\n \"id\": 10\n }\n ```\n \n **Note:** This endpoint sets a flag to stop processing. The actual stop\n may take a few seconds as the current image finishes processing.",
"operationId": "stop_playlist_processing_api_playlist__id__stop_post",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"title": "Id"
}
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateUpdateResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/api/playlist/{id}/restart": {
"post": {
"tags": [
"playlists"
],
"summary": "Restart playlist processing from beginning",
"description": "Restart playlist processing from the beginning.\n \n **Features:**\n - Stops current processing (if any)\n - Resets processing state\n - Starts processing from the first image\n \n **Path Parameters:**\n - `id`: The unique identifier of the playlist to restart\n \n **Response:**\n - `success`: Boolean indicating if restart was successful\n - `message`: Human-readable message explaining the result\n - `id`: ID of the playlist\n \n **Example Response (success):**\n ```json\n {\n \"success\": true,\n \"message\": \"Playlist processing restarted\",\n \"id\": 10\n }\n ```\n \n **Example Response (not found):**\n ```json\n {\n \"success\": false,\n \"message\": \"Playlist 10 not found\",\n \"id\": 10\n }\n ```\n \n **Note:** This is an asynchronous operation. Use GET /api/playlist/live\n to monitor the processing status.",
"operationId": "restart_playlist_processing_api_playlist__id__restart_post",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"title": "Id"
}
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateUpdateResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/api/batch/{uid}/start": {
"post": {
"tags": [
"batches"
],
"summary": "Start or resume batch processing",
"description": "Start or resume processing images in a batch.\n \n **Features:**\n - Starts processing the images in the specified batch\n - Processes new/unprocessed images with OCR\n - Updates the database with new OCR results\n \n **Path Parameters:**\n - `uid`: The unique identifier of the batch to start processing\n \n **Response:**\n - `success`: Boolean indicating if start was successful\n - `message`: Human-readable message explaining the result\n - `id`: UID of the batch\n \n **Example Response (success):**\n ```json\n {\n \"success\": true,\n \"message\": \"Batch processing started\",\n \"id\": 5\n }\n ```\n \n **Example Response (already processing):**\n ```json\n {\n \"success\": false,\n \"message\": \"A batch is already being processed\",\n \"id\": 5\n }\n ```\n \n **Note:** This is an asynchronous operation. Use GET /api/batch/live\n to monitor the processing status.",
"operationId": "start_batch_processing_api_batch__uid__start_post",
"parameters": [
{
"name": "uid",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"title": "Uid"
}
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateUpdateResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/api/batch/{uid}/restart": {
"post": {
"tags": [
"batches"
],
"summary": "Restart batch processing from beginning",
"description": "Restart batch processing from the beginning.\n \n **Features:**\n - Stops current processing (if any)\n - Resets processing state\n - Starts processing from the first image\n \n **Path Parameters:**\n - `uid`: The unique identifier of the batch to restart\n \n **Response:**\n - `success`: Boolean indicating if restart was successful\n - `message`: Human-readable message explaining the result\n - `id`: UID of the batch\n \n **Example Response (success):**\n ```json\n {\n \"success\": true,\n \"message\": \"Batch processing restarted\",\n \"id\": 5\n }\n ```\n \n **Example Response (not found):**\n ```json\n {\n \"success\": false,\n \"message\": \"Batch 5 not found\",\n \"id\": 5\n }\n ```\n \n **Note:** This is an asynchronous operation. Use GET /api/batch/live\n to monitor the processing status.",
"operationId": "restart_batch_processing_api_batch__uid__restart_post",
"parameters": [
{
"name": "uid",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"title": "Uid"
}
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateUpdateResponse"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Batch": {
"properties": {
"uid": {
"type": "integer",
"title": "Uid"
},
"folder_path": {
"type": "string",
"title": "Folder Path"
},
"batch_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Batch Name"
},
"created_at": {
"type": "string",
"title": "Created At"
},
"unprocessed_images": {
"type": "integer",
"title": "Unprocessed Images",
"default": 0
},
"processed_images": {
"type": "integer",
"title": "Processed Images",
"default": 0
}
},
"type": "object",
"required": [
"uid",
"folder_path",
"created_at"
],
"title": "Batch",
"description": "Batch model"
},
"BatchesResponse": {
"properties": {
"batches": {
"items": {
"$ref": "#/components/schemas/Batch"
},
"type": "array",
"title": "Batches"
},
"total": {
"type": "integer",
"title": "Total"
},
"limit": {
"type": "integer",
"title": "Limit"
},
"offset": {
"type": "integer",
"title": "Offset"
}
},
"type": "object",
"required": [
"batches",
"total",
"limit",
"offset"
],
"title": "BatchesResponse",
"description": "Response model for batches listing"
},
"CreateBatchRequest": {
"properties": {
"folder_path": {
"type": "string",
"title": "Folder Path",
"description": "Absolute path to folder containing images"
},
"batch_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Batch Name",
"description": "Optional name for the batch"
}
},
"type": "object",
"required": [
"folder_path"
],
"title": "CreateBatchRequest",
"description": "Request model for creating a batch"
},
"CreatePlaylistRequest": {
"properties": {
"playlist_name": {
"type": "string",
"title": "Playlist Name",
"description": "Name of the playlist"
},
"image_paths": {
"items": {
"type": "string"
},
"type": "array",
"title": "Image Paths",
"description": "List of image paths"
},
"keywords": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Keywords",
"description": "Keywords for the playlist"
},
"ideas_themes": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Ideas Themes",
"description": "Ideas/themes for the playlist"
},
"user": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "User",
"description": "Associated user"
}
},
"type": "object",
"required": [
"playlist_name",
"image_paths"
],
"title": "CreatePlaylistRequest",
"description": "Request model for creating a playlist"
},
"CreateUpdateResponse": {
"properties": {
"success": {
"type": "boolean",
"title": "Success"
},
"message": {
"type": "string",
"title": "Message"
},
"id": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Id"
}
},
"type": "object",
"required": [
"success",
"message"
],
"title": "CreateUpdateResponse",
"description": "Response model for create/update operations"
},
"DeleteResponse": {
"properties": {
"success": {
"type": "boolean",
"title": "Success"
},
"message": {
"type": "string",
"title": "Message"
}
},
"type": "object",
"required": [
"success",
"message"
],
"title": "DeleteResponse",
"description": "Response model for delete operations"
},
"HTTPValidationError": {
"properties": {
"detail": {
"items": {
"$ref": "#/components/schemas/ValidationError"
},
"type": "array",
"title": "Detail"
}
},
"type": "object",
"title": "HTTPValidationError"
},
"LiveBatchResponse": {
"properties": {
"processing": {
"type": "boolean",
"title": "Processing"
},
"batch_uid": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Batch Uid"
},
"message": {
"type": "string",
"title": "Message"
}
},
"type": "object",
"required": [
"processing",
"message"
],
"title": "LiveBatchResponse",
"description": "Response model for live batch processing status"
},
"LivePlaylistResponse": {
"properties": {
"processing": {
"type": "boolean",
"title": "Processing"
},
"playlist_id": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Playlist Id"
},
"message": {
"type": "string",
"title": "Message"
}
},
"type": "object",
"required": [
"processing",
"message"
],
"title": "LivePlaylistResponse",
"description": "Response model for live playlist processing status"
},
"OCRResult": {
"properties": {
"id": {
"type": "integer",
"title": "Id"
},
"image_path": {
"type": "string",
"title": "Image Path"
},
"detected_text": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Detected Text"
},
"ai_cleaned_text": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Ai Cleaned Text"
},
"processed_at": {
"type": "string",
"title": "Processed At"
},
"status": {
"type": "string",
"title": "Status"
},
"error_message": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Error Message"
},
"selected_directory_uid": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Selected Directory Uid"
},
"processing_time": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Processing Time"
}
},
"type": "object",
"required": [
"id",
"image_path",
"processed_at",
"status"
],
"title": "OCRResult",
"description": "OCR result model"
},
"OCRResultsResponse": {
"properties": {
"results": {
"items": {
"$ref": "#/components/schemas/OCRResult"
},
"type": "array",
"title": "Results"
},
"total": {
"type": "integer",
"title": "Total"
},
"limit": {
"type": "integer",
"title": "Limit"
},
"offset": {
"type": "integer",
"title": "Offset"
}
},
"type": "object",
"required": [
"results",
"total",
"limit",
"offset"
],
"title": "OCRResultsResponse",
"description": "Response model for OCR results listing"
},
"Playlist": {
"properties": {
"id": {
"type": "integer",
"title": "Id"
},
"playlist_name": {
"type": "string",
"title": "Playlist Name"
},
"image_paths": {
"items": {
"type": "string"
},
"type": "array",
"title": "Image Paths"
},
"keywords": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Keywords"
},
"ideas_themes": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Ideas Themes"
},
"user": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "User"
},
"created_at": {
"type": "string",
"title": "Created At"
},
"processing_time_data": {
"anyOf": [
{
"items": {
"$ref": "#/components/schemas/ProcessingTimeEntry"
},
"type": "array"
},
{
"type": "null"
}
],
"title": "Processing Time Data"
}
},
"type": "object",
"required": [
"id",
"playlist_name",
"image_paths",
"created_at"
],
"title": "Playlist",
"description": "Playlist model"
},
"PlaylistsResponse": {
"properties": {
"playlists": {
"items": {
"$ref": "#/components/schemas/Playlist"
},
"type": "array",
"title": "Playlists"
},
"total": {
"type": "integer",
"title": "Total"
},
"limit": {
"type": "integer",
"title": "Limit"
},
"offset": {
"type": "integer",
"title": "Offset"
}
},
"type": "object",
"required": [
"playlists",
"total",
"limit",
"offset"
],
"title": "PlaylistsResponse",
"description": "Response model for playlists listing"
},
"ProcessingTimeEntry": {
"properties": {
"image_path": {
"type": "string",
"title": "Image Path"
},
"seconds": {
"type": "integer",
"title": "Seconds"
}
},
"type": "object",
"required": [
"image_path",
"seconds"
],
"title": "ProcessingTimeEntry",
"description": "Processing time entry for an image"
},
"SingleBatchResponse": {
"properties": {
"batch": {
"anyOf": [
{
"$ref": "#/components/schemas/Batch"
},
{
"type": "null"
}
]
},
"found": {
"type": "boolean",
"title": "Found"
}
},
"type": "object",
"required": [
"found"
],
"title": "SingleBatchResponse",
"description": "Response model for single batch retrieval"
},
"UpdateBatchRequest": {
"properties": {
"batch_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Batch Name",
"description": "New batch name"
},
"folder_path": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Folder Path",
"description": "New folder path"
}
},
"type": "object",
"title": "UpdateBatchRequest",
"description": "Request model for updating a batch"
},
"UpdatePlaylistRequest": {
"properties": {
"playlist_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Playlist Name",
"description": "New playlist name"
},
"image_paths": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"title": "Image Paths",
"description": "New list of image paths"
},
"keywords": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Keywords",
"description": "New keywords"
},
"ideas_themes": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Ideas Themes",
"description": "New ideas/themes"
}
},
"type": "object",
"title": "UpdatePlaylistRequest",
"description": "Request model for updating a playlist"
},
"ValidationError": {
"properties": {
"loc": {
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
},
"type": "array",
"title": "Location"
},
"msg": {
"type": "string",
"title": "Message"
},
"type": {
"type": "string",
"title": "Error Type"
}
},
"type": "object",
"required": [
"loc",
"msg",
"type"
],
"title": "ValidationError"
}
}
},
"tags": [
{
"name": "default",
"description": "Core API endpoints"
},
{
"name": "ocr",
"description": "OCR results and data retrieval endpoints"
},
{
"name": "batches",
"description": "Batch processing management and retrieval endpoints"
},
{
"name": "playlists",
"description": "Playlist management and retrieval endpoints"
},
{
"name": "gradio",
"description": "Gradio web interface and auto-generated API endpoints for OCR functions"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment