Refactored api calls into functions
Removed redis stuff
Included refactoring of api calls