본문 바로가기
개발 상식 & Tip!

노션 API 필터링 방법 정리

by saramnim 2024. 1. 16.
728x90

기본적인 사용 방법은 아래에 나와있다.
https://developers.notion.com/reference/post-database-query

 

Query a database

Gets a list of Pages and/or Databases contained in the database, filtered and ordered according to the filter conditions and sort criteria provided in the request. The response may contain fewer than page_size of results. If the response includes a next_cu

developers.notion.com

다만 위의 방법만으로는 헷갈리는 사람들이 많을 것이다.

 

http://api/notion/query?database_id=사용할DB의ID

여기서 사용할 DB의 ID는 노션 DB의 점 세 개 아이콘을 누른 후, 보기 링크 복사를 누르면,

https://www.notion.so/DB의ID?v=뭔가다른거

위의 주소에서 DB의ID라 쓰여진 /부터 ?전까지의 자리에 위치한 것이 DB의 ID이다.

// const filterConditions = []

      // // 프로젝트 필터
      // if (params.프로젝트 !== null) {
      //   filterConditions.push({
      //     property: '프로젝트',
      //     relation: {
      //       contains: params.프로젝트,
      //     },
      //   })
      // }

      // // 담당자 필터
      // if (params.담당자 !== null) {
      //   filterConditions.push({
      //     property: '담당자',
      //     people: {
      //       contains: params.담당자,
      //     },
      //   })
      // }

      // // 계획일자 필터
      // if (params.계획일자 !== null) {
      //   filterConditions.push({
      //     property: '계획일자',
      //     date: {
      //       on_or_after: params.planStart,
      //     },
      //   })
      //   filterConditions.push({
      //     property: '계획일자',
      //     date: {
      //       on_or_before: params.planEnd,
      //     },
      //   })
      // }
728x90
반응형

댓글

"이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다."