import requests from urllib.request import urlretrieve # Test for Chubb APIKEY = "RFzu130s451F2eKgm45Ck7gyWZMvGToR6Lmf2k5V" EXTRACT = "47156f3d-277a-4c98-b2ba-732ae364270c" FILEID = "cpxFPY" HEADERS = { "accept": "application/json", "x-api-key": APIKEY } def get_latest_extract(): url = f"https://analytics.northpass.io/extracts/{EXTRACT}/files/latest" resp = requests.get(url, headers=HEADERS) print(resp.text) data = resp.json() print(data) def get_info_and_download(): url = f"https://analytics.northpass.io/extracts/{EXTRACT}/files/{FILEID}/download" resp = requests.get(url, headers=HEADERS) data = resp.json() print(data['url']) urlretrieve(data['url'], 'Chubb_MCA.csv.gz') if __name__ == "__main__": get_info_and_download()