Have you installed the Well-Read Service in your development system? Make sure you have all the prerequisites to run the service in your system before you continue.
The Well-Read Service’s book collection contains novels categorized with different fantasy subgenres.
This tutorial teaches you how to retrieve a list of book
resources with a specific fantasy subgenre.
The tutorial takes approximately 5 minutes to complete.
For this tutorial, you’ll retrieve a list of all the books in the database with the epic subgenre.
Start the service by running this command in your preferred command-line tool:
cd <directory of the database file location>
json-server well-read-db.json
{base_url}/books?subgenre=epic
N/A
N/A
The response body should return all the books in the database with the epic subgenre:
[
{
"title": "Assasin's Apprentice",
"author": "Robin Hobb",
"page_count": 672,
"subgenre": "epic",
"pace": "slow",
"tags": [
"adventurous",
"epic",
"world-building"
],
"is_series": "true",
"id": 4
},
{
"title": "Tress of the Emerald Sea",
"author": "Brandon Sanderson",
"page_count": 384,
"subgenre": "epic",
"pace": "slow",
"is_series": "false",
"tags": [
"low-fantasy",
"adventurous",
"epic",
"whimsical"
],
"id": 5
}
]
Now that you know how to retrieve books by subgenre, you can filter books using the other book
resource properties.
View the reference topics for the book
resource to experiment with different ways to retrieve books.
You can even combine different properties in your API request for more refined results.