openapi: 3.1.0 info: title: Api version: 0.1.0 description: Novel Writer API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: books description: Book operations - name: sections description: Section operations - name: writing description: Writing assistance - name: export description: Export operations paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /books: get: operationId: listBooks tags: [books] summary: List all books responses: "200": description: List of books content: application/json: schema: type: array items: $ref: "#/components/schemas/Book" post: operationId: createBook tags: [books] summary: Create a new book requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateBook" responses: "201": description: Book created content: application/json: schema: $ref: "#/components/schemas/Book" /books/{bookId}: get: operationId: getBook tags: [books] summary: Get a book by ID parameters: - name: bookId in: path required: true schema: type: integer responses: "200": description: Book details content: application/json: schema: $ref: "#/components/schemas/Book" patch: operationId: updateBook tags: [books] summary: Update a book parameters: - name: bookId in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateBook" responses: "200": description: Book updated content: application/json: schema: $ref: "#/components/schemas/Book" delete: operationId: deleteBook tags: [books] summary: Delete a book parameters: - name: bookId in: path required: true schema: type: integer responses: "204": description: Deleted /books/{bookId}/sections: get: operationId: listSections tags: [sections] summary: List all sections of a book parameters: - name: bookId in: path required: true schema: type: integer responses: "200": description: List of sections content: application/json: schema: type: array items: $ref: "#/components/schemas/Section" post: operationId: createSection tags: [sections] summary: Create a new section parameters: - name: bookId in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateSection" responses: "201": description: Section created content: application/json: schema: $ref: "#/components/schemas/Section" /books/{bookId}/sections/{sectionId}: get: operationId: getSection tags: [sections] summary: Get a section by ID parameters: - name: bookId in: path required: true schema: type: integer - name: sectionId in: path required: true schema: type: integer responses: "200": description: Section details content: application/json: schema: $ref: "#/components/schemas/Section" patch: operationId: updateSection tags: [sections] summary: Update a section parameters: - name: bookId in: path required: true schema: type: integer - name: sectionId in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateSection" responses: "200": description: Section updated content: application/json: schema: $ref: "#/components/schemas/Section" delete: operationId: deleteSection tags: [sections] summary: Delete a section parameters: - name: bookId in: path required: true schema: type: integer - name: sectionId in: path required: true schema: type: integer responses: "204": description: Deleted /books/{bookId}/sections/reorder: post: operationId: reorderSections tags: [sections] summary: Reorder sections parameters: - name: bookId in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ReorderSections" responses: "200": description: Sections reordered content: application/json: schema: type: array items: $ref: "#/components/schemas/Section" /books/{bookId}/stats: get: operationId: getBookStats tags: [books] summary: Get book statistics parameters: - name: bookId in: path required: true schema: type: integer responses: "200": description: Book statistics content: application/json: schema: $ref: "#/components/schemas/BookStats" /books/{bookId}/daily-goal: patch: operationId: setDailyGoal tags: [books] summary: Set daily word goal for a book parameters: - name: bookId in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: type: object properties: dailyWordGoal: type: integer required: - dailyWordGoal responses: "200": description: Updated book content: application/json: schema: $ref: "#/components/schemas/Book" /writing/synonyms: post: operationId: getSynonyms tags: [writing] summary: Get synonyms for a word requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SynonymRequest" responses: "200": description: Synonyms content: application/json: schema: $ref: "#/components/schemas/SynonymResponse" /writing/style: post: operationId: getStyleSuggestions tags: [writing] summary: Get style improvement suggestions for text requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/StyleRequest" responses: "200": description: Style suggestions content: application/json: schema: $ref: "#/components/schemas/StyleResponse" /writing/characters: post: operationId: getCharacters tags: [writing] summary: Extract character names from text requestBody: required: true content: application/json: schema: type: object properties: text: type: string required: - text responses: "200": description: Extracted characters content: application/json: schema: $ref: "#/components/schemas/CharactersResponse" /books/{bookId}/export: post: operationId: exportBook tags: [export] summary: Export book as DOCX parameters: - name: bookId in: path required: true schema: type: integer requestBody: required: false content: application/json: schema: $ref: "#/components/schemas/ExportOptions" responses: "200": description: DOCX file content: application/octet-stream: schema: type: string format: binary /books/{bookId}/export-templates: get: operationId: listExportTemplates tags: [export] summary: List export templates for a book parameters: - name: bookId in: path required: true schema: type: integer responses: "200": description: List of templates content: application/json: schema: type: array items: $ref: "#/components/schemas/ExportTemplate" post: operationId: createExportTemplate tags: [export] summary: Create an export template parameters: - name: bookId in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateExportTemplate" responses: "201": description: Template created content: application/json: schema: $ref: "#/components/schemas/ExportTemplate" /books/{bookId}/export-templates/{templateId}: patch: operationId: updateExportTemplate tags: [export] summary: Update an export template parameters: - name: bookId in: path required: true schema: type: integer - name: templateId in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateExportTemplate" responses: "200": description: Template updated content: application/json: schema: $ref: "#/components/schemas/ExportTemplate" delete: operationId: deleteExportTemplate tags: [export] summary: Delete an export template parameters: - name: bookId in: path required: true schema: type: integer - name: templateId in: path required: true schema: type: integer responses: "204": description: Deleted components: schemas: HealthStatus: type: object properties: status: type: string required: - status Book: type: object properties: id: type: integer title: type: string author: type: string description: type: string dailyWordGoal: type: integer createdAt: type: string format: date-time updatedAt: type: string format: date-time required: - id - title - author - dailyWordGoal - createdAt - updatedAt CreateBook: type: object properties: title: type: string author: type: string description: type: string required: - title - author UpdateBook: type: object properties: title: type: string author: type: string description: type: string Section: type: object properties: id: type: integer bookId: type: integer title: type: string content: type: string type: type: string enum: [chapter, foreword, epilogue, prologue, afterword, preface, introduction, appendix, interlude] sortOrder: type: integer wordCount: type: integer createdAt: type: string format: date-time updatedAt: type: string format: date-time required: - id - bookId - title - content - type - sortOrder - wordCount - createdAt - updatedAt CreateSection: type: object properties: title: type: string content: type: string type: type: string enum: [chapter, foreword, epilogue, prologue, afterword, preface, introduction, appendix, interlude] sortOrder: type: integer required: - title - type UpdateSection: type: object properties: title: type: string content: type: string type: type: string enum: [chapter, foreword, epilogue, prologue, afterword, preface, introduction, appendix, interlude] ReorderSections: type: object properties: sectionIds: type: array items: type: integer required: - sectionIds BookStats: type: object properties: totalWords: type: integer totalSections: type: integer totalChapters: type: integer dailyWordGoal: type: integer wordsWrittenToday: type: integer sectionStats: type: array items: $ref: "#/components/schemas/SectionStat" required: - totalWords - totalSections - totalChapters - dailyWordGoal - wordsWrittenToday - sectionStats SectionStat: type: object properties: sectionId: type: integer title: type: string type: type: string wordCount: type: integer required: - sectionId - title - type - wordCount SynonymRequest: type: object properties: word: type: string required: - word SynonymResponse: type: object properties: word: type: string synonyms: type: array items: type: string required: - word - synonyms StyleRequest: type: object properties: text: type: string required: - text StyleResponse: type: object properties: original: type: string suggestions: type: array items: $ref: "#/components/schemas/StyleSuggestion" required: - original - suggestions StyleSuggestion: type: object properties: improved: type: string explanation: type: string required: - improved - explanation CharactersResponse: type: object properties: characters: type: array items: $ref: "#/components/schemas/CharacterInfo" required: - characters CharacterInfo: type: object properties: name: type: string mentions: type: integer firstAppearance: type: string required: - name - mentions - firstAppearance ExportOptions: type: object properties: templateId: type: integer includeToc: type: boolean default: true ExportTemplate: type: object properties: id: type: integer bookId: type: integer name: type: string chapterFormat: type: string description: "Format for chapter headings. Substitutions: {{chapter_number}}, {{chapter_title}}, {{section_title}}" nonChapterFormat: type: string description: "Format for non-chapter headings. Substitutions: {{section_title}}, {{section_type}}" titlePageFormat: type: string description: "Format for title page. Substitutions: {{book_title}}, {{author}}, {{description}}, {{date}}" pageBreakBetweenSections: type: boolean fontSize: type: integer fontFamily: type: string createdAt: type: string format: date-time updatedAt: type: string format: date-time required: - id - bookId - name - chapterFormat - nonChapterFormat - titlePageFormat - pageBreakBetweenSections - fontSize - fontFamily - createdAt - updatedAt CreateExportTemplate: type: object properties: name: type: string chapterFormat: type: string nonChapterFormat: type: string titlePageFormat: type: string pageBreakBetweenSections: type: boolean default: true fontSize: type: integer default: 12 fontFamily: type: string default: "Times New Roman" required: - name - chapterFormat - nonChapterFormat UpdateExportTemplate: type: object properties: name: type: string chapterFormat: type: string nonChapterFormat: type: string titlePageFormat: type: string pageBreakBetweenSections: type: boolean fontSize: type: integer fontFamily: type: string