Tons of anthology work with notes and scripts. Updated DE's tamplates. Small script changes as well.
This commit is contained in:
34
Scripts/API_Tests/get_course_ids.py
Normal file
34
Scripts/API_Tests/get_course_ids.py
Normal file
@ -0,0 +1,34 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user