Implementation of API to fetch data. Merge conflicts
Fix error on closing functino