Code Buckets

Buckets of code

.Net Projects

Buddhist Texts API: Dhammapada

The Pali Canon

A while ago I was looking for an API which provided Buddhists Texts and I couldn’t finda good one – so I’ve created one myself and published it.

I’ve started with the Dhammapada which is pretty much the most well-known of the original Buddhist texts. It’s compact and is divided up nicely into chapters and verses. It’s also one of my favourites, full of lovely quotes such as

Not the sweet smell of flowers, not even the fragrance of sandal,tagara,or jasmine blows against the wind. But the fragrance of the virtuous blows against the wind. Truly the virtuous man pervades all directions with the fragrance of his virtue.

Pupphavagga: Flowers (dhp 4), translated from the Pali by Acharya Buddharakkhita. Access to Insight (

The Dhammapada is part of a bigger collection of Buddhist texts called the Pali Canon – named after the Indian language it was originally written in. It is the oldest collection of Buddhist texts dated from the time of the Buddha himself.


The API is published at

and is freely available under these terms of use

You may download these files to your computer, print them out, read them, share them with your friends, copy them to your own website, translate them into other languages, and redistribute them electronically — provided that you do not charge any money for them. They are not in the public domain.

Basically, you can do what you like with the texts except sell them. I’m personally not massively troubled about anyone selling them either, but this license is from the original translators of the texts at Access to Insight.

The code is published on my git hub site here

and is freely available to use under similar terms, again to respect the wishes of the original translators.

Example Calls

I think that the random quote function is the most useful, but the API also contains search functionality and the ability to retrieve specific chapters and/or verses e.g.


Generates a random quote from all supported texts


Generates a random quote from all supported texts of a maximum length of 100 characters


Gets the fifth verse of the fourth sutta of the Dhammapada collection. This is the Flowers sutta


Gets the first 5 quotes from all supported text which contain the word happiness

The full OpenAPI definition is available at here which can also be used to automatically generate clients using NSwagStudio or similar

Technical Details

The overall aim is to use purely open-source software for this. Therefore

  • The API is coded in Asp.Net Core 3.1
  • Database is MySql
  • Containerised into Linux containers using Docker
  • Containers deployed onto a Linux (Debian) hosted at Digital Ocean


I’ve coded several clients that use the API.

Angular –

React –

Asp.Net Razor Pages –

The Razor Pages one is a good one to look at, if you are curious. That has a footer which randomly generates Dhammpada quotes which is pretty nice and a good use case for the API.

Razor pages client with random quote in footer

Next Steps

I’ve been through a couple of iterations of the API so I think the endpoints are pretty stable now. The next step is to put some more content in. The next ones will be


This is a collection of poetry written by the Buddha’s male followers – the monks. It’s very quoteable. It’s provided by Access to Insight however it’s incomplete so only part of it will go in


Very similar to the above except it’s poetry by Buddhist nuns. Again, very quoteable and very lovely and provided by Access to Insight. Also, incomplete.

Dhammapada – translated by F. Max Muller

One of the oldest translations of the Dhammapada. Some of the translations are a bit odd (church, sin etc…) but it’s translation that I’m very fond of. It’s freely available at the Gutenberg Project. I’ll have to extend the API at this point to include authors, but I’ve designed the API with that extension in mind.


Most of the unpaid stuff I’ve done has been to try out new technologies and for my own personal amusement. This one, I actually think is useful. It would be amazing if anyone wanted to contribute – particularly writing code to bring in new content. All you would need to do is

  1. Write another class like the DhammapadaProvider for your new text
  2. Make sure it inherits from IProvider
  3. Provide the source for the import and make sure that it’s free to use under our terms i.e. we aren’t going to resell it.
  4. Update the tests here

And that’s it

Balanced against that, it would need to be someone who is interested in writing APIs and reading 2500-year-old Buddhist texts.

Not too many people in the green intersection

I suspect that there aren’t too many people who are at the intersection of that particular Venn diagram. It might be a set with just one member – me!


    • Glad you found it useful. Unfortunately the Dhammapada is the only book supported at the moment. When I get time I intend to add more. All the best


Your email address will not be published. Required fields are marked *