Notion API Master Series 03 - properties

소찬 (Chan)·2022년 7월 24일
0
post-thumbnail

The last time for getting title information, we should know the composition of properties. It seems complex than more than we think, so I will explain it detailedly.

properties

classified name and type(select type, multi-select type, input directly, and so on) information are properties like below.

Examples

  • 위치(Location), 플랫폼(Platform), 지역(Zone) -> Classified Name
  • 배달(Delivery), 쿠팡이츠(Coopang Eats), 성수(Seongsu) -> Classified information followed by the classified name

properties returned like as below JSON type.

'properties': {'title': {'id': 'title',
               'title': [{'annotations': {'bold': False,
                                          'code': False,
                                          'color': 'default',
                                          'italic': False,
                                          'strikethrough': False,
                                          'underline': False},
               'href': None,
               'plain_text': '007. '
               '제임스본드'
               '작전'
               '버전 3.0',
               'text': {'content': '007. '
                                   '제임스본드'
                                   '작전'
                                   '버전 '
                                   '3.0',
                        'link': None},
               'type': 'text'}],
               'type': 'title'}} ...

type is the title, then it will be title of page.
If we want to change the title, then change the value plain_text and content of text. For example, it is like below.

title_change = '008. 제임스본드 작전 Plan B'
'properties': {'title': {'id': 'title',
               'title': [{'annotations': {'bold': False,
                                          'code': False,
                                          'color': 'default',
                                          'italic': False,
                                          'strikethrough': False,
                                          'underline': False},
               'href': None,
               'plain_text': title_change,
               'text': {'content': title_change,
                        'link': None},
               'type': 'text'}],
               'type': 'title'}} ...

Then how are other properties composed?
Refer to the link to the Property Object link of the Notion API Document. Then we can find the way how to input it. Let us check one example.

'properties': {'진행여부': {'id': 'SPEi',
                          'select': {'color': 'gray',
                                     'id': '1fa10b33-a0b2-4877-9b4f-bea3eb54bb88',
                                     'name': '진행중'},
                                     'type': 'select'}

Refer above values, and we can get to know that the property name is 진행여부(proceed status).
select is select so we can guess this type is choose one from list.

The inputted value is 진행중(Proceed), and color is grey.
One needs to change values, type, and color and must choose one of the API Document color lists.

For color example, default, gray, brown, orange, yellow, green, blue, purple, pink, red are avaiable. If choice is other color from list, API return error. For instance, I want to choose sky color and fill the value like below.

'properties': {'진행여부': {'select': {'color': 'sky',
                                     'name': '진행중'},
                                     'type': 'select'}

sky is not a supported option, so API returns an error.

profile
QA Specialist

0개의 댓글