I have connected octoprint via http Json rest API.
This could be a starting point for what you want to do!