Notion Ruby Mapping Public API Reference

<aside> 💡

[P] means methods for Page Property, [DB/DS] means methods for Database or DataSource Property, and [DS] means methods for DataSource Property only.

</aside>

Property is the abstract base class of all property classes such as TitleProperty and CheckboxProperty. It keeps the property name, the raw JSON body, the update flag, and the base type (Page, Database, or DataSource), and provides the API shared by all property classes.

Property is not instantiated directly. Property objects are obtained from Page#properties, Database#properties, DataSource#properties, or Property.create_from_json.

1. Class methods

Property.create_from_json(name, input_json, base_type = "page", property_cache = nil, query = nil) → Property

  1. create_from_json creates the property object that matches the type of the given JSON.
  2. When the JSON is a Retrieve a page property item response ("type" => "property_item"), the results are expanded through List before the property object is created. people, relation, rich_text, rollup, and title are supported in this form.
  3. When a relation Page property returns "has_more" => true, the property item list is retrieved again so that all relations are included.
  4. It raises StandardError in the three cases below.
Property.create_from_json "np", nil
# => ...:in `create_from_json': Property not found: np: (StandardError)

Property.create_from_json "np", {"id" => "SQeZ"}
# => ...:in `create_from_json': Property value is not returned: np (StandardError)

Property.create_from_json "np", {"id" => "SQeZ", "type" => "brand_new", "brand_new" => {}}
# => ...:in `create_from_json': Unsupported property type: brand_new (np). Please update notion_ruby_mapping. (StandardError)

2. Instance methods