Add heroku-api support and refactor code to use it