<aside> 👉

Links (Block base class)

Page

AudioBlock

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.new(url) → LinkPreviewBlock

$\fbox{implemented in UrlBaseBlock}$

self.new creates an in-memory LinkPreviewBlock object using url. A Link Preview has a URL but does not have a caption.

b = LinkPreviewBlock.new "<https://github.com/example/example-repo/pull/1234>"
b.block_json
# => {"type"=>"link_preview", "object"=>"block", "link_preview"=>{"url"=>"<https://github.com/example/example-repo/pull/1234>"}}

<aside> ⚠️

The Notion API can return link_preview blocks, but does not support creating or appending them. Use Block.find to retrieve an existing Link Preview when working with workspace content.

</aside>

2. Instance methods

save(dry_run: false)

$\fbox{implemented in Block}$

save sends changes made to an existing LinkPreviewBlock through the Update a block API. Retrieve the existing block before updating it because the Notion API does not support creating or appending link_preview blocks.

block = Block.find "link_preview_block_id"
block.url = "<https://github.com/example/example-repo/pull/5678>"
block.save
# => #<NotionRubyMapping::LinkPreviewBlock:...>

With dry_run: true, save returns a verification script. The update payload uses the link_preview key.

block = Block.find "link_preview_block_id"
block.url = "<https://github.com/example/example-repo/pull/5678>"
block.save dry_run: true
# => curl -X PATCH '<https://api.notion.com/v1/blocks/link_preview_block_id>' ...
#    --data '{"link_preview":{"url":"<https://github.com/example/example-repo/pull/5678>"}}'

url → String

$\fbox{implemented in UrlBaseBlock}$

url returns the URL stored in the LinkPreviewBlock.

b = LinkPreviewBlock.new "<https://github.com/example/example-repo/pull/1234>"
b.url
# => "<https://github.com/example/example-repo/pull/1234>"

url=(url)

$\fbox{implemented in UrlBaseBlock}$