<aside> 👉

Links (Block base class)

Page

Block

CalloutBlock

DividerBlock

Heading1Block

ImageBlock

ParagraphBlock

TableOfContentsBlock

ToggleHeading2Block

Database

BookmarkBlock

CodeBlock

EmbedBlock

Heading2Block

LinkPreviewBlock

PdfBlock

ToDoBlock

ToggleHeading3Block

DataSource 🆕

BreadcrumbBlock

ColumnBlock

EquationBlock

Heading3Block

LinkToPageBlock

QuoteBlock

ToggleBlock

ToggleHeading4Block

List

BulletedListItemBlock

ColumnListBlock

FileBlock

Heading4Block

NumberedListItemBlock

SyncedBlock

ToggleHeading1Block

VideoBlock

Notion Ruby Mapping Public API Reference

</aside>

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>''' \\
#   -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
# => 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 dry_run: true
# #!/bin/sh
# curl -X PATCH '<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(template_page: nil, markdown: nil) { |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.

By setting the template_page option, you can apply a template when creating a page. The value is either the string "default" or a Page object of the retrieved template page.

page = 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
# => #<NotionRubyMapping::Page:...> # Page object generated from response from Notion (created Page)