Addition of API code

Needs a lot of cleanup