readwise_get_book_highlights
Extract and retrieve all highlights from a specific book using the book ID. Simplifies access to key insights and annotations for efficient review and knowledge management.
Instructions
Get all highlights from a specific book
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bookId | Yes | The ID of the book to get highlights from |
Implementation Reference
- The main handler function for 'readwise_get_book_highlights'. Initializes the Readwise client, calls getBookHighlights with bookId, strips response to id/text/note, and returns JSON-formatted text content.export async function handleGetBookHighlights(args: any) { const client = await initializeClient(); const response = await client.getBookHighlights(args.bookId); // Strip to essentials const minimal = response.data.map(h => ({ id: h.id, text: h.text, note: h.note || undefined })); return { content: [ { type: 'text', text: JSON.stringify(minimal, null, 2), }, ], }; }
- Tool schema definition including name, description, and input schema requiring 'bookId' as a number.{ name: 'readwise_get_book_highlights', description: 'Get all highlights from a specific book', inputSchema: { type: 'object', properties: { bookId: { type: 'number', description: 'The ID of the book to get highlights from', }, }, required: ['bookId'], additionalProperties: false, }, },
- src/handlers/index.ts:54-55 (registration)Registration in the main tool dispatcher switch statement, routing the tool call to the handler function.case 'readwise_get_book_highlights': return handleGetBookHighlights(args);
- src/readwise-client.ts:410-421 (helper)Helper method in ReadwiseClient that fetches highlights for a book by calling listHighlights with book_id filter and page_size 1000, used by the handler.async getBookHighlights(bookId: number): Promise<APIResponse<ReadwiseHighlight[]>> { try { const result = await this.listHighlights({ book_id: bookId, page_size: 1000 }); return this.createResponse(result.data.results); } catch (error) { if (error instanceof Error && error.message.startsWith('RATE_LIMIT:')) { const seconds = parseInt(error.message.split(':')[1], 10); throw new Error(`Rate limit exceeded. Too many requests. Please retry after ${seconds} seconds.`); } throw error; } }
- src/handlers/index.ts:8-16 (registration)Import statement registering the handleGetBookHighlights function for use in the tool dispatcher.import { handleListHighlights, handleCreateHighlight, handleExportHighlights, handleGetDailyReview, handleListBooks, handleGetBookHighlights, handleSearchHighlights, } from './highlights-handlers.js';