Edits history of script submission #23068 for ' Retrieve Page (notion)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Retrieve Page
     * 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.
     */
    export async function main(
      auth: RT.Notion,
      page_id: string,
      filter_properties: string[] | undefined
    ) {
      const url = new URL(`https://api.notion.com/v1/pages/${page_id}`)
      for (const p of filter_properties ?? []) {
        if (p !== "") url.searchParams.append("filter_properties", p)
      }
    
      const response = await fetch(url, {
        headers: {
          Authorization: `Bearer ${auth.token}`,
          Accept: "application/json",
          "Notion-Version": "2026-03-11",
        },
      })
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 4 days ago