Move api related funcs to api package
Separate main to cli package