The liked books API allows users to favorite books and retrieve their liked book list.
Toggle like
Add or remove a book from the user’s liked books list.
const result = await orpc.likedBooks.toggleLike.mutate({
bookUuid: "550e8400-e29b-41d4-a716-446655440000"
});
Parameters
UUID of the book to like/unlike
Response
Whether the book is now liked (true) or unliked (false)
Get like status
Check if a specific book is liked by the current user.
const status = await orpc.likedBooks.getLikeStatus.query({
bookUuid: "550e8400-e29b-41d4-a716-446655440000"
});
Parameters
UUID of the book to check
Response
Whether the book is liked by the current user
List liked books
Retrieve a paginated list of books liked by the current user.
const likedBooks = await orpc.likedBooks.listLiked.query({
limit: 20
});
Parameters
Number of books to return (max 100)
Response
Returns an array of book objects with full metadata.
Array of liked books
Unique identifier for the book
URL to the book’s cover image
ISO timestamp when the book was liked
Implementation example
Display a like button in your book UI:
import { useState } from 'react';
import { orpc } from '@/utils/orpc';
function LikeButton({ bookUuid }: { bookUuid: string }) {
const [liked, setLiked] = useState(false);
const handleToggle = async () => {
const result = await orpc.likedBooks.toggleLike.mutate({ bookUuid });
setLiked(result.liked);
};
return (
<button onClick={handleToggle}>
{liked ? '❤️ Liked' : '🤍 Like'}
</button>
);
}
All liked books endpoints require authentication. The liked books list is private to each user.