API - Basic API calls

take a look at line 96. Try to make code have the same pattern because you will be able to see common patterns and create a generic function to reuse in multiple API calls (read my very last comment to get also more ideas)