Is there an API for Buddhist texts?
SC has a API. E.g. : https://suttacentral.net/data?suttas=dn1,dn2

Also see: https://discourse.suttacentral.net/t/suttacentral-api-apps/1927/8

Also the data is in Github. E.g. https://github.com/suttacentral/suttacentral-data/blob/master/text/en/pi/su/an/an1/an1.21-40.html 

Similarly you can download the whole Access to Insight website as files: http://www.accesstoinsight.org/tech/download/bulk.html