Spaces:
Sleeping
Sleeping
File size: 687 Bytes
ce889fc |
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 |
import requests
import json
import random
url = "https://api.notion.com/v1/databases/180f4b492f4d421c88028c54cfe077a5/query"
payload = json.dumps({
"filter": {
"property": "Weekly Rotation",
"checkbox": {
"equals": True
}
}
})
headers = {
'Authorization': 'Bearer secret_oG3PIzAL10np4NadmID4X93ISNJP7zHBr6CQ8Oskakb',
'Content-Type': 'application/json',
'Notion-Version': '2022-02-22'
}
response = requests.request("POST", url, headers=headers, data=payload)
recipes = response.json()
n_recipes = 10
for recipe in random.sample(recipes['results'], n_recipes):
print(recipe["properties"]["Name"]["title"][0]["plain_text"].strip())
print(recipe["url"]) |