//native
/**
* Get Page as Markdown
* Get a page's content as Notion-flavored Markdown. If `truncated` is true, fetch each ID in `unknown_block_ids` the same way to get the missing subtrees.
*/
export async function main(
auth: RT.Notion,
page_id: string,
include_transcript: boolean = false
) {
const url = new URL(`https://api.notion.com/v1/pages/${page_id}/markdown`)
if (include_transcript) {
url.searchParams.append("include_transcript", "true")
}
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 hours ago