Constructing the bilara-data URL for a given sutta

If I want to construct the URL for a given suttas text in bilara-data, how do I do this?

For something like MN8 this is straightforward -

But for something like Iti14 - - how do I know to add the “/vagga2/” part?

Is there some lookup table that maps suttas to URLs?

1 Like

Wow you have just chosen the most difficult example! The content of the Iti folders does not follow any logical system. While translating that collection, when I was looking for a particular Sutta, I just went there and opened the folders to look what is inside …

Not sure if there’s a better way? Learn them by heart? :see_no_evil: :person_shrugging:

Haha I want to access them programatically.

Ok I created a mapping table, here’s the code in case anyone is interested.


# Check Github API calls remaining.
rate <- gh("GET /rate_limit")
calls_remaining <- rate$rate$limit - rate$rate$used
if (calls_remaining < 72) stop("API calls insufficient.")

sutta_list_root <- "/repos/suttacentral/bilara-data/contents/translation/en/sujato/sutta/"

nikayas <- c("dn", "mn", "sn", "an", "kn")

sutta_list <- unlist(map(sutta_list_root, paste0, nikayas))

resp <- map(paste0("GET ", sutta_list), gh)
names(resp) <- nikayas

raw_content_url <- function (resp) {
  lapply(resp, function (x) {
    if (is.null(x$download_url)) {
    } else {

download_urls <- unlist(lapply(resp, raw_content_url))

output <- tibble(url = download_urls) %>% 
  mutate(sutta = str_remove(url, "^.*(?=/)/")) %>% 
  mutate(sutta = str_remove(sutta, "(?=_).*$")) %>% 
  toJSON(pretty = TRUE)
1 Like

Bhante @sujato if I send you the JSON file that maps suttas to URLs is that something you might upload to bilara-data?

Looks like this:

“url”: “”,
“sutta”: “ud7.10”

1 Like