-
Notifications
You must be signed in to change notification settings - Fork 0
Api Reference
- Retrieve All Session IDs
- Retrieve Draft HTML
- Save Draft HTML Content
- Create a New Session
- Edit Session
- Process Draft
- Tag Entry Description
- Correct String
- Add Character to Database
- Add Tag to Database
- Get Entries for Session
- Update Entry Field
- Delete Entry
Method: POST
URL: /get_sessions
This endpoint retrieves all session IDs from the database, providing a list of available sessions.
This endpoint does not require any path, query, or body parameters.
-
Status Code:
200
- Successfully retrieved a list of session IDs.-
Response Body:
{ "sessions": [ {"id": 1}, {"id": 2} ] }
-
Response Body:
-
Status Code:
500
- Internal Server Error due to database querying issues.
Method: POST
URL: /get_html
This endpoint retrieves the draft HTML content for a specified session ID.
-
session_id
(string, required): The session ID for which to retrieve draft HTML.
-
Status Code:
200
- Successfully retrieved the draft HTML.-
Response Body:
{ "success": True, "html_content": "<p>Sample HTML content</p>" }
-
Response Body:
-
Status Code:
400
- Missingsession_id
in the request. -
Status Code:
404
- Session not found. -
Status Code:
500
- Internal Server Error due to unexpected errors.
Method: POST
URL: /save_draft
Save draft HTML content associated with a specific session ID.
-
html
(string, required): The HTML content to save. -
session_id
(string, required): The session ID associated with the draft.
-
Status Code:
202
- HTML content successfully saved.-
Response Body:
{ "success": True, "html_content": "<p>Sample HTML content</p>" }
-
Response Body:
-
Status Code:
400
- Missinghtml
orsession_id
. -
Status Code:
500
- Database error when trying to save.
Method: POST
URL: /new_session
Create a new session by providing a unique session ID in yyyymmdd
format.
-
session_id
(string, required): The session ID to create.
-
Status Code:
201
- Session successfully created.-
Response Body:
{ "success": True, "content": "20230101" }
-
Response Body:
-
Status Code:
400
- Improper session ID format or session ID already exists. -
Status Code:
400
- Invalid length for the session ID.
Method: GET
URL: /edit_session/<session_id>
Retrieve session details to edit based on session ID. Renders appropriate HTML based on session state.
-
session_id
(string): The session ID to retrieve and edit.
-
Status Code:
200
- Renders the draft or edit session HTML page.- Response: HTML content.
-
Status Code:
400
- Record not found.
Method: POST
URL: /process_draft
Processes and saves draft content by checking and inserting locations and entries into the database.
-
session_id
(string, required): The session ID to associate with the draft. -
html
(string, required): The draft content to process.
-
Status Code:
201
- Successfully processed and stored draft content.-
Response Body:
{ "success": True, "session": "20230101" }
-
Response Body:
-
Status Code:
400
- Missing or incorrect parameters. -
Status Code:
500
- Processing error or unknown AI error.
Method: PATCH
URL: /tool/ai/tag_description/<entry_id>
Adds AI-generated tags to a specific entry's description.
-
entry_id
(string): The unique identifier for the entry.
-
Status Code:
200
- Successfully tagged the entry description.-
Response Body:
{ "success": True }
-
Response Body:
-
Status Code:
400
- No entry found with the provided ID. -
Status Code:
500
- AI processing error.
Method: POST
URL: /tool/ai/correct_string
Corrects and validates a given string through AI processing.
-
string
(string, required): The string to be corrected.
-
Status Code:
200
- Successfully corrected the string.-
Response Body:
{ "success": True, "content": "Corrected string content" }
-
Response Body:
-
Status Code:
400
- No string provided for correction. -
Status Code:
500
- Error during string correction.
Method: POST
URL: /db/add_character
Adds a fictional character entry to the database with relevant details.
-
name
(string, required): Character's name. -
classe
(string, optional): Character's class. -
type
(string, optional): Character's type. -
tag
(string, required): Tag identifier in format@JournalEntry[foundry_name]{alias}
.
-
Status Code:
200
- Successfully added character to the database.-
Response Body:
{ "success": True, "id": "character_uuid", "name": "Character Name", "classe": "", "char_type": "", "tag": "Tag", "tag_id": "tag_uuid" }
-
Response Body:
-
Status Code:
400
- Missing or invalid tag format or name. -
Status Code:
500
- Database error during insertion.
Method: POST
URL: /db/add_tag
Add a new tag to the database, ensuring it adheres to the required format and uniqueness.
-
tag
(string, required): The tag to be added. -
tag_type
(string, required): The type of tag being added.
-
Status Code:
200
- Tag successfully created and stored in the database.-
Response Body:
{ "id": "tag_uuid", "tag": "@JournalEntry[Example]{Alias}", "tag_type": "character" }
-
Response Body:
-
Status Code:
400
- Tag format is invalid or the tag already exists. -
Status Code:
400
- Missing tag or tag type.
Method: GET
URL: /get_entries/<int:session_id>
Retrieve session entries, including locations and associated data, for a specified session ID.
-
session_id
(integer): The session ID to retrieve entries for.
-
Status Code:
200
- Successfully retrieved session entries.-
Response Body:
{ "session_id": 12345678, "session_title": "Session Title", "locations": { "1": { "location_name": "Location Name", "entries": [ { "entry_id": "entry_uuid", "entry_index": 0, "entry_title": "Entry Title", "entry_description": "Description of the entry", "entry_tagged": "Tagged description" } ] } } }
-
Response Body:
-
Status Code:
500
- Internal Server Error due to database querying issues. -
Status Code:
404
- The specified session ID does not exist.
Method: POST
URL: /db/update_entry/<field>/
Updates a specific field of an entry in the database.
-
field
(string): The name of the field to update.
-
new_value
(string, required): The new value to assign to the field. -
entry_id
(string, required): The unique identifier for the entry to update.
-
Status Code:
200
- Entry field successfully updated.-
Response Body:
{ "success": True, "content": "Updated value", "field": "field_name" }
-
Response Body:
-
Status Code:
500
- Internal Server Error during the update operation.
Method: DELETE
URL: /db/delete_entry/<entry_id>
Deletes an entry from the database using the specified entry ID.
-
entry_id
(string): The unique identifier for the entry to be deleted.
-
Status Code:
200
- Entry successfully deleted.-
Response Body:
{ "success": True }
-
Response Body:
-
Status Code:
400
- Deletion failed, possibly due to the entry not existing.-
Response Body:
{ "success": False, "error": "Deletion failed" }
-
Response Body: