get when you already have a page ID, and getFirst when you have a property
such as a slug. Both return the page’s properties and Markdown content.
Database and property names below come from your generated schema.
Fetch by ID
An ID identifies a particular page. Use it for links that should keep working when a title or slug changes.get returns an error. The SDK does not turn it into
an empty page.
Fetch by a property
A property lookup finds a page that matches your site’s rule. For example, find a published post by its slug:post is null when nothing matches. Your application can use that result to
show a 404. A failed request is an error, not a missing page.
getFirst is available in NotCMS 0.5.0 and later. Upgrade the notcms package before using it.Decide which match to use
where and sort work like list(). If several pages match,
getFirst returns the first one in that order; it does not enforce uniqueness.
Handle the result
Types are inferred from the generated schema. Check
error before using the
page; for getFirst, also handle null. See errors and rate limits
for retry decisions.
Request and ordering details
Request and ordering details
getFirstsends one list request withlimit=1&include=content, so only the first match and its content are transferred.- Like
list,getFirstreturns content already synchronized into NotCMS. Unlikeget, it does not contact Notion, so changes after the last synchronization, such as a page that is no longer accessible, appear after the next sync. - With no sort, or when sort values tie, ordering uses registration order followed by page ID.
- The optional third tuple value is the list response on success or no match, or the failed response on error. It is
undefinedfor a network failure. The SDK does not retry automatically.