Get a database, including the IDs of its data sources.
1
//native
2
3
/**
4
* Retrieve Database
5
* Get a database by the ID in its URL. Its `data_sources` list gives the data source IDs that Query Data Source and Create Page need.
6
*/
7
export async function main(auth: RT.Notion, database_id: string) {
8
const response = await fetch(
9
`https://api.notion.com/v1/databases/${database_id}`,
10
{
11
headers: {
12
Authorization: `Bearer ${auth.token}`,
13
Accept: "application/json",
14
"Notion-Version": "2026-03-11",
15
},
16
}
17
)
18
19
if (!response.ok) {
20
throw new Error(`${response.status} ${await response.text()}`)
21
22
23
return await response.json()
24
25