import Apikeys import requests APIKEY = Apikeys.ANTHOLOGY HEADERS = { "accept": "application/json", "X-Api-Key": APIKEY, } def get_courses(): """ Function to get courses and their IDs """ count = 0 list_of_ids = [] while True: count += 1 url = f"https://api.northpass.com/v2/courses/?limit=100&page={count}" response = requests.get(url, headers=HEADERS) response = response.json() nextlink = response["links"] for item in response["data"]: id = item["id"] name = item["attributes"]["name"] list_of_ids.append(id) if "next" not in nextlink: break print(list_of_ids) if __name__ == "__main__": get_courses()