-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnotion.py
51 lines (37 loc) · 1 KB
/
notion.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Notion Application
import json, requests
file = open('SECRET.json') # Opens the file
data = json.load(file) # loads the data then stores in variable called data
# Secret here:
secret = data['id']
# Database information here:
database = data['database_tasks']
file.close() # close file
url = 'https://api.notion.com/v1/pages'
# Headers
headers = {
'Authorization': f'Bearer {secret}',
'Content-Type': 'application/json',
'Notion-Version': '2021-08-16'
}
# Data input
data_input = {
"parent": { "database_id": f"{database}" },
"properties": {
"Name": {
"title": [
{
"text": {
"content": "Yurts in Big Sur, California"
},
"multi_select": {
"content": "Yurts in Big Sur, California"
}
}
]
}
}
}
# check request
response = requests.post(url, headers=headers, json=data_input)
print(response.json())