Get SuttaPlex data API

Do you need general information about a sutta, including blurb, difficulty, and a list of all the translations available on SuttaCentral? Then the SuttaPlex API is for you!

[ All API documentation | General discussion on SC APIs | autogenerated documentation]

What is a SuttaPlex?

A SuttaPlex page is one where all of the basic data about a sutta is presented on a single page. For example, https://suttacentral.net/dn1 The exact presentation depends on what a website user’s language setting is:

We also find these SuttaPlex “cards” as a list when displaying a chapter. Sometimes the cards are “compact”:

The SuttaPlex API gives all the information on these cards other than the parallel data.

Requesting SuttaPlex data

Pattern:

https://suttacentral.net/api/suttaplex/<uid>?language=<2 letter language code>

Example URL: https://suttacentral.net/api/suttaplex/dn1?language=de

Language parameter is optional

Returns:

acronym:

A string with the human readable/pretty version of the citation. e.g. DN 1 (as opposed to the uid)

volpages:

A string with a list of all PTS volume and page numbers for this sutta. E.g.:
" PTS 1.1, PTS 1.2, PTS 1.3, PTS 1.4, PTS 1.5, PTS 1.6, PTS 1.7, PTS 1.8, PTS 1.9, PTS 1.10, etc.

alt_volpages:

???

uid:

A string with the unique ID for this sutta, e.g. “dn1”. Always lowercase, no spaces, ascii hyphens only.

blurb:

A short summary for the sutta. This data is located here on github.

difficulty: {

An object with two key/value pairs. E.g.:

{
      "name": "advanced",
      "level": 3
}

name can be “beginner”, “intermediate”, or “advanced”. Level is a number between 1 and 3.

original_title:

A string with the title in the original language, e.g. “Brahmajālasutta”. These are found here on github.

root_lang:

A string with the language code of the original language, e.g. “pli”.

root_lang_name:

A string with the full name of the original language, e.g. “Pāli”.

type:

A string with values “leaf” or “branch”

translated_title:

This is the site wide title (not a specific translator’s title of the sutta). By default it is English unless a language is specified in the request, e.g. api/suttaplex/dn1?language=de

translations: [

This is an array of objects for the root text and all existing translations on the site in all languages.

Root text example:

 {
        "lang": "pli",
        "lang_name": "Pāli",
        "is_root": true,
        "author": "Mahāsaṅgīti Tipiṭaka Buddhavasse 2500",
        "author_short": "ms",
        "author_uid": "ms",
        "publication_date": null,
        "id": "dn1_root-pli-ms",
        "segmented": true,
        "title": null,
        "volpage": null,
        "has_comment": false
      },

Translation example:

{
        "lang": "de",
        "lang_name": "Deutsch",
        "is_root": false,
        "author": "Sabbamitta",
        "author_short": "sabbamitta",
        "author_uid": "sabbamitta",
        "publication_date": null,
        "id": "dn1_translation-de-sabbamitta",
        "segmented": true,
        "title": "Das göttliche Netz ",
        "volpage": null,
        "has_comment": true
      },

parallel_count:

An integer with the number of parallels for this sutta.

biblio:

This type is a string, representing the uid of a book

priority_author_uid

A string with the unique ID for the translator whose translation appears first in the list.

verseNo:

For suttas in collections that are primarily verses, this is a string that lists the verses in that sutta. E.g. for Snp1.1 it is "Verse 1–17". Uses an en-dash () for ranges.

Errors

If there is no matching text, the following will be returned:

[
  {
    "acronym": null,
    "volpages": null,
    "alt_volpages": null,
    "uid": null,
    "blurb": null,
    "difficulty": null,
    "original_title": null,
    "root_lang": null,
    "root_lang_name": null,
    "type": null,
    "translated_title": null,
    "translations": [],
    "parallel_count": 0,
    "biblio": null,
    "priority_author_uid": null,
    "verseNo": null
  }
]

Parameters

The language=de, etc., parameter only affects the translated_title and blurb results.


Note: This is post is a wiki. Please feel free to click the edit button below to make changes. Feel free to reply to the post if you have questions.

3 Likes

There were a few things I was unsure about, including type, biblio, and alt_volpages.

I’m also not really sure how to explain volpages since it doesn’t appear to be exclusively PTS. Is it some kind of somewhat arbitrary “main” reference system?

I thought that type had to do with range suttas, but I don’t think so.

@HongDa if you have time to explain I will update the OP. No rush.

I was also unsure where the translated names of suttas are found on github. ven. @sabbamitta ?

1 Like

Do you mean the “name” files?

The English ones are here, the German ones here, and probably for other languages respectively.

But I think not all translation projects do include the “names”.

Ah, thank you.

I had assumed that Bhante Sujato’s names were the default names like the English interface files. But the priority_author_uid must determine it.

1 Like

I didn’t know we have something with that name! :laughing:

Sorry for the late reply :pray:

Yes.

type:

A string with values “leaf” or ???

leaf and branch.

biblio

This type is a string, representing the uid of a book


The relationship between volpages and alt_volpages requires Bhante @sujato to explain :pray:

1 Like

Oh wow this is really cool. Is it possible to also get the URLs that hold the text for the original and translated languages? If not, I think that would be extremely useful to have too.

You can build that from the data in the translations array. You would just have to cycle through the array testing to see when translations[n].is_root==true to get the root. Then build it into something like this:
https://suttacentral.net/dn1/pli/ms
https://suttacentral.net/dn1/{lang}/{author_uid}

Is that what you mean?

Hmm I’m talking about the raw text as a JSON file:

https://raw.githubusercontent.com/suttacentral/bilara-data/published/translation/en/sujato/sutta/dn/dn1_translation-en-sujato.json

1 Like

Ah. I don’t think any of the APIs will be able to link back to github. But the Bilara sutta text API (not sure the name exactly) will get you the json. E.g
https://suttacentral.net/api/bilarasuttas/sn7.5/sujato

Here is the wiki:

2 Likes

@HongDa, Am I correct in understanding that the response from this api call will always be an array with a single item? For example:
https://suttacentral.net/api/suttaplex/dn1?language=de returns an array:
image

Whereas the bilara api retuns an object:
[https://suttacentral.net/api/bilarasuttas/dn1/sujato?lang=en](https://suttacentral.net/api/bilaras
image
uttas/dn1/sujato?lang=en)

Ven. @Snowbird
The suttaplex API returns an array even if there is only one result.

The bilarasutta API will return an object.

1 Like