0

Retrieve Page

by
Published Jun 6, 2022

Get a page's properties, icon, parent and trash state.

Script notion Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 4 days ago
1
//native
2

3
/**
4
 * Retrieve Page
5
 * Get a page's properties (title, database columns, icon, parent, trash state). Its content is not included — use Get Page as Markdown or Retrieve Block Children.
6
 */
7
export async function main(
8
  auth: RT.Notion,
9
  page_id: string,
10
  filter_properties: string[] | undefined
11
) {
12
  const url = new URL(`https://api.notion.com/v1/pages/${page_id}`)
13
  for (const p of filter_properties ?? []) {
14
    if (p !== "") url.searchParams.append("filter_properties", p)
15
  }
16

17
  const response = await fetch(url, {
18
    headers: {
19
      Authorization: `Bearer ${auth.token}`,
20
      Accept: "application/json",
21
      "Notion-Version": "2026-03-11",
22
    },
23
  })
24

25
  if (!response.ok) {
26
    throw new Error(`${response.status} ${await response.text()}`)
27
  }
28

29
  return await response.json()
30
}
31

Other submissions
  • Submitted by adam186 Deno
    Created 517 days ago
    1
    import { Client } from "npm:@notionhq/client";
    2
    
    
    3
    /**
    4
     * Learn more at
    5
     * https://developers.notion.com/reference/retrieve-a-page
    6
     */
    7
    type Notion = {
    8
      token: string;
    9
    };
    10
    export async function main(
    11
      auth: Notion,
    12
      page_id: string,
    13
      filter_properties?: string[],
    14
    ) {
    15
      const client = new Client({ auth: auth.token });
    16
      if (!filter_properties?.filter(Boolean).length) {
    17
        filter_properties = undefined;
    18
      }
    19
      return await client.pages.retrieve({
    20
        page_id,
    21
        filter_properties,
    22
      });
    23
    }
    24
    
    
  • Submitted by hugo989 Bun
    Created 125 days ago
    1
    import { Client } from "@notionhq/client";
    2
    
    
    3
    /**
    4
     * Learn more at
    5
     * https://developers.notion.com/reference/retrieve-a-page
    6
     */
    7
    type Notion = {
    8
      token: string;
    9
    };
    10
    export async function main(
    11
      auth: Notion,
    12
      page_id: string,
    13
      filter_properties?: string[],
    14
    ) {
    15
      const client = new Client({ auth: auth.token });
    16
      if (!filter_properties?.filter(Boolean).length) {
    17
        filter_properties = undefined;
    18
      }
    19
      return await client.pages.retrieve({
    20
        page_id,
    21
        filter_properties,
    22
      });
    23
    }
    24