0

Retrieve Page Property Item

by
Published today

Get one property value of a page, paginated for long title, text, relation, people and rollup properties.

Script notion Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 3 hours ago
1
//native
2

3
/**
4
 * Retrieve Page Property Item
5
 * Get one property of a page by property ID (from Retrieve Page's `properties.<name>.id`). Title, rich text, relation and people properties come back as a paginated list of items: use it when Retrieve Page truncates them past 25 references. Paginate with `next_cursor` as `start_cursor`.
6
 */
7
export async function main(
8
  auth: RT.Notion,
9
  page_id: string,
10
  property_id: string,
11
  start_cursor: string | undefined,
12
  page_size: number | undefined
13
) {
14
  const url = new URL(
15
    `https://api.notion.com/v1/pages/${page_id}/properties/${encodeURIComponent(property_id)}`
16
  )
17
  if (start_cursor !== undefined && start_cursor !== "") {
18
    url.searchParams.append("start_cursor", start_cursor)
19
  }
20
  if (page_size !== undefined) {
21
    url.searchParams.append("page_size", String(page_size))
22
  }
23

24
  const response = await fetch(url, {
25
    headers: {
26
      Authorization: `Bearer ${auth.token}`,
27
      Accept: "application/json",
28
      "Notion-Version": "2026-03-11",
29
    },
30
  })
31

32
  if (!response.ok) {
33
    throw new Error(`${response.status} ${await response.text()}`)
34
  }
35

36
  return await response.json()
37
}
38