2023-01-30 17:27:36 -05:00
|
|
|
import requests
|
2023-01-31 16:24:35 -05:00
|
|
|
import pandas as pd
|
2023-01-30 17:27:36 -05:00
|
|
|
|
|
|
|
|
apiKey = "HWxj6VTNPwbc3WghFTPzr7SjE"
|
|
|
|
|
# Wild Health
|
|
|
|
|
groupid = "504c4771-223a-447f-9ec6-08e51bc9ca23"
|
|
|
|
|
groupurl = f"https://api.northpass.com/v2/groups/{groupid}/memberships"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getemailsfromGroup(apiKey, groupid, groupurl):
|
|
|
|
|
x = 0
|
2023-01-31 16:24:35 -05:00
|
|
|
emaillist = []
|
2023-01-30 17:27:36 -05:00
|
|
|
while True:
|
|
|
|
|
x += 1
|
2023-01-31 16:24:35 -05:00
|
|
|
url = f"https://api.northpass.com/v2/groups/{groupid}/memberships?page={x}"
|
2023-01-30 17:27:36 -05:00
|
|
|
headers = {"accept": "application/json", "X-Api-Key": apiKey}
|
|
|
|
|
response = requests.get(url, headers=headers)
|
|
|
|
|
jsonResponse = response.json()
|
|
|
|
|
next = jsonResponse["links"]
|
|
|
|
|
|
2023-01-31 16:24:35 -05:00
|
|
|
for emails in jsonResponse["included"]:
|
|
|
|
|
email = emails["attributes"]["email"]
|
|
|
|
|
print(email)
|
|
|
|
|
emaillist.append(email)
|
2023-01-30 17:27:36 -05:00
|
|
|
|
|
|
|
|
if "next" not in next:
|
|
|
|
|
break
|
2023-01-31 16:24:35 -05:00
|
|
|
print(emaillist)
|
|
|
|
|
pd.DataFrame(emaillist).to_csv('/Users/normrasmussen/Downloads/emails_in_group.csv')
|
2023-01-30 17:27:36 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
getemailsfromGroup(apiKey, groupid, groupurl)
|