Read pages, sections and tables of contents
shamela_readRead an installed book's text and structure by internal ids. unit:
page (default): one page_id → body (author's matn), foot (editor's footnotes), printed page label, prev/next page ids, enclosing headings.
range: up to 20 consecutive pages from start_page_id, each with text, footnotes, printed page — to read on past a hit or through a span.
section: one chapter by title_id with its sub-headings, up to the next heading outside it.
toc: headings with their title_ids; top level by default, parent_id/depth expand, containing_page_id gives the chain enclosing a page.
parts: volumes — part label, page count, first/last page_id.
services: what one page cites (aya ids, hadith keys, isnad markers, as stored) → shamela_lookup_quran(mode='aya'), shamela_lookup_hadith(mode='sources'), shamela_lookup_rijal(mode='isnad'). Rules: a parameter of another unit is refused. page_id is not the printed page and ids have gaps: step with prev_page_id/next_page_id, not ±1; for a printed «vol./page» call shamela_cite(mode='printed_page') first. A size budget cuts long text: follow body_has_more (body_part+1) or next_start_page_id. Errors: PAGE_NOT_FOUND (also a range start past the end), TITLE_NOT_FOUND, BOOK_NOT_FOUND, BOOK_NOT_DOWNLOADED (catalogued, not installed: use an installed edition from shamela_get_details(kind='book') same_group). Instead: a heading by its words → shamela_find(kind='heading'); books of untitled «فصل» headings → shamela_search(match='words') scoped to the book; any catalogued book's metadata → shamela_get_details(kind='book').
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| unit | No | Selects what the call does: page | range | section | toc | parts | services. Default page. | |
| count | No | How many consecutive pages to fetch (1–20, default 5). Fewer come back when the ~12,000-character budget is reached; has_more then stays true. Use shamela_read(unit='section') for full chapter reads. Faster than looping unit='page'. E.g. {unit:'range', book_id, start_page_id:1, count:5}. (unit=range only.) | |
| depth | No | Levels below parent_id to include (1–5, default 1); deeper levels arrive nested in `children`. Ignored when containing_page_id is set. E.g. {unit:'toc', book_id, depth:1} lists the top-level chapters. (unit=toc only.) | |
| book_id | No | The book id, from shamela_find(kind='book'), shamela_find(kind='work') or shamela_find(kind='name'). Installed ids: shamela_list_downloaded_books. | |
| page_id | No | [unit=page] Internal page id, as search hits, shamela_read(unit='toc') and shamela_cite(mode='printed_page') return it; not the printed page number. Ids have gaps, so take neighbours from prev_page_id/next_page_id. [unit=services] Shamela's internal page id (from a search hit or reader tool), not the printed page number. Example: {unit:'services', book_id:1681, page_id:10}. (unit=page|services only.) | |
| title_id | No | The title id of the chapter / section to fetch, from shamela_read(unit='toc') or shamela_find(kind='heading'). Its sub-headings are included. (unit=section only.) | |
| body_part | No | For long pages: when the body exceeds ~4000 characters it is split into parts. Pass the 1-based part to read (default 1). The response reports body_part/body_total_parts/body_has_more; request the next part by incrementing. The footnote/comment are returned with part 1. (unit=page only.) | |
| keep_html | No | [unit=page] If true, preserve inline HTML markers (e.g. <span data-type='title'>). Default false strips them for plain Arabic display. [unit=range|section] If true, keep Shamela's inline markup: <span data-type='title'> headings, <a href="inr://man-<narrator_id>"> narrator links, <hadeeth-N> markers. Default false strips them for plain Arabic display. (unit=page|range|section only.) | |
| max_pages | No | Cap on pages to read (1–100, default 30). The ~12,000-character budget can stop the read earlier; either way truncated:true and next_start_page_id say where to resume with shamela_read(unit='range'). (unit=section only.) | |
| parent_id | No | Title id whose children to list; 0 (default) = top-level chapters. Ignored when containing_page_id is set. (unit=toc only.) | |
| start_page_id | No | First page id to read (inclusive). To continue a range that was cut short, pass the previous response's next_start_page_id. (unit=range only.) | |
| response_format | No | Format of the human-readable text: 'markdown' (default) for display; 'json' the same data as one JSON code block; 'none' only a one-line pointer, leaving structuredContent as the whole answer. structuredContent is always returned, so a caller that parses it should pass 'none': the character budget counts both channels, and the unread copy otherwise spends most of it. Requires the 'response_format.none' capability (see shamela_get_brief). | |
| containing_page_id | No | Page id. Switches to ancestor-chain mode: returns the headings that enclose this page, root to leaf, in `ancestor_chain`; parent_id and depth are then ignored. E.g. containing_page_id:17 gives the chapter holding page 17. (unit=toc only.) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| raw | No | The raw service record, for debugging. (unit=services only.) | |
| ayat | No | Cumulative aya ids (1-6236, 262 = 2:255) cited on the page, as stored; pass to shamela_lookup_quran(mode='aya'). (unit=services only.) | |
| body | No | Main text (matn), or the requested body_part of it. (unit=page only.) | |
| foot | No | Footnotes (editor's words, not the author's); returned with body_part 1 only. (unit=page only.) | |
| mode | No | 'subtree' (parent_id/depth) or 'ancestor_chain' (containing_page_id). (unit=toc only.) | |
| part | No | Volume/part label, e.g. '4'; null for single-volume books. (unit=page only.) | |
| count | No | Pages actually returned (may be fewer than requested). (unit=range only.) | |
| depth | No | Levels expanded in subtree mode; null in ancestor_chain mode. (unit=toc only.) | |
| esnad | No | Raw isnad markers, one string per chain: «<zero-padded hadith key> s <narrator ids, Companion first, collector last>». Ids, not names; resolve with shamela_lookup_rijal(mode='isnad'). (unit=services only.) | |
| pages | No | Pages in reading order. (unit=range|section only.) | |
| parts | No | Volumes in reading order: whether a citation needs a part designator. Empty for a single-volume book unless its pages carry one part label (kept: citations print it). (unit=parts only.) | |
| titles | No | Subtree mode: the headings, nested via children. Empty under a leaf. (unit=toc only.) | |
| book_id | No | Catalogue book id. | |
| comment | No | User annotation; returned with body_part 1 only. (unit=page only.) | |
| hadeeth | No | Numeric hadith keys, as stored; pass to shamela_lookup_hadith(mode='sources'). (unit=services only.) | |
| page_id | No | [unit=page] Internal page id that was read. [unit=services] Page id. (unit=page|services only.) | |
| _display | No | Advice on presenting a long text (show in parts, or ask the user how); null when the text is short. (unit=page|range|section only.) | |
| has_more | No | True when pages exist after the last one returned. (unit=range only.) | |
| title_id | No | Heading that was read. (unit=section only.) | |
| body_part | No | 1-based part of the body returned. (unit=page only.) | |
| book_name | No | Catalogue title of the book (Arabic). (unit=page|range|section|toc|parts only.) | |
| parent_id | No | Parent expanded in subtree mode; null in ancestor_chain mode. (unit=toc only.) | |
| truncated | No | True when fewer pages were returned than the section has. | |
| title_text | No | Heading text. (unit=section only.) | |
| author_name | No | Main author name. (unit=page|range|section only.) | |
| end_page_id | No | Last page id of the section. (unit=section only.) | |
| esnad_count | No | Number of isnad markers. (unit=services only.) | |
| total_pages | No | Page records in the book. (unit=parts only.) | |
| has_services | No | False when the page carries no markers (common outside hadith works). (unit=services only.) | |
| next_page_id | No | Next existing page id; null at the end. (unit=page only.) | |
| prev_page_id | No | Previous existing page id (ids have gaps); null at the start. (unit=page only.) | |
| printed_page | No | Printed page label as Shamela renders it, e.g. '4/ 405'; null when the page has no printed number. (unit=page only.) | |
| rows_dropped | No | ||
| body_has_more | No | True when another body_part follows. (unit=page only.) | |
| category_path | No | Category names, broadest first. (unit=page only.) | |
| start_page_id | No | [unit=range] First page id requested. [unit=section] First page id of the section. (unit=range|section only.) | |
| ancestor_chain | No | ancestor_chain mode: headings enclosing the page, root to leaf. (unit=toc only.) | |
| is_multi_volume | No | True when the pages carry more than one part label. (unit=parts only.) | |
| body_total_parts | No | How many parts the body is split into. (unit=page only.) | |
| containing_titles | No | Chapter headings enclosing the page, root to leaf. (unit=page only.) | |
| next_start_page_id | No | [unit=range] Where to continue when the size budget cut the range short; null otherwise. [unit=section] Continue with shamela_read(unit='range') from here; null when the section is complete. (unit=range|section only.) | |
| truncation_message | No | ||
| total_pages_in_section | No | Pages the whole section spans. (unit=section only.) |