찬찬의 Notion API 정복기 23 - API 집중분석 - List all users & Retrieve your token's bot user

소찬 (Chan)·2022년 12월 21일
0
post-thumbnail

Reference URL : List all users, Retrieve your token's bot user

API Bot 이 조회할수 있는 전체 유저를 조회하는 명령이 있습니다.

user_list = notion.users.list()

물론 page_sizestart_cursor를 지원합니다.
하기와 같이 has_moreTrue 일 경우, next_cursor 를 다음 start_cursor로 입력하여 다음 목록결과를 조회하시면 됩니다.

{'has_more': True,
 'next_cursor': 'a75f4717-6a45-4c2b-acec-38b6f3b752f0',
 'object': 'list',
 'results': [{'avatar_url': 'https://s3-us-west-2.amazonaws.com/public.notion-static.com/xxxx/profile.jpeg',
              'id': 'df4a9e4f-bb7d-4b69-a196-c79bf171a484', ...
  • start_cursor (string)
    If supplied, this endpoint will return a page of results starting after the cursor provided. If not supplied, this endpoint will return the first page of results.
    search 명령어로 최대 조회해올 수 있는 건이 총 100건입니다. 100건이 초과되는 경우, 응답값에 "has_more" : True"next_cursor": "{고유 id}"를 보냅니다. next_cursor 를 참조해서 start_cursor를 입력시키면, 101번째부터 그 이후의 결과를 search 해오실 수 있습니다.

  • page_size (int32)
    The number of items from the full list desired in the response. Maximum: 100
    한번에 몇 건을 조회에 올지 정하실 수 있습니다. 입력을 따로 안할시에는 최대 100건을 조회해 옵니다.

Retrieve your token's bot user는 bot user의 정보를 리턴합니다. 별도의 parameter 값이 존재하지 않습니다.

bot_info = notion.users.me()
pprint(bot_info)

bot_info를 표기한 결과입니다.

{'avatar_url': 'https://s3-us-west-2.amazonaws.com/public.notion-static.com/xxxx/summer.gif',
 'bot': {'owner': {'type': 'workspace', 'workspace': True}},
 'id': '4666301e-ddb5-45de-b2f9-88eec463052b',
 'name': 'ChanChan Test Bot',
 'object': 'user',
 'type': 'bot'}
profile
QA Specialist

0개의 댓글