Free Use Bible API

repository·main·Indexed 41 days ago

https://github.com/helloaolab/bible-api

A high-performance JSON API provided by AO Lab that offers Bible translations, commentaries, and supplementary datasets (such as cross-references and biblical entities) in numerous languages without requiring API keys or usage limits. Version 1.14.0.

Tokens
36.9K
Snippets
102
Records
132
Agent score
49%

What's inside Free Use Bible API

  1. Overview of the Free Use Bible API

    main

    The Free Use Bible API provides a fully featured JSON interface for accessing over 1,000 Bible translations in more than 700 languages. The API returns data in a JSON format that includes basic formatting information and additional metadata such as footnotes.

    Key characteristics:

    • No Authentication Required: No API keys are needed to access the service.
    • No Usage Limits: There are no restrictions on the number of requests.
    • Permissive Licensing: The content has no copyright restrictions, allowing for modification and commercial use. (Note: If you modify a translation, you should rename it to avoid confusion with the original).
    • Global Availability: Hosted on AWS for low-latency access worldwide.
  2. Overview of the Free Use Bible API

    main
    The Free Use Bible API, provided by AO Lab, offers the Bible and related resources in formats optimized for application use. The project aims to make these resources freely available to developers and users globally. The API is developed in partnership with the Berean Study Bible (BSB) team.
  3. Explore the Free Use Bible API reference documentation

    main

    The Free Use Bible API reference documentation is organized into three primary categories. Depending on your integration needs, you can access documentation for:

    1. Translations, Books, & Chapters: Information regarding Bible translations, their constituent books, and chapter content. This is available in both standard and simplified formats.
    2. Commentaries: Details on Bible commentaries, including their books, chapters, and profiles.
    3. Datasets: Access to supplementary biblical data, such as cross-references and biblical entities (including people, places, events, and people groups), along with their associated books, chapters, and entities.
  4. Available SDKs for Free Use Bible API

    main
    The Free Use Bible API provides pre-built SDKs to simplify integration. Currently, a dedicated SDK is available for JavaScript and TypeScript environments. For detailed installation instructions and usage patterns, refer to the JavaScript/TypeScript documentation.
  5. Choose between Standard and Simplified content formats

    main

    When fetching chapter content, complete-translation downloads, or word-level annotations, you can choose between two formats depending on your rendering needs:

    • Standard format: The original, structured format. Verse content is provided as a list of discrete pieces (e.g., plain text, formatted text, footnote references) that you must manually assemble.
    • Simplified format: A flattened format where the content of each verse is a single string. Footnotes, poetry, and other markup are expressed as offsets within that string.
  6. Use Simplified Chapters

    main

    Simplified chapters provide each verse's content as a single string instead of a list of formatted content items. This is useful for easier text processing. Footnotes, headings, and poetry are represented as offset ranges into this single string.

    Methods:

    • getSimpleTranslationBookChapter(translation, book, chapter, endpoint?)
    • getSimpleCommentaryBookChapter(commentary, book, chapter, endpoint?)
    • getSimpleCompleteTranslation(translation, endpoint?)
    • getSimpleChapter(chapter, endpoint?): Follows a chapter's simpleChapterApiLink.
    • getSimpleTranslationBookChapterWords(translation, book, chapter, endpoint?) / getSimpleChapterWords(chapter, endpoint?): Word annotations for simplified chapters.
    • getSimpleWordText(verse, word) / getSimpleVerseWords(verse, words): Resolves offsets for simplified verses.
    • getSimpleChapterVerseText(chapter, options?): Extracts text from a simplified chapter.
  7. Understand ChapterContent types

    main

    The chapter.content array is a union type of different content pieces that make up a chapter. When iterating through content, check the type field to determine how to render it.

    Supported Types:

    • heading: A chapter heading. Contains a content array of strings.
    • line_break: A simple line break.
    • verse: A Bible verse. Contains a number and a content array which can include strings, FormattedText, InlineHeading, InlineLineBreak, or VerseFootnoteReference.
    • hebrew_subtitle: Informational content (e.g., subtitles in Psalms). Contains a content array of strings, FormattedText, or VerseFootnoteReference.
    type ChapterContent = ChapterHeading | ChapterLineBreak | ChapterVerse | ChapterHebrewSubtitle;
    
    interface ChapterHeading {
        type: 'heading';
        content: string[];
    }
    
    interface ChapterLineBreak {
        type: 'line_break';
    }
    
    interface ChapterHebrewSubtitle {
        type: 'hebrew_subtitle';
        content: (string | FormattedText | VerseFootnoteReference)[];
    }
    
    interface ChapterVerse {
        type: 'verse';
        number: number;
        content: (string | FormattedText | InlineHeading | InlineLineBreak | VerseFootnoteReference)[];
    }
  8. Use @helloao/cli as a library

    main

    The @helloao/cli package can be imported into your own TypeScript/JavaScript projects to perform CLI actions programmatically. It exports six main modules:

    • actions: Function versions of the CLI commands for easy scripting.
    • db: Database operations (importing translations, inserting chapters/verses, managing SQLite instances).
    • downloads: Utilities for downloading files.
    • files: File system utilities (loading translation files, discovering metadata, managing local/zip uploads).
    • uploads: Utilities for uploading APIs to S3, local filesystems, or zip archives.
    • s3: A class specifically for uploading files to S3.
  9. Understand Offsets in the Simplified Format

    main

    In the simplified format, all offsets (offset, start, and end) are indexes into the text property of the verse.

    • Measurement: Offsets are measured in UTF-16 code units, matching JavaScript's String.prototype.length and String.prototype.slice().
    • Ranges: start is inclusive and end is exclusive. You can extract the marked text using text.slice(start, end).
    • Footnotes: The offset for a footnote indicates the position where the footnote's caller should be inserted. For example, text.slice(0, offset) returns the text preceding the footnote.
  10. Understand the Simplified Format

    main
    The Simplified Format is a streamlined data representation used for retrieving chapters, performing complete-translation downloads, and accessing word-level annotations. It is intended as a less structured alternative to the standard format. Use this format when you need a more direct representation of the text without the full complexity of the standard structured schema.
  11. How entity datasets and chapter entities work

    main

    Entity datasets (like theographic) provide metadata about people, places, events, and people groups.

    Key Characteristics:

    • Discovery: Entity datasets include specific links in their /api/available_datasets.json entry: listOfPeopleApiLink, listOfPlacesApiLink, listOfEventsApiLink, and listOfPeopleGroupsApiLink.
    • Chapter Alignment: You can retrieve chapter-aligned entity data via /api/d/{dataset}/{book}/{chapter}.json. This returns the entities appearing in that chapter and the verse numbers where they are mentioned.
    • Combining Data: Entities use standard Bible book IDs, chapter numbers, and verse numbers, allowing them to be overlaid on any translation.
    • Entity References: Entities reference each other using DatasetEntityRef, which specifies a type ('people' | 'places' | 'events' | 'groups') and an id.
    export interface DatasetEntityRef {
        /**
         * The ID of the entity that is being referenced.
         */
        id: string;
    
        /**
         * The type of the entity that is being referenced.
         * Matches the collection segment of the entity's API link,
         * so the link can be constructed as `/api/d/{dataset}/{type}/{id}.json`.
         */
        type: 'people' | 'places' | 'events' | 'groups';
    
        /**
         * The name of the entity that is being referenced.
         */
        name?: string;
    
        /**
         * The API link for the entity that is being referenced.
         */
        apiLink?: string;
    }
    
    export interface VerseRef {
        /**
         * The ID of the book (GEN, EXO, etc.).
         */
        book: string;
    
        /**
         * The chapter number that the reference starts at.
         */
        chapter: number;
    
        /**
         * The verse number that the reference starts at.
         */
        verse: number;
    
        /**
         * The verse that the reference ends at.
         * Consecutive verses in the same chapter are collapsed into a single reference.
         */
        endVerse?: number;
    }
  12. Format and Footnotes in Chapter Content

    main

    Text within verses or subtitles can be enriched with formatting and footnotes.

    FormattedText: Used to denote specific text styles. Includes:

    • text: The actual string.
    • poem?: A number indicating indentation level (common in Psalms).
    • wordsOfJesus?: A boolean flag for the words of Jesus.

    Footnotes: Footnotes are managed via ChapterFootnote objects and referenced in content using VerseFootnoteReference (which provides a noteId).

    Footnote Structure:

    • noteId: Unique identifier for the note.
    • text: The footnote content.
    • reference?: The chapter and verse this footnote applies to.
    • caller: The character used to link the text to the footnote (e.g., "(a)" or "+" for autogenerated).
    interface FormattedText {
        text: string;
        poem?: number;
        wordsOfJesus?: boolean;
    }
    
    interface VerseFootnoteReference {
        noteId: number;
    }
    
    interface ChapterFootnote {
        noteId: number;
        text: string;
        reference?: {
            chapter: number;
            verse: number;
        };
        caller: '+' | string | null;
    }