Skip to main content

Method

client.dataSources.retrieve(parameters: GetDataSourceParameters): Promise<DataSourceObjectResponse | PartialDataSourceObjectResponse>
Retrieves a data source object using its ID.

Parameters

data_source_id
string
required
The ID of the data source to retrieve (with or without dashes)
auth
string
Bearer token for authentication. Overrides the client-level auth if provided.

Response

Returns a DataSourceObjectResponse or PartialDataSourceObjectResponse.
object
string
Always "data_source"
id
string
The unique identifier of the data source
title
RichTextItemResponse[]
The title of the data source
description
RichTextItemResponse[]
The description of the data source
parent
object
The parent of the data source. Can be a database or another data source.
parent.type
string
Either "database_id" or "data_source_id"
parent.database_id
string
The ID of the parent database (when type is database_id)
parent.data_source_id
string
The ID of the parent data source (when type is data_source_id)
database_parent
object
The parent of the data source’s containing database. This is typically a page, block, or workspace.
properties
Record<string, DatabasePropertyConfigResponse>
The property schema of the data source
is_inline
boolean
Whether the data source is inline
archived
boolean
Whether the data source is archived
in_trash
boolean
Whether the data source is in the trash
created_time
string
ISO 8601 timestamp when the data source was created
last_edited_time
string
ISO 8601 timestamp when the data source was last edited
created_by
PartialUserObjectResponse
The user who created the data source
last_edited_by
PartialUserObjectResponse
The user who last edited the data source
icon
PageIconResponse | null
The icon of the data source
cover
PageCoverResponse | null
The cover image of the data source
url
string
The Notion URL of the data source
public_url
string | null
The public URL of the data source if it is publicly accessible

Example

import { Client } from "@notionhq/client"

const notion = new Client({ auth: process.env.NOTION_API_KEY })

const dataSource = await notion.dataSources.retrieve({
  data_source_id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
})

console.log("Data Source:", dataSource.title)
console.log("Properties:", Object.keys(dataSource.properties))
console.log("Created:", dataSource.created_time)

Error Handling

try {
  const dataSource = await notion.dataSources.retrieve({
    data_source_id: "invalid-id"
  })
} catch (error) {
  if (error.code === "object_not_found") {
    console.error("Data source not found")
  } else if (error.code === "unauthorized") {
    console.error("No access to this data source")
  } else {
    console.error("Error retrieving data source:", error.message)
  }
}

Build docs developers (and LLMs) love