Modifications done:

Added logout function
No need to pass api url and format every time.