-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgetFood2ForkRecipes.py
More file actions
29 lines (25 loc) · 865 Bytes
/
getFood2ForkRecipes.py
File metadata and controls
29 lines (25 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import requests
#My Food2Fork Free API. 500 calls per 24 hours
api_key = 'f1a8d378f3d9b5a736f810d9847069c8'
final_output = []
def findRecipes(search, numOfPages):
#TODO: Add pagination
#Currently only returns top thirty recipes.
found_recipes = []
for num in range (1, (int(numOfPages) + 1)):
numString = str(num)
url = 'http://food2fork.com/api/search?key=' + api_key + '&q=' + search + '&page=' + numString
url = url.replace(' ','%20')
print(url)
res = requests.get(url)
recipes = (res.json())['recipes']
print(recipes)
found_recipes.append(recipes)
return found_recipes
def getRecipe(recipe_id):
url = 'http://food2fork.com/api/get?key=' + api_key + '&rId=' + recipe_id
#Debug
print(url)
res = requests.get(url)
recipe = res.json()
return recipe