1. Class methods

self.find(id, dry_run: false)

DataSource.find(id) creates a DataSource object with retrieving data source API. The created object has data source information generated from the JSON response.

ds = DataSource.find "26cd8e4e98ab81d08983000b28d9e04d" # Notion API call
# => NotionRubyMapping::DataSource-26cd8e4e98ab81d08983000b28d9e04d # retrieved DataSource object

DataSource.find id, dry_run: true creates shell script using Retrieve a data source API for verification.

print DataSource.find "26cd8e4e98ab81d08983000b28d9e04d", dry_run: true
# #!/bin/sh
# curl -X GET '[<https://api.notion.com/v1/data_sources/26cd8e4e98ab81d08983000b28d9e04d>](<https://api.notion.com/v1/data_sources/26cd8e4e98ab81d08983000b28d9e04d>)''' \\
#   -H 'Notion-Version: 2025-09-03' \\
#   -H 'Authorization: Bearer '"$NOTION_API_KEY"''
# => nil

2. Instance methods

add_property(klass, title)

add_property adds a data source property. After setting the property, please call ds.save to send data source information to Notion.

ds = DataSource.find "26cd8e4e98ab81d08983000b28d9e04d" # Notion API call
ds.add_property NumberProperty, "added number property" do |np|
  np.format = "euro" # arrange option
end
ds.add_property UrlProperty, "added url property" # UrlProperty has no option
[ds.save](<http://ds.save>)
# => NotionRubyMapping::DataSource-26cd8e4e98ab81d08983000b28d9e04d

[ds.save](<http://ds.save>) dry_run: true creates a shell script for verification (Update data source API using data_source_id as parent)

ds = DataSource.find "26cd8e4e98ab81d08983000b28d9e04d" # Notion API call
ds.add_property NumberProperty, "added number property" do |np|
  np.format = "euro" # arrange option
end
ds.add_property UrlProperty, "added url property" # UrlProperty has no option
print [ds.save](<http://ds.save>) dry_run: true
# #!/bin/sh
# curl -X PATCH '[<https://api.notion.com/v1/data_sources/26cd8e4e98ab81d08983000b28d9e04d>](<https://api.notion.com/v1/data_sources/26cd8e4e98ab81d08983000b28d9e04d>)''' \\
#   -H 'Notion-Version: 2025-09-03' \\
#   -H 'Authorization: Bearer '"$NOTION_API_KEY"'' \\
#   -H 'Content-Type: application/json' \\
#   --data '{"properties":{"added number property":{"number":{"format":"euro"}},"added url property":{"url":{}}}}'
# => nil

build_child_page { |p, pc| ... } → Page

build_child_page creates a child page object of the data source. After setting some properties, please call page.save to send page information to Notion. Properties of the created child page are automatically assigned using the parent data source. If a block is provided, the method will yield the new Page object (p) and the properties (PropertyCache object pc) to that block for initialization.

page = [ds.build](<http://ds.build>)_child_page do |p, pc|
  # p is the new Page object
  # pc is the properties of the new Page object (PropertyCache Object)
  p.set_icon emoji: "🎉"
  pc["Title"] << "New Page"
end
[page.save](<http://page.save>)
# => #<NotionRubyMapping::Page:...> # Page object generated from response from Notion (created Page)

[page.save](<http://page.save>) dry_run: true creates a shell script for verification (Create a page API using data_source_id as parent)

page = [ds.build](<http://ds.build>)_child_page(dry_run: true) do |p, pc|
  p.set_icon emoji: "🎉"
  pc["Title"] << "New Page"
end
print [page.save](<http://page.save>) dry_run: true
# #!/bin/sh
# curl -X POST '[<https://api.notion.com/v1/pages>](<https://api.notion.com/v1/pages>)''' \\
#   -H 'Notion-Version: 2025-09-03' \\
#   -H 'Authorization: Bearer '"$NOTION_API_KEY"'' \\
#   -H 'Content-Type: application/json' \\
#   --data '{"parent":{"data_source_id":"26cd8e4e98ab81d08983000b28d9e04d"}}'
# => nil

create_child_page(dry_run: false) { |p, pc| ... } → Page

create_child_page creates a child page object of the data source and send to Notion. Properties of the created child page are automatically assigned using the parent data source. If a block is provided, the method will yield the new Page object (p) and the properties (PropertyCache object pc) to that block for initialization.

page = ds.create_child_page do |p, pc|
  # p is the new Page object
  # pc is the properties of the new Page object (PropertyCache Object)
  p.set_icon emoji: "🎉"
  pc["Title"] << "New Page"
end
# => #<NotionRubyMapping::Page:...> # Page object generated from response from Notion (created Page)

create_child_page dry_run: true creates a shell script for verification (Create a page API using data_source_id as parent)

print ds.create_child_page dry_run: true do |p, pc|
  p.set_icon emoji: "🎉"
  pc["Title"] << "New Page"
end
# #!/bin/sh
# curl -X POST '[<https://api.notion.com/v1/pages>](<https://api.notion.com/v1/pages>)''' \\
#   -H 'Notion-Version: 2025-09-03' \\
#   -H 'Authorization: Bearer '"$NOTION_API_KEY"'' \\
#   -H 'Content-Type: application/json' \\
#   --data '{"parent":{"data_source_id":"26cd8e4e98ab81d08983000b28d9e04d"}}'
# => nil

created_time → CreatedTimeProperty