diff --git a/Scripts/API_Tests/__pycache__/Apikeys.cpython-311.pyc b/Scripts/API_Tests/__pycache__/Apikeys.cpython-311.pyc index 485cc67e..4de73c57 100644 Binary files a/Scripts/API_Tests/__pycache__/Apikeys.cpython-311.pyc and b/Scripts/API_Tests/__pycache__/Apikeys.cpython-311.pyc differ diff --git a/Scripts/API_Tests/get_category_ids.py b/Scripts/API_Tests/get_category_ids.py new file mode 100644 index 00000000..15fe18ba --- /dev/null +++ b/Scripts/API_Tests/get_category_ids.py @@ -0,0 +1,31 @@ +import requests +import Apikeys +import csv +import time +import os + +apikey = Apikeys.walmartprod +cmd = "touch ~/Downloads/Spark_Categories.csv" + +os.system(cmd) +url = "https://api2.northpass.com/v2/categories?limit=100" +headers = { + "accept": "application/json", + "X-Api-Key" : apikey, +} +response = requests.get(url, headers=headers) +response = response.json() + +for item in response['data']: + id = item['id'] + name = item['attributes']['name'] + with open('/Users/normrasmussen/Downloads/Spark_Categories.csv', 'a', newline='') as csvfile: + writer = csv.writer(csvfile, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL) + writer.writerow([name, id,]) + # print(f"Category: {name} and ID: {id}") + +with open('/Users/normrasmussen/Downloads/Spark_Categories.csv', 'r') as readfile: + reader = csv.reader(readfile) + for row in reader: + print(row) +