Added a handler for the api for easier management and use
Merged in API code