This document provides a comprehensive list of all API endpoints available in Lute v3, including their methods, parameters, and functionality.
- Description: Main index page showing available books and languages
- Parameters:
- None
- Response: HTML template with book and language listings
- Data Exposed: Books, languages, backup settings, tutorial information
- Description: Marks all book stats as stale to trigger recalculation
- Parameters: None
- Response: Redirect to main page
- Data Used: All books (non-archived)
- Description: Deletes all data if in demo mode
- Parameters: None
- Response: Flash message and redirect to main page
- Data Affected: All tables (when demo flag is set)
- Description: Removes the demo flag to deactivate demo mode
- Parameters: None
- Response: Flash message and redirect to main page
- Data Affected: Demo flag in database
- Description: Shows application version information
- Parameters: None
- Response: HTML template with version, data path, and database info
- Data Exposed: App version, data path, database filename, Docker status
- Description: JSON endpoint for version and data information
- Parameters: None
- Response: JSON object with version, data path, and database info
- Data Exposed: App version, data path, database
- Description: Serves JavaScript files with no caching headers
- Parameters:
filename- path to the JS file - Response: JS file with no-cache headers
- Data Used: JavaScript files in static/js directory
- Description: DataTables JSON response for active books
- Parameters: DataTables parameters in POST request
- Response: JSON with book data for DataTables
- Data Exposed: All active books with metadata
- Description: Archived books listing page
- Parameters: None
- Response: HTML template with archived book listing
- Data Exposed: Language choices, current language ID
- Description: DataTables JSON response for archived books
- Parameters: DataTables parameters in POST request
- Response: JSON with archived book data for DataTables
- Data Exposed: All archived books with metadata
- Description: Create new book page
- Parameters:
importurl(optional) - URL to import from
- Response: HTML form for creating a new book
- Data Exposed: Available languages, book tags
- Description: Create new book
- Parameters: Book data from form submission
- Response: Redirect to reading page
- Data Used: Book parameters (title, text, language, etc.)
- Description: Edit book page
- Parameters:
bookid- ID of the book to edit - Response: HTML form for editing a book
- Data Exposed: Book details, available languages, book tags
- Description: Update book
- Parameters:
bookid- ID of the book to update - Response: Flash message and redirect to main page
- Data Used: Updated book parameters from form
- Description: Page for importing a webpage
- Parameters: None
- Response: HTML template for webpage import
- Data Used: None
- Description: Archive a book
- Parameters:
bookid- ID of the book to archive - Response: Redirect to main page
- Data Used: Book to be archived
- Description: Unarchive a book
- Parameters:
bookid- ID of the book to unarchive - Response: Redirect to main page
- Data Used: Book to be unarchived
- Description: Delete a book
- Parameters:
bookid- ID of the book to delete - Response: Redirect to main page
- Data Used: Book to be deleted
- Description: Get statistics for a book via JSON
- Parameters:
bookid- ID of the book - Response: JSON with book statistics
- Data Exposed: Book statistics (distinct terms, unknowns, percent, status distribution)
- Description: List all languages with book and term counts
- Parameters: None
- Response: HTML template with language data
- Data Exposed: Languages with associated book and term counts
- Description: Edit language page
- Parameters:
langid- ID of the language to edit - Response: HTML form for editing a language
- Data Exposed: Language details, available parsers
- Description: Update language
- Parameters:
langid- ID of the language to update - Response: Flash message and redirect to main page
- Data Used: Updated language parameters from form
- Description: Create new language page
- Parameters: None
- Response: HTML form for creating a new language
- Data Exposed: Available predefined languages, available parsers
- Description: Create new language
- Parameters: None
- Response: Flash message and redirect to main page
- Data Used: Language parameters from form
- Description: Create new language from predefined template
- Parameters:
langname- Name of the predefined language - Response: HTML form with predefined language settings
- Data Exposed: Predefined language template
- Description: Create new language from predefined template
- Parameters:
langname- Name of the predefined language - Response: Flash message and redirect to main page
- Data Used: Predefined language settings and form data
- Description: Delete a language
- Parameters:
langid- ID of the language to delete - Response: Redirect to language index
- Data Used: Language to be deleted
- Description: List predefined languages not already in database
- Parameters: None
- Response: HTML template with predefined languages
- Data Exposed: Predefined languages not currently in the system
- Description: Load a predefined language with sample stories
- Parameters:
langname- Name of the predefined language to load - Response: Flash message and redirect to main page
- Data Used: Predefined language definition
- Description: Term management index page
- Parameters: None
- Response: HTML template with term management interface
- Data Exposed: Available languages, statuses, term tags
- Description: Term management index page with initial search
- Parameters:
search- Initial search term - Response: HTML template with term management interface
- Data Exposed: Available languages, statuses, term tags
- Description: DataTables JSON response for terms
- Parameters: DataTables parameters in POST request, filter parameters
- Response: JSON with term data for DataTables
- Data Exposed: Terms with filtering options
- Description: Bulk edit terms from index page
- Parameters: Various parameters from bulk edit form
- Response: Redirect to term index
- Data Used: Term IDs and update parameters
- Description: Bulk edit terms from reading pane
- Parameters: Various parameters from bulk edit form
- Response: HTML template for updated term
- Data Used: Term IDs and update parameters
- Description: Ajax term update from index page
- Parameters: JSON with term_id, update_type, and values
- Response: JSON with updated status or error
- Data Used: Term ID and update parameters
- Description: Export terms to CSV file
- Parameters: DataTables parameters in POST request, filter parameters
- Response: CSV file attachment
- Data Exposed: Term data in CSV format
- Description: Edit term page
- Parameters:
termid- ID of the term to edit - Response: HTML form for editing a term
- Data Exposed: Term details and available languages
- Description: Update term
- Parameters:
termid- ID of the term to update - Response: Redirect to term index
- Data Used: Updated term parameters from form
- Description: Edit term by language and text
- Parameters:
langid- Language IDtext- Text content of the term
- Response: HTML form for editing/creating a term
- Data Exposed: Term details and language dictionaries
- Description: Create or update term by language and text
- Parameters:
langid- Language IDtext- Text content of the term
- Response: Redirect to term index
- Data Used: Form data for term creation/update
- Description: Create new term page
- Parameters: None
- Response: HTML form for creating a new term
- Data Exposed: Available languages and dictionaries
- Description: Create new term
- Parameters: None
- Response: Redirect to term new page
- Data Used: Term parameters from form
- Description: Search for terms by text in a specific language
- Parameters:
text- Text to search forlangid- Language ID to search in
- Response: JSON with matching terms
- Data Exposed: Terms matching the text in the specified language
- Description: Get sentences for a term
- Parameters:
langid- Language IDtext- Term text
- Response: HTML template with sentence references
- Data Exposed: Sentences containing the term and its parents/children
- Description: Bulk update term statuses
- Parameters: JSON with update information
- Response: JSON confirmation
- Data Used: Term IDs and new status values
- Description: Bulk delete terms
- Parameters: JSON with word IDs to delete
- Response: JSON confirmation
- Data Used: Term IDs for deletion
- Description: Delete a term
- Parameters:
termid- ID of the term to delete - Response: Redirect to term index
- Data Used: Term to be deleted
- Description: Read a book starting at current/last reading position (defaults to page 1)
- Parameters:
bookid- ID of the book to read - Response: Full HTML template for reading interface
- Data Exposed: Full page structure with metadata (title, page count, audio settings), navigation elements, and language settings
- Note: The
<div id="thetext">placeholder is empty. Use/read/start_reading/...to get actual text content
- Description: Get full HTML page structure for a specific book page (for metadata extraction)
- Parameters:
bookid- ID of the bookpagenum- Page number to read
- Response: Full HTML template for reading interface
- Data Exposed: Full page structure with metadata (title, page count, audio settings), navigation elements, and language settings
- Note: The
<div id="thetext">placeholder is empty. Use/read/start_reading/...to get actual text content. This endpoint is used to extract page metadata like title, page count, and audio information.
- Description: Peek at a page without tracking as read
- Parameters:
bookid- ID of the bookpagenum- Page number to peek at
- Response: HTML template for reading interface
- Data Exposed: Book page content, language settings
- Description: Start reading a page (set start date and return actual parsed text content)
- Parameters:
bookid- ID of the bookpagenum- Page number to start reading
- Response: HTML fragment containing the parsed page text with word status classes (not a full HTML page)
- Data Used: Page start date tracking
- Usage: Used for page navigation (next/previous) to track reading. Returns the actual text content that should be loaded into the
<div id="thetext">element from the full page structure.
- Description: Refresh page content without changing start date
- Parameters:
bookid- ID of the bookpagenum- Page number to refresh
- Response: HTML template with parsed page content
- Data Exposed: Page content without updating start date
- Usage: Used for page navigation when not tracking (e.g., peeking)
- Description: Mark page as read
- Parameters: JSON with bookid, pagenum, and restknown
- Response: JSON confirmation
- Data Used: Book page completion data
- restknown:
- If
false: Mark page as read only (callmarkPageRead) - If
true: Mark page as read AND set all unknown words (status 0) on the page to Well-Known (status 99) (callmarkPageKnown)
- If
- Description: Delete a page from a book
- Parameters:
bookid- ID of the bookpagenum- Page number to delete
- Response: Redirect to the same page (after deletion)
- Data Used: Book and page
- Description: Create a new page in a book
- Parameters:
bookid- ID of the bookposition- Position to insert page ("before" or "after")pagenum- Reference page number
- Response: HTML form for creating page or redirect after creation
- Description: Create a new page in a book
- Parameters:
bookid- ID of the bookposition- Position to insert page ("before" or "after")pagenum- Reference page number
- Response: Redirect to reading page after creation
- Data Used: New page text from form
- Description: Save audio player position and bookmarks
- Parameters: JSON with bookid, position, and bookmarks
- Response: JSON confirmation
- Data Used: Audio playback data
- Description: Start reading a page (set start date and render content)
- Parameters:
bookid- ID of the bookpagenum- Page number to start reading
- Response: HTML template with parsed page content
- Data Used: Page start date tracking
- Description: Refresh page content without changing start date
- Parameters:
bookid- ID of the bookpagenum- Page number to refresh
- Response: HTML template with parsed page content
- Data Exposed: Page content without updating start date
- Description: Return an empty page
- Parameters: None
- Response: Empty string
- Data Used: None
- Description: Create term form for reading interface
- Parameters:
langid- Language IDtext- Term text (may contain "LUTESLASH" to represent "/")
- Response: HTML term form
- Data Exposed: Term details, language dictionaries
- Description: Submit term form for reading interface
- Parameters:
langid- Language IDtext- Term text (may contain "LUTESLASH" to represent "/")
- Response: HTML template with updated term
- Data Used: Term form data
- Description: Edit term form in reading interface
- Parameters:
term_id- ID of the term to edit - Response: HTML term form
- Data Exposed: Term details, language dictionaries
- Description: Submit term edit in reading interface
- Parameters:
term_id- ID of the term to edit - Response: HTML template with updated term
- Data Used: Term form data
- Description: Show bulk term edit form in reading interface
- Parameters: None
- Response: HTML bulk edit form
- Data Exposed: Available term tags
- Description: Get term popup HTML for a specific term
- Parameters:
termid- ID of the term - Response: HTML template with term information
- Data Exposed: Term details, parent/children, sentences
- Description: Show flash notification for copied text
- Parameters: None
- Response: HTML template for flash notification
- Description: Edit text of a page
- Parameters:
bookid- ID of the bookpagenum- Page number to edit
- Response: HTML form for editing page text
- Data Exposed: Page content
- Description: Update text of a page
- Parameters:
bookid- ID of the bookpagenum- Page number to update
- Response: Redirect to reading page
- Data Used: Updated page text from form
- Description: Edit user settings page
- Parameters: None
- Response: HTML form for user settings
- Data Exposed: Current user settings
- Description: Update user settings
- Parameters: None
- Response: Flash message and redirect to main page
- Data Used: Settings form data
- Description: Test MeCab parser with provided path
- Parameters:
mecab_path- Path to MeCab executable - Response: JSON result of test
- Data Used: MeCab path for testing
- Description: Set a specific user setting key to value
- Parameters:
key- Setting keyvalue- Setting value
- Response: JSON confirmation
- Data Used: Setting key-value pair
- Description: Edit keyboard shortcuts
- Parameters: None
- Response: HTML form for editing shortcuts
- Data Exposed: Current shortcut settings
- Description: Update keyboard shortcuts
- Parameters: None
- Response: Flash message and redirect to main page
- Data Used: Shortcut form data
- Description: List available backups
- Parameters: None
- Response: HTML template with backup listing
- Data Exposed: Available backup files
- Description: Download a backup file
- Parameters:
filename- Name of the backup file - Response: File download
- Data Exposed: Backup file
- Description: Backup creation page
- Parameters:
type(optional) - Type of backup ("manual") - Response: HTML template for backup creation
- Data Exposed: Backup folder path
- Description: Create backup
- Parameters: Form data with backup type
- Response: JSON with backup filename or error
- Data Used: Backup settings and database
- Description: Skip current backup and update settings
- Parameters: None
- Response: Redirect to main page
- Data Used: Backup settings
- Description: Get current theme CSS
- Parameters: None
- Response: CSS content for current theme
- Data Exposed: Current theme CSS
- Description: Get custom user styles
- Parameters: None
- Response: CSS content for custom styles
- Data Exposed: Custom styles from user settings
- Description: Cycle to next theme
- Parameters: None
- Response: JSON confirmation
- Data Used: Theme settings
- Description: Toggle text highlighting
- Parameters: None
- Response: JSON confirmation
- Data Used: Highlight setting
- Description: Statistics main page
- Parameters: None
- Response: HTML template with statistics
- Data Exposed: Reading statistics table data
- Description: Statistics chart data
- Parameters: None
- Response: JSON with chart data
- Data Exposed: Reading statistics chart data
- Description: DataTables JSON response for bookmarks
- Parameters:
bookid- ID of the book- DataTables parameters in POST request
- Response: JSON with bookmark data for DataTables
- Data Exposed: Bookmarks for the specified book
- Description: List all bookmarks for a book
- Parameters:
bookid- ID of the book - Response: HTML template with bookmark listing
- Data Exposed: Bookmarks for the specified book
- Description: Add a new bookmark
- Parameters: JSON with book_id, page_num, and title
- Response: JSON confirmation
- Data Used: Bookmark information
- Description: Delete a bookmark
- Parameters: JSON with bookmark_id
- Response: JSON confirmation
- Data Used: Bookmark to be deleted
- Description: Edit a bookmark
- Parameters: JSON with bookmark_id and new_title
- Response: JSON confirmation
- Data Used: Bookmark to be updated
- Description: Term tag management index page
- Parameters: None
- Response: HTML template with term tag management interface
- Data Exposed: Available term tags
- Description: Term tag management index page with initial search
- Parameters:
search- Initial search term - Response: HTML template with term tag management interface
- Data Exposed: Available term tags
- Description: DataTables JSON response for term tags
- Parameters: DataTables parameters in POST request
- Response: JSON with term tag data for DataTables
- Data Exposed: Term tags
- Description: Edit term tag page
- Parameters:
termtagid- ID of the term tag to edit - Response: HTML form for editing a term tag
- Data Exposed: Term tag details
- Description: Update term tag
- Parameters:
termtagid- ID of the term tag to update - Response: Redirect to term tag index
- Data Used: Updated term tag parameters from form
- Description: Create new term tag page
- Parameters: None
- Response: HTML form for creating a new term tag
- Data Used: None
- Description: Create new term tag
- Parameters: None
- Response: Redirect to term tag index
- Data Used: Term tag parameters from form
- Description: Delete a term tag
- Parameters:
termtagid- ID of the term tag to delete - Response: Redirect to term tag index
- Data Used: Term tag to be deleted
- Description: Term import page
- Parameters: None
- Response: HTML form for importing terms
- Data Used: None
- Description: Process term import file
- Parameters: Form data with file and import options
- Response: Flash message and redirect to term index
- Data Used: Term import file and options
- Description: List Anki export configurations
- Parameters: None
- Response: HTML template with export configurations
- Data Exposed: Export specifications
- Description: Edit Anki export specification
- Parameters:
spec_id- ID of the export spec to edit - Response: HTML form for editing export spec
- Data Exposed: Export specification details
- Description: Update Anki export specification
- Parameters:
spec_id- ID of the export spec to update - Response: Redirect to export index
- Data Used: Updated export specification from form
- Description: Create new Anki export specification
- Parameters: None
- Response: HTML form for creating new export spec
- Data Used: None
- Description: Create new Anki export specification
- Parameters: None
- Response: Redirect to export index
- Data Used: Export specification from form
- Description: Delete Anki export specification
- Parameters:
spec_id- ID of the export spec to delete - Response: Flash message and redirect to export index
- Data Used: Export specification to be deleted
- Description: Get data for Anki Connect post request
- Parameters: JSON with term IDs, sentences, and settings
- Response: JSON with Anki Connect post data
- Data Used: Term IDs, sentence data, and export specifications
- Description: Validate export specifications
- Parameters: JSON with deck names and note types
- Response: JSON validation results or error
- Data Used: Export specifications
- Description: Serve user image files
- Parameters:
lgid- Language IDf- Path to the image file
- Response: Image file
- Data Exposed: User image files
- Description: Stream audio file for a book
- Parameters:
bookid- ID of the book - Response: Audio file stream
- Data Exposed: Audio file from the specified book
- Description: Load initial image search page
- Parameters:
langid- Language IDtext- Text to search forsearchstring- Search string pattern
- Response: HTML template with search interface
- Data Exposed: Search URL for AJAX calls
- Description: Perform Bing image search
- Parameters:
langid- Language IDtext- Text to search forsearchstring- Search string pattern
- Response: JSON with image search results
- Data Exposed: Bing image search results
- Description: Save image from Bing search
- Parameters: Form data with src, text, and langid
- Response: JSON with saved image URL and filename
- Data Used: Image source URL
- Description: Save manually uploaded image
- Parameters: Form data with text, langid, and image file
- Response: JSON with saved image URL and filename
- Data Used: Uploaded image file
- Description: CLI command to print a greeting
- Parameters: None
- Response: Greeting message
- Data Used: None
- Description: CLI command to export terms from a language
- Parameters:
language- Name of the languageoutput_path- Output file path
- Response: Export file with term frequencies
- Data Exposed: Terms in the specified language
- Description: CLI command to export terms from a book
- Parameters:
bookid- ID of the bookoutput_path- Output file path
- Response: Export file with term frequencies
- Data Exposed: Terms in the specified book
- Description: CLI command to import books from CSV
- Parameters:
file- Path to the CSV file--commit- Flag to commit changes--tags- Comma-separated tags to apply--language- Default language for books
- Response: Import results
- Data Used: CSV file with book data
- Description: Wipe the entire database
- Parameters: None
- Response: Flash message and redirect to main page
- Data Used: All database tables (deletion)
- Description: Load demo data after wiping
- Parameters: None
- Response: Flash message and redirect to main page
- Data Used: Demo data
- Description: Load demo languages with dummy dictionaries
- Parameters: None
- Response: Redirect to main page
- Data Used: Demo language definitions
- Description: Load demo stories only
- Parameters: None
- Response: Flash message and redirect to main page
- Data Used: Demo stories
- Description: Get IDs of all languages
- Parameters: None
- Response: JSON with language names and IDs
- Data Exposed: Language IDs
- Description: Delete all terms only
- Parameters: None
- Response: Flash message and redirect to main page
- Data Used: All terms (deletion)
- Description: Execute SQL and return results as JSON
- Parameters:
sql- SQL query string - Response: JSON with SQL results
- Data Exposed: Results of SQL query
- Description: Execute arbitrary SQL (with no validation)
- Parameters:
sql- SQL command string - Response: JSON confirmation
- Data Used: SQL command execution
- Description: Fake language dictionary lookup
- Parameters:
langname- Language nameterm- Term to look up
- Response: Dummy dictionary content
- Data Used: None (dummy response)
- Description: Hack to rename parser in registry
- Parameters:
parsername- Parser to renamerenameto- New name for parser
- Response: JSON with parser information
- Data Exposed: Parser information
- Description: Disable backup feature
- Parameters: None
- Response: Flash message and redirect to main page
- Data Used: Backup settings
- Description: Throw an error to test error handling
- Parameters:
message- Error message - Response: RuntimeError with specified message
- Data Used: None (just raises error)
- Description: Return a fake story for testing
- Parameters: None
- Response: HTML content of a fake story
- Data Used: None
- Description: Get content of a temporary file
- Parameters:
filename- Name of the temp file - Response: Content of the temporary file
- Data Exposed: Temporary file content
IMPORTANT: Reading Flow Update
When opening a book, the app now uses a two-step process:
- Call
/read/{bookid}(without page number) → Gets CURRENT page from server + metadata - Extract
page_numvalue from HTML response - Call
/read/start_reading/{bookid}/{pagenum}with extracted page → Gets actual text content
This ensures the app always opens the book at the server's current reading position, even if the user has been reading on another device or the browser.
Lute v3 uses regular expressions in multiple places throughout its codebase, particularly in parsing and text processing functionality. This document identifies all endpoints and components that either currently use regex or would require regex to properly extract information.
-
Current regex usage:
re.findall(r"(<img .*?>)", content, re.I)- Finds all img tags in Bing search resultsre.search(r'src=\"(.*?)\"', normalized_source)- Extracts src attribute from img tagsre.search(r'src=\"(.*?)\"', normalized_source)- Used to extract image URLs from HTML
-
Why regex is needed: The endpoint returns HTML content that needs to be parsed to extract image URLs. The Bing search results contain various HTML elements that need to be processed to extract the relevant information.
Several endpoints rely on parsing functionality that uses regex, particularly:
/read/<int:bookid>/page/<int:pagenum>- When reading pages, the text is parsed which uses language-specific regex/term/sentences/<int:langid>/<text>- Sentence extraction uses parsing that may involve regex/read/start_reading/<int:bookid>/<int:pagenum>- Page content is parsed using language-specific parsing
Current regex usage in parsing:
- Language character substitution patterns:
´='|='|’='|‘='|...=…|..=‥` - Sentence splitting patterns:
.!? - Word character patterns:
a-zA-ZÀ-ÖØ-öø-ȳáéíóúÁÉÍÓÚñÑand language-specific ranges
- File:
lute/models/language.py - Regex: Used to convert old PHP regex patterns to Python:
- Converting
\\x{XXXX}to\\uXXXXpatterns - Example:
x{0600}-x{06FF}x{FE70}-x{FEFC}becomesu0600-u06FFuFE70-uFEFC
- Converting
- File:
lute/parse/base.py(base parsing functionality) - Usage: Tokenization of text based on language-specific patterns
- Regex: Word character patterns for different languages
- File:
lute/models/term.py - Regex: Used when processing text to remove special characters:
zws = "\\u200B"(zero-width space) - though not exactly regex, it's string processingnbsp = "\\u00A0"(non-breaking space)
- While these endpoints return structured data, if you need to extract specific patterns from the statistics, regex could be useful
- The HTML response from
/stats/might require regex if parsing for specific patterns
- When processing the DataTables response, you might need regex to:
- Extract specific term patterns
- Process tag lists
- Parse complex term data for display
Many endpoints return HTML templates. If you need to extract specific data from these HTML responses, you would use regex:
/read/<int:bookid>- extract term data from reading interface/term/form- extract term details from forms/language/new- extract available language options
´='|='|’='|‘='|...=…|..=‥` (in Language.character_substitutions)
- Default:
.!? - Can be customized per language
- Default:
a-zA-ZÀ-ÖØ-öø-ȳáéíóúÁÉÍÓÚñÑ - Language-specific patterns using unicode ranges like
\\u0600-\\u06FF
def _get_python_regex_pattern(self, s):
def convert_match(match):
# Convert backslash-x{XXXX} to backslash-uXXXX
hex_value = match.group(1)
return f"\\\\u{hex_value}"
ret = re.sub(r"\\\\x{([0-9A-Fa-f]+)}", convert_match, s)
return retWhile many endpoints return structured JSON or HTML, Lute v3 uses regex extensively in its core functionality, particularly in:
- Text parsing and tokenization
- HTML content extraction (especially for Bing image search)
- Language-specific character processing
- Database data cleanup and processing
If you're consuming Lute's API from an external application, you'll likely need regex to:
- Parse HTML responses to extract specific elements
- Process the raw HTML from Bing search results
- Handle language-specific text processing
- Extract specific patterns from textual data