API code for GetAll and GetByID