API function to get datasets as JSON