Main functionality for the data API