changed api() to allow dependency injection

dependency injection for the http() class to test locally easier along
with fixes.