GET /search

This returns the results that come from the search query that is used

Endpoint URL

http://127.0.0.1:8080/api/search

Query parameters

Name
Type
Description

book

string

The search that is used for the book

Example code

const searchBooks = async (text) => {
    // If the text is undefined, return an empty array
    if (text === undefined) {
        return [];
    }

    try {
        const response = await fetch(`/api/search?book=${text}`);
        const books = await response.json();

        // Sort the books based on the similarity to the search text
        books.sort((a, b) => {
            const similarityA = calculateSimilarity(a.title, text);
            const similarityB = calculateSimilarity(b.title, text);
            
            // Sort in descending order of similarity
            return similarityB - similarityA;
        });

        return books;
    } catch (error) {
        console.error("Error fetching search results:", error);
        throw error;
    }
};

Example response

Below are the search results for "android" they are ordered by _id

Response fields

Name
Type
Description

_id

integer

This is the identification number, which is unique to each specific book

newrelease

Boolean

A Boolean value to determine whether or not the book is a new release and would therefore show up in the new release section if this is true

title

string

The title of the book

isbn

string

The International Standard Book Number for this specific book

pageCount

integer

The number of pages in the book, all pages are included

publishedDate

date

The date at which this copy of the book was first published

thumbnailUrl

string

Image URL for the thumbnail or cover of the book

shortDescription

string

A short description of the book, acting as a blurb

longDescription

string

A more extensive description which covers the major points of the book

status

string

Whether or not the book is currently published, so far all the books in the library are

authors

array of strings

An array of all authors who contributed to the book

categories

array of strings

The listed genres / categories of the book as all books are non-fiction at the moment

favourited

Boolean

Whether or not the book is a favourite for the user, as no identification system is being used, this is a global property

Last updated