Ramadan Last 10 Nights Campaign

Used by thousands of students worldwide - help us reach 150 members

... / 150 members...

Developers

Sharh API

The same REST API that powers sharhapp.com and the Sharh mobile app. Read classical texts line by line, manage your notes, flashcards and bookmarks, digitize documents with OCR, and more — 173 endpoints across 20 resource groups.

Base URL

All paths in this reference are relative to the API base URL. Requests and responses are JSON unless an endpoint says otherwise.

Base URL
https://app.ummahspot.com

Many read endpoints are public and need no credentials:

Request
curl "https://app.ummahspot.com/books/search?q=ajrumiyyah"

Authentication

Authenticated endpoints expect a bearer credential in the Authorization header. There are two kinds, and they are interchangeable on every endpoint in this reference except token management:

  • API tokens (recommended for scripts and integrations) — long-lived tokens that start with sharh_pat_, are attached to your account and act with your permissions. Create and revoke them on the API Tokens page or through the API Tokens endpoints.
  • Session tokens — the JWT returned by POST /user/login, POST /user/signup or Google sign-in. This is what the web and mobile apps use. Session tokens do not expire.
Using an API token
export SHARH_TOKEN="sharh_pat_..."

curl "https://app.ummahspot.com/books/mybooks" \
  -H "Authorization: Bearer $SHARH_TOKEN"
Getting a session token
curl -X POST "https://app.ummahspot.com/user/login" \
  -H "Content-Type: application/json" \
  -d '{"identifier": "you@example.com", "password": "••••••••"}'

Treat API tokens like passwords. The full token is shown once when you create it; Sharh only stores a hash. You can hold up to 10 active tokens, give each an optional expiry of up to 365 days, and revoke any of them at any time. API tokens cannot create or revoke other tokens, and are rejected by admin-only endpoints.

Access levels

Each endpoint is labelled with what it needs:

  • Public — no credentials needed.
  • Auth optional — works anonymously, but returns more (your private items, personalised fields) when you send a token.
  • Auth required — any signed-in account. Most of these only ever touch your own data.
  • editor / admin only — content-management endpoints limited to accounts with the editor role.
  • Subscription required — needs an active Sharh subscription (OCR uploads).

Errors

The API uses conventional HTTP status codes. Be prepared for error bodies to be either JSON ({ "message": "..." } or { "error": "..." }) or a plain-text string, depending on the endpoint — check the status code first.

400Missing or invalid parameters
401No credential was sent on an endpoint that requires one
402The content is gated behind a creator subscription
403The token is invalid, expired or revoked, or your account lacks the required role or subscription
404The resource does not exist, or is not visible to you
500Something went wrong on our side. Malformed ids are also commonly reported as 500

Conventions

  • Resource ids are 24-character MongoDB ObjectId strings. Timestamps are ISO 8601 in UTC.
  • A book's lines live inside the book: each line has Arabic, English, commentary and rootwords fields.
  • List endpoints that paginate take page and limit query parameters; each endpoint documents its own defaults and response envelope.
  • Audio, files and images are served through short-lived presigned URLs — request a fresh URL rather than storing one.
  • File uploads use multipart/form-data; everything else takes a JSON body.

API reference

Library

Books19 endpoints
/books

Browse, search, create and edit books. A book is a classical text stored as an ordered array of bilingual lines (Arabic, English, commentary, root words) embedded in the book document. Most error responses in this group are plain-text bodies rather than JSON.

Bookmarks5 endpoints
/bookmarks

Per-user bookmarks on book lines, with an optional note. A bookmark points at a line by its zero-based position (lineId) within the book, and is unique per user, book and line. All routes require authentication and only ever touch the caller's own bookmarks.

Audio15 endpoints
/audio

Text-to-speech audio for book lines. Audio is generated per line field (arabic, english, commentary) with an OpenAI TTS voice, stored as MP3 in S3 under the key bookId/lineId/field/voice_contentHash.mp3, and handed to clients either as a time-limited S3 presigned URL or as an MP3 stream proxied by the API. The content hash covers all of the line text plus the voice, so editing a line invalidates its cached audio. Generating audio is restricted to editors and admins; anonymous callers and members can only fetch audio that has already been generated for the current line content, and the listing and URL endpoints apply the same read-access rules as GET /books/:bookId (private and subscriber-only books require a token).

Quizzes8 endpoints
/quiz

AI-generated multiple-choice quizzes for books. A quiz belongs to one book and holds a list of questions, each with exactly 4 options (one correct) and a rationale. Reading quizzes is public; generating, editing and deleting them is limited to editors and admins.