# Retrieving All Books - Planning

Refer back to [*Chapter 6, The Bookstore API Endpoint Specifications, API Endpoint #5: Retrieve All Book Listings*](/part-3/chapter-6/1-the-bookstore-api-endpoint-specifications.md#api-endpoint-5-retrieve-all-book-listings) section for the API endpoint specifications.

## 1 - Route Name

From the specification, it seems like this will be a `GET` request that will fetch a collection of books. We can refer back to the sections under chapter 3 for guidelines to follow, specifically the sections [*Method Verbs*](/part-2/chapter-3/3-method-verbs.md) and [*URI Design*](/part-2/chapter-3/2-uri-design.md).

The following URI should suffice.

`GET /api/v1/books`

## 2 - Input Request

Since this is a `GET` request, there won't be any input request or payload from the client.

## 3 - Middleware

This is a public URI, so there really is no need for any middleware.

## 4 - Validation

Again, since this is just a simple `GET` request, there won't be any validation needed.

## 5 - Domain

From the specifications, it looks like we will need the following book entity in our domain layer.

**bookModel**

* `title`
* `description`
* `price`
* `author`
* `datePublished`

We will also need some sort of way to query the database to be able to retrieve all the books, `getAllBooks()` will be the method we'd call.

**bookRepository**

* `getAll()`

On top of that, our controller will call a service, in this case, it will be the `bookService` which will retrieve all of the books in our database.

**bookService**

* `getAllBooks()`

This is a rough outline of how we are going to be implementing these functions, we'll take a deeper dive at the implementations in the next section of this chapter.

## 6 - Events

Judging from the specifications, there doesn't seem to be any events, so we'll leave this blank as well.

## 7 - Response

As mentioned previous, we will be ["Using a Consistently Wrapped Response"](/part-2/chapter-3/5-representational-design.md#using-a-consistently-wrapped-response).

We'll be adding in these fields:

* `title`
* `description`
* `price`
* `author`
* `datePublished`

for each of our book listings.

```json
{
    "status": "success",
    "code": 200,
    "message": "List of all books in the database."
    "data": [
        {
            "id": "61f88350745d83158f3c746d",
            "title": "Harry Potter and the Goblet of Fire",
            "description": "Mint condition, but will negotiate",
            "price": 99,
            "author": "J.K. Rowling",
            "datePublished": "Sun Oct 10 2021 23:56:34 GMT-0400"
        },
        ...
    ],
    "errors": null
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://book.restfulnode.com/part-3/chapter-7/1-retrieving-all-books-planning.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
