2025-09-20 16:47:41 +03:00
2025-09-20 16:47:41 +03:00
2025-09-20 16:47:41 +03:00
2025-09-20 16:47:41 +03:00
2025-09-20 16:47:41 +03:00
2025-09-13 17:39:17 +03:00
2025-09-20 16:47:41 +03:00
2025-09-20 16:47:41 +03:00
2025-09-13 17:39:17 +03:00
2025-09-13 17:39:17 +03:00
2025-09-13 17:39:17 +03:00
2025-09-13 17:39:17 +03:00
2025-09-13 17:39:17 +03:00
2025-09-13 17:39:17 +03:00
2025-09-13 17:39:17 +03:00
2025-09-20 16:47:41 +03:00
2025-09-20 16:47:41 +03:00
2025-09-13 17:39:17 +03:00
2025-09-20 16:47:41 +03:00
2025-09-20 16:47:41 +03:00
2025-09-13 17:39:17 +03:00
2025-09-20 16:47:41 +03:00
2025-09-20 16:47:41 +03:00

Laravel Logo

Build Status Total Downloads Latest Stable Version License

Open Text Summaries API

Sitemap

  • Endpoint: GET /sitemap.xml
  • Description: Returns an XML sitemap including homepage, static pages (/about, /privacy, /terms, /contact), index pages (/books, /categories), and all book detail pages.
  • How to submit to Google: In Google Search Console, add your property (domain) and submit the sitemap URL, e.g., https://your-domain.com/sitemap.xml

This API lets you ingest Books (with optional Category and Summary) in a create-or-update (upsert) fashion. It is designed so your client can safely resend the same data without creating duplicates.

  • Method and route: POST /api/ingest/books
  • Content-Type: application/json
  • Authentication: none (development default). If you expose this API publicly, add auth/rate limit yourself.
  • Base URL (local):

What the endpoint does

  • Finds or creates Category by slug or name; updates name/description if provided.
  • Finds or creates Book by slug (preferred) or by the (title + author) pair; updates fields if provided.
  • Finds or creates Summary by book_id; updates fields if provided.
  • Processes one or many items in a single request.

Accepted request shapes

  1. Single object (a single book): { "title": "Clean Code", "author": "Robert C. Martin", "description": "A Handbook of Agile Software Craftsmanship", "publication_date": "2008-08-11", "cover_image": "https://example.com/cleancode.jpg", "slug": "clean-code", // optional; auto-slugified from title if missing "category": { // optional "name": "Software Engineering", "slug": "software-engineering", // optional; auto from name if missing "description": "SE books" }, "summary": { // optional "content": "Clean Code explains principles and best practices for writing maintainable code...", "key_insights": "SOLID; meaningful names; small functions" } }

  2. Batch object with books array: { "books": [ { "title": "Clean Code", "author": "Robert C. Martin", "category": {"name": "Software Engineering"} }, { "title": "The Pragmatic Programmer", "author": "Andrew Hunt", "summary": {"content": "..."} } ] }

  3. Raw JSON array (also accepted): [ { "title": "Clean Code", "author": "Robert C. Martin" }, { "title": "Refactoring", "author": "Martin Fowler" } ]

Field reference

  • Book
    • title (string, required)
    • author (string, required if authors not provided)
    • authors (array, optional; preferred. If provided, author may be omitted. The first name is also stored in the legacy author field for backward compatibility.)
    • slug (string, optional; defaults to slugified title)
    • description (string, optional)
    • publication_date (YYYY-MM-DD string, optional)
    • cover_image (string URL, optional)
    • category_id (integer, optional; used if you already know an existing category ID)
    • category (object, optional; see below). If both category and category_id are provided, category takes precedence.
  • Category
    • name (string, recommended if creating)
    • slug (string, optional; defaults to slugified name)
    • description (string, optional)
  • Summary
    • content (string, recommended if creating a summary)
    • key_insights (string, optional)

Upsert rules (idempotency)

  • Category: matched by slug if present; else by name. If found, it is updated with any provided fields. If not found, it is created.
  • Book: matched by slug if present; else by composite (title + author). If found, it is updated with provided fields. If not found, it is created. If category is provided, the book's category_id is set/updated.
  • Summary: matched by book_id (exactly one per book). If found, it is updated; else created.

HTTP status codes

  • 200 OK: Request processed; see per-item statuses in results.
  • 422 Unprocessable Entity: No valid books provided (e.g., empty payload); message explains the reason.

Example cURL (single) curl -X POST "http://127.0.0.1:8000/api/ingest/books"
-H "Content-Type: application/json"
-d '{ "title": "Clean Code", "author": "Robert C. Martin", "description": "A Handbook of Agile Software Craftsmanship", "publication_date": "2008-08-11", "cover_image": "https://example.com/cleancode.jpg", "category": {"name": "Software Engineering", "description": "SE books"}, "summary": {"content": "...", "key_insights": "..."} }'

Example success response (single) { "results": [ { "book": {"status": "created", "id": 12, "slug": "clean-code"}, "category": {"status": "created", "id": 4, "slug": "software-engineering"}, "summary": {"status": "created", "id": 9} } ] }

Example cURL (batch) curl -X POST "http://127.0.0.1:8000/api/ingest/books"
-H "Content-Type: application/json"
-d '{ "books": [ {"title": "Clean Code", "author": "Robert C. Martin", "category": {"name": "Software Engineering"}}, {"title": "The Pragmatic Programmer", "author": "Andrew Hunt", "summary": {"content": "..."}}, {"author": "Missing Title"} ] }'

Example mixed response (batch with one error) { "results": [ { "book": {"status": "updated", "id": 12, "slug": "clean-code"}, "category": {"status": "updated", "id": 4, "slug": "software-engineering"}, "summary": null }, { "book": {"status": "created", "id": 13, "slug": "the-pragmatic-programmer"}, "category": null, "summary": {"status": "created", "id": 10} }, { "index": 2, "status": "error", "message": "title and author are required." } ] }

Example error (empty payload) Status: 422 { "message": "No books provided." }

Notes

  • Authors are normalized to a separate authors table and linked via a pivot. You may send author (string) or authors (array). If authors is provided, the first name is also saved to the legacy author column on books for compatibility.
  • This endpoint performs minimal validation: each item must have title and author/authors. Other fields are optional.
  • Slugs are derived from names/titles if not provided, using Laravel's Str::slug.
  • There is no pagination or retrieval endpoint here; this endpoint is for ingestion only.
  • No authentication/rate limiting is configured by default; add it before exposing this API to untrusted clients.

About Laravel

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:

Laravel is accessible, powerful, and provides tools required for large, robust applications.

Learning Laravel

Laravel has the most extensive and thorough documentation and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.

You may also try the Laravel Bootcamp, where you will be guided through building a modern Laravel application from scratch.

If you don't feel like reading, Laracasts can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.

Laravel Sponsors

We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel Partners program.

Premium Partners

Contributing

Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the Laravel documentation.

Code of Conduct

In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via taylor@laravel.com. All security vulnerabilities will be promptly addressed.

License

The Laravel framework is open-sourced software licensed under the MIT license.

S
Description
No description provided
Readme
216 KiB
Languages
PHP 61.9%
Blade 37.9%