Notion API: Notion API, select all pages with a specific emoji

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


Here’s something I used to select all subpages of a Notion page that used a specific emoji icon:

const notion = new Client({ auth: process.env.NOTION_API_KEY })
const pageId = process.env.NOTION_PAGE_ID

async function getAllSubpagesOfPage(page, notion) {
  const pages = []

  const blocks = await notion.blocks.children.list({
    block_id: page.id,
  })
  for (const block of blocks.results) {
    if (block.type === 'child_page') {
      //we need to add icons to the block because 
			//it's not provided by default
      const temp = await notion.pages.retrieve({ page_id: block.id })
      block.icon = temp.icon
      pages.push(block)
    }
  }

  return pages
}

const pages = await getAllSubpagesOfPage(page, notion)

pages.map(async (page) => {
  if (page.icon?.emoji === '✅') {
    //ok the page has that emoji
  }
})

Lessons in this unit:

0: Introduction
1: Notion API, how to retrieve the entries in a database
2: ▶︎ Notion API, select all pages with a specific emoji
3: Notion API, update a checkbox value in a database
4: Notion API, update the icon emoji of a page