There is a python discourse api library that is a few years old:
https://github.com/tindie/pydiscourse
And a forked version that has been updated somewhat recently:
https://github.com/bennylope/pydiscourse
Hopefully the latter one will work for you.
Also this plugin may be of interest to you:
https://meta.discourse.org/t/the-github-linkback-plugin/66081