Skip to content

Instantly share code, notes, and snippets.

@prakhar21
Created May 27, 2018 11:21
Show Gist options
  • Save prakhar21/19182a22dee00d108b4ac636a95f1d86 to your computer and use it in GitHub Desktop.
Save prakhar21/19182a22dee00d108b4ac636a95f1d86 to your computer and use it in GitHub Desktop.
Get Collection ids.
#!/usr/bin/env python
import requests
import config
import get_cityids
def run():
collection_id = {}
'''calling city id'''
city_id_mappings = get_cityids.run()
for city, id_ in city_id_mappings.items():
parameters = {'city_id': id_}
header = {"user-key":config.APP_KEY}
response = requests.get(
config.COLLECTIONS_API,
params=parameters,
headers=header
)
collection = response.json().get('collections')
temp = []
for cid in collection:
temp.append(cid.get('collection').get('collection_id'))
collection_id[city] = {'id': id_, 'collection': temp}
return collection_id
if __name__ == '__main__':
collection_ids = run()
print collection_ids
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment