2023-11-07 16:57:58 -05:00
|
|
|
import pprint
|
|
|
|
|
import json
|
2023-05-17 12:30:27 -04:00
|
|
|
import requests
|
|
|
|
|
import Apikeys
|
|
|
|
|
|
2023-11-07 16:57:58 -05:00
|
|
|
APIKEY = Apikeys.ANTHOLOGY
|
2023-05-17 12:30:27 -04:00
|
|
|
groups_dict = {}
|
2023-11-07 16:57:58 -05:00
|
|
|
pp = pprint.PrettyPrinter(indent=4)
|
2023-05-17 12:30:27 -04:00
|
|
|
|
|
|
|
|
|
2023-11-07 16:57:58 -05:00
|
|
|
def get_groups(APIKEY):
|
2023-05-17 12:30:27 -04:00
|
|
|
count = 0
|
|
|
|
|
groups = []
|
|
|
|
|
|
|
|
|
|
while True:
|
|
|
|
|
count += 1
|
|
|
|
|
url = f"https://api.northpass.com/v2/groups?page={count}"
|
2023-11-07 16:57:58 -05:00
|
|
|
headers = {"accept": "application/json", "X-Api-Key": APIKEY}
|
2023-05-17 12:30:27 -04:00
|
|
|
response = requests.get(url, headers=headers)
|
|
|
|
|
data = response.json()
|
|
|
|
|
nextlink = data["links"]
|
|
|
|
|
|
|
|
|
|
for response in data["data"]:
|
2024-01-04 16:51:28 -05:00
|
|
|
# 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 = {
|
|
|
|
|
group_name : group_id
|
|
|
|
|
}
|
|
|
|
|
groups.append(groups_dict)
|
2023-05-17 12:30:27 -04:00
|
|
|
|
|
|
|
|
if "next" not in nextlink:
|
|
|
|
|
break
|
|
|
|
|
|
2023-11-17 17:18:13 -05:00
|
|
|
pp.pprint(groups)
|
|
|
|
|
print(len(groups))
|
|
|
|
|
# with open('/Users/normrasmussen/Documents/Work/CustomerNotes/Anthology/antho-groups.json', 'w') as jsn:
|
|
|
|
|
# json.dump(groups, jsn)
|
2023-05-17 12:30:27 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-11-07 16:57:58 -05:00
|
|
|
get_groups(APIKEY)
|