This repo[1] contains IPA dictionaries for 17 languages, including English, Spanish, and Chinese in JSON/CSV/XML/plain text format.
If you really want to find puns programmatically, the releases section[2] has a ready-made package with homonyms in all the languages, including English. It should be trivial to make an online service that searches through this file for matches on particular words.
[1] https://github.com/open-dict-data/ipa-dict [2] https://github.com/open-dict-data/ipa-dict/releases