Made the API functions handle both collection and item requests.