File tree Expand file tree Collapse file tree 2 files changed +37
-26
lines changed Expand file tree Collapse file tree 2 files changed +37
-26
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import requests
2
+ import json
3
+ import config
4
+
5
+ #################################
6
+ # This script is used to fetch data from shelterluv API.
7
+ # Please be mindful of your usage.
8
+ # example: /people will fetch the data of all people. and send approximately 300 requests.
9
+ # https://help.shelterluv.com/hc/en-us/articles/115000580127-Shelterluv-API-Overview
10
+ #################################
11
+
12
+ ######## Insights ###############
13
+ # Max result items is 100 - even though it's not specifically specified in the above reference
14
+ # /people has all the data. it seems that /person/:id isn't used
15
+ #################################
16
+
17
+ shelterluv_token = "replace_with_secret_token" #dropbox
18
+
19
+
20
+ ''' Iterate over all shelterlove people and store in json file in the raw data folder
21
+ We fetch 100 items in each request, since that is the limit based on our research '''
22
+ def save_shelterluv_people_all ():
23
+ offset = 0
24
+ LIMIT = 100
25
+ has_more = True
26
+ shelterluv_people = []
27
+
28
+ while has_more :
29
+ r = requests .get ("http://shelterluv.com/api/v1/people?limit={}&offset={}" .format (LIMIT , offset ),
30
+ headers = {"x-api-key" : shelterluv_token })
31
+ response = r .json ()
32
+ shelterluv_people += response ["people" ]
33
+ has_more = response ["has_more" ]
34
+ offset += 100
35
+
36
+ with open (config .RAW_DATA_PATH + "shelterLuv_people.json" , "w" ) as outfile :
37
+ json .dump (shelterluv_people , outfile , indent = 4 )
You can’t perform that action at this time.
0 commit comments