Skip to content

Instantly share code, notes, and snippets.

Last active January 15, 2017 18:51
What would you like to do?
Checks Apple inventory for availability of any Apple SKU. In this example, AirPods
# If you don't have the requests module, you can download by typing:
# sudo easy_install -U requests
# into the terminal on macOS
# You can change the partnum below with any Apple SKU
import urllib
import json
import requests
def get_status(zipcode):
partnum = "MMEF2AM/A"
print ("Checking AirPods for " + zipcode)
url = "" + (partnum) + "&location=" + zipcode
r = requests.get(url)
json = r.json()
body = json['body']
for store in body['stores']:
status = store['partsAvailability']
print (store['storeName'].ljust(20) + ": " + str(status[partnum]['pickupDisplay']).rjust(20))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment