import requests import Apikeys apiKey = Apikeys.bigideas groups_dict = {} def get_groups(apiKey): count = 0 groups = [] while True: count += 1 url = f"https://api.northpass.com/v2/groups?page={count}" headers = {"accept": "application/json", "X-Api-Key": apiKey} response = requests.get(url, headers=headers) data = response.json() nextlink = data["links"] for response in data["data"]: created_at = response["attributes"]["created_at"] if created_at.startswith("2023"): group_id = response["id"] group_name = response["attributes"]["name"] # print(group_name) groups_dict = { "id": group_id, "name": group_name, "created_at": created_at, } groups.append(groups_dict) if "next" not in nextlink: break print(groups) print(len(groups)) if __name__ == "__main__": get_groups(apiKey)