Back in July, I thought I’d prototype a REST API for MorphGNT with resources for books, paragraphs, sentences, verses and words.

The prototype is available on http://api.morphgnt.org/ and the underlying code here.

The API exposes in JSON not only the normal MorphGNT data but also the paragraphs from the SBLGNT proper, the sentence divisions from the GBI syntax analysis AND the dependency relationships discussed in Converting the GBI Syntax Trees to a Dependency Analysis. So for now, at least, it’s the only place you can get all that info.

The prototype is currently served up using Django hitting a PostgreSQL database but it would be possible to just generate the roughly 150,000 JSON files once and serve them up from a CDN.

There’s only one thing using the API that I know of at the moment and that’s the lab on this site. It doesn’t make use of a lot of the rich word-level information but it does demo how you can navigate through paragraphs of the GNT purely using the links in a book’s first_paragraph or a paragraph’s prev and next fields.

Note that the /v0/ prefix is used in URLs because there is no commitment to keep this API. It is subject to rapid change at the moment.

The URI patterns are:

/v0/root.json
/v0/book/{osis_id}.json
/v0/paragraph/{paragraph_id}.json
/v0/sentence/{sentence_id}.json
/v0/verse/{verse_id}.json
/v0/word/{word_id}.json

A word (currently) looks something like this:

{
    @id: "/v0/word/64001001005.json",
    @type: "word",
    verse_id: "/v0/verse/640101.json",
    sentence_id: "/v0/sentence/640001.json",
    paragraph_id: "/v0/paragraph/64001.json",
    crit_text: "λόγος,",
    text: "λόγος,",
    word: "λόγος",
    norm: "λόγος",
    lemma: "λόγος",
    pos: "N",
    case: "N",
    number: "S",
    gender: "M",
    dep_type: "S",
    head: "/v0/word/64001001002.json"
}

A verse (currently) looks something like this:

{
    @id: "/v0/verse/640101.json",
    @type: "verse",
    prev: null,,
    next: "/v0/verse/640102.json",
    book: "/v0/book/John.json",
    words: [...]
}

where words is a list of objects like the word above.

A paragraph and sentence are very similar to a verse (with an @id, @type, prev, next, book and words list).

A book (currently) looks something like this:

{
    "@id": "/v0/book/1Cor.json",
    "@type": "book",
    "name": "1 Corinthians",
    root: "/v0/root.js",
    "first_paragraph": "/v0/paragraph/67001.json",
    "first_verse": "/v0/verse/670101.json",
    "first_sentence": "/v0/sentence/670001.json"
}

Feedback is greatly appreciated to make this more useful. I’d particularly like to work with some front-end developers to do some more complex demos built on the API.