API Documentation

Simple RESTful API for Book Reading Application

Download Demo Android App

Try our demo Android application to see the API in action

📥 Download APK (Demo) 📂 View on GitHub

🌐 Base URL

Base URL: http://testapijo.my.id/api/v0

All endpoints are relative to the base URL. Replace your-domain.com with your actual server domain.

📡 API Endpoints

GET /books

Retrieve all books with their chapters.

Response:

{ "success": true, "data": [ { "id": 1, "title": "The Great Adventure", "author": "John Smith", "description": "An epic tale of courage", "cover_image": "https://example.com/image.jpg", "created_at": "2024-01-01T00:00:00.000000Z", "updated_at": "2024-01-01T00:00:00.000000Z", "chapters": [ { "id": 1, "book_id": 1, "chapter_number": 1, "title": "The Beginning", "content": "Chapter content...", "created_at": "2024-01-01T00:00:00.000000Z", "updated_at": "2024-01-01T00:00:00.000000Z" } ] } ] }

GET /books/{id}

Retrieve a specific book with all its chapters.

URL Parameters:

Parameter Type Description
id integer The ID of the book

Example Request:

GET /api/books/1

Response:

{ "success": true, "data": { "id": 1, "title": "The Great Adventure", "author": "John Smith", "description": "An epic tale of courage and discovery", "cover_image": "https://example.com/image.jpg", "chapters": [...] } }

GET /books/{bookId}/chapters

Retrieve all chapters for a specific book.

URL Parameters:

Parameter Type Description
bookId integer The ID of the book

Example Request:

GET /api/books/1/chapters

Response:

{ "success": true, "data": [ { "id": 1, "book_id": 1, "chapter_number": 1, "title": "The Beginning", "content": "It was a dark and stormy night...", "created_at": "2024-01-01T00:00:00.000000Z", "updated_at": "2024-01-01T00:00:00.000000Z" }, { "id": 2, "book_id": 1, "chapter_number": 2, "title": "The Discovery", "content": "As dawn broke...", "created_at": "2024-01-01T00:00:00.000000Z", "updated_at": "2024-01-01T00:00:00.000000Z" } ] }

GET /chapters/{id}

Retrieve a specific chapter with book information.

URL Parameters:

Parameter Type Description
id integer The ID of the chapter

Example Request:

GET /api/chapters/1

Response:

{ "success": true, "data": { "id": 1, "book_id": 1, "chapter_number": 1, "title": "The Beginning", "content": "It was a dark and stormy night...", "created_at": "2024-01-01T00:00:00.000000Z", "updated_at": "2024-01-01T00:00:00.000000Z", "book": { "id": 1, "title": "The Great Adventure", "author": "John Smith", "description": "An epic tale", "cover_image": "https://example.com/image.jpg" } } }

📋 Data Models

Book Object

Field Type Description
id integer Unique identifier
title string Book title
author string Author name
description string Book description
cover_image string (URL) Book cover image URL
chapters array Array of chapter objects
created_at timestamp Creation timestamp
updated_at timestamp Last update timestamp

Chapter Object

Field Type Description
id integer Unique identifier
book_id integer Parent book ID
chapter_number integer Chapter number
title string Chapter title
content text Chapter content
created_at timestamp Creation timestamp
updated_at timestamp Last update timestamp

⚠️ Error Responses

404 Not Found

{ "success": false, "message": "Book not found" }

500 Server Error

{ "success": false, "message": "Internal server error" }

🚀 Quick Start

Using cURL

# Get all books curl http://testapijo.my.id/api/v0/books # Get specific book curl http://testapijo.my.id/api/v0/books/1 # Get chapters curl http://testapijo.my.id/api/v0/books/1/chapters

Using Android (Retrofit)

// Define service interface interface ClientService { @GET("books") suspend fun getAllBooks(): Response @GET("books/{id}") suspend fun getBook(@Path("id") id: Int): Response } // Make API call lifecycleScope.launch { val response = ApiClient.service.getAllBooks() if (response.isSuccessful) { val books = response.body() // Handle response } }