A general function that takes a JSON file with API request and outputs a csv