{"id":13770515,"url":"https://github.com/danmurphy1217/notion-ruby","last_synced_at":"2025-05-12T03:31:51.917Z","repository":{"id":47255065,"uuid":"307820004","full_name":"danmurphy1217/notion-ruby","owner":"danmurphy1217","description":"Unofficial Notion Client for Ruby.","archived":false,"fork":false,"pushed_at":"2021-09-06T20:41:29.000Z","size":48268,"stargazers_count":70,"open_issues_count":5,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-21T15:56:07.499Z","etag":null,"topics":["notion","notion-api","notion-client","ruby","wrapper"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/notion","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danmurphy1217.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-27T20:28:25.000Z","updated_at":"2024-10-23T07:55:33.000Z","dependencies_parsed_at":"2022-09-01T23:02:40.008Z","dependency_job_id":null,"html_url":"https://github.com/danmurphy1217/notion-ruby","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danmurphy1217%2Fnotion-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danmurphy1217%2Fnotion-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danmurphy1217%2Fnotion-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danmurphy1217%2Fnotion-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danmurphy1217","download_url":"https://codeload.github.com/danmurphy1217/notion-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253668065,"owners_count":21944971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["notion","notion-api","notion-client","ruby","wrapper"],"created_at":"2024-08-03T17:00:38.640Z","updated_at":"2025-05-12T03:31:46.889Z","avatar_url":"https://github.com/danmurphy1217.png","language":"Ruby","readme":"\n\n# Unofficial Notion Client for Ruby.\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/f13e49a8807e4fe297273f48bd8d7a61)](https://app.codacy.com/gh/danmurphy1217/notion-ruby?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=danmurphy1217/notion-ruby\u0026utm_campaign=Badge_Grade)\n[![Build Status](https://travis-ci.com/danmurphy1217/notion-ruby.svg?branch=master)](https://travis-ci.com/danmurphy1217/notion-ruby) [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop-hq/rubocop) [![Gem Version](https://badge.fury.io/rb/notion.svg)](https://badge.fury.io/rb/notion)\n\n- Read the [blog post](https://towardsdatascience.com/introducing-the-notion-api-ruby-gem-d47d4a6ef0ca), which outlines why I built this and some of the functionality.\n- Check out the [Gem](https://rubygems.org/gems/notion)!\n\n## Table of Contents\n- [Unofficial Notion Client for Ruby.](#unofficial-notion-client-for-ruby)\n  - [Table of Contents](#table-of-contents)\n  - [Getting Started](#getting-started)\n    - [Installation](#installation)\n  - [Retrieving a Page](#retrieving-a-page)\n  - [Retrieving a CollectionView Page](#retrieving-a-collectionview-page)\n  - [Retrieving a Block within the Page](#retrieving-a-block-within-the-page)\n    - [Get a Block](#get-a-block)\n    - [Get a Collection View](#get-a-collection-view)\n  - [Creating New Blocks](#creating-new-blocks)\n    - [Create a block whose parent is the page](#create-a-block-whose-parent-is-the-page)\n    - [Create a block whose parent is another block](#create-a-block-whose-parent-is-another-block)\n  - [Creating New Collections](#creating-new-collections)\n  - [Updating Collection View Cells](#updating-collection-view-cells)\n  - [Troubleshooting](#troubleshooting)\n    - [No results returned when attempting to get a page](#no-results-returned-when-attempting-to-get-a-page)\n    - [Retrieve a full-page Collection View](#retrieve-a-full-page-collection-view)\n    - [Linking to another page](#linking-to-another-page)\n\n## Getting Started\n### Installation\nto install the gem:\n```ruby\ngem install notion\n```\nThen, place this at the top of your file:\n```ruby\nrequire 'notion_api'\n```\nTo get started using the gem, you'll first need to retrieve your token_v2 credentials by signing into Notion online, navigating to the developer tools, inspecting the cookies, and finding the value associated with the **token_v2** key.\n\nFrom here, you can instantiate the Notion Client with the following code:\n```ruby\n\u003e\u003e\u003e @client = NotionAPI::Client.new(\"\u003cinsert_v2_token_here\u003e\")\n```\n## Retrieving a Page\nA typical starting point is the `get_page` method, which returns a Notion Page Block. The `get_page` method accepts the ID (formatted or not) or the URL of the page:\n1. URL → https://www.notion.so/danmurphy/TEST-PAGE-d2ce338f19e847f586bd17679f490e66\n2. ID → d2ce338f19e847f586bd17679f490e66\n3. Formatted ID → d2ce338f-19e8-47f5-86bd-17679f490e66\n```ruby\n\u003e\u003e\u003e @client.get_page(\"https://www.notion.so/danmurphy/TEST-PAGE-d2ce338f19e847f586bd17679f490e66\")\n\u003e\u003e\u003e @client.get_page(\"d2ce338f19e847f586bd17679f490e66\")\n\u003e\u003e\u003e @client.get_page(\"d2ce338f-19e8-47f5-86bd-17679f490e66\")\n```\nAll three of these will return the same block instance:\n```ruby\n#\u003cNotionAPI::PageBlock id=\"d2ce338f-19e8-47f5-86bd-17679f490e66\" title=\"TEST\" parent_id=\"\u003comitted\u003e\"\u003e\n```\nThe following attributes can be read from any block class instance:\n1. `id`: the ID associated with the block.\n2. `title`: the title associated with the block.\n3. `parent_id`: the parent ID of the block.\n4. `type`: the type of the block.\n\nTo update the title of the page:\n![Update the title of a page](https://github.com/danmurphy1217/notion-ruby/blob/master/gifs/change_title.gif)\n\n## Retrieving a CollectionView Page\nThis is achieved by passing the ID of the Collection View to the `get_page` method. Currently, the full URL of a Collection View Page is not supported (next up on the features list!). Once you retrieve the Collection View Page, all of the methods exposed to a normal Collection View instance are available (such as `.rows`, `.row(\u003crow_id\u003e)`, and all else outlined in [Updating a Collection](#updating-collection-view-cells)).\n## Retrieving a Block within the Page\nNow that you have retrieved a Notion Page, you have full access to the blocks on that page. You can retrieve a specific block or collection view, retrieve all children IDs (array of children IDs), or retrieve all children (array of children class instances).\n\n### Get a Block\nTo retrieve a specific block, you can use the `get_block` method. This method accepts the ID of the block (formatted or not), and will return the block as an instantiated class instance:\n```ruby\n@page = @client.get_page(\"https://www.notion.so/danmurphy/TEST-PAGE-d2ce338f19e847f586bd17679f490e66\")\n@page.get_block(\"2cbbe0bf-34cd-409b-9162-64284b33e526\")\n#\u003cTextBlock id=\"2cbbe0bf-34cd-409b-9162-64284b33e526\" title=\"TEST\" parent_id=\"d2ce338f-19e8-47f5-86bd-17679f490e66\"\u003e\n```\nAny Notion Block has access to the following methods:\n\n1. `title=` → change the title of a block.\n```ruby\n\u003e\u003e\u003e @block = @client.get_block(\"2cbbe0bf-34cd-409b-9162-64284b33e526\")\n\u003e\u003e\u003e @block.title # get the current title...\n\"TEST\"\n\u003e\u003e\u003e @block.title= \"New Title Here\" # lets update it...\n\u003e\u003e\u003e @block.title\n\"New Title Here\"\n```\nFor example:\n![Update the title of a block](https://github.com/danmurphy1217/notion-ruby/blob/master/gifs/change%20block%20title.gif)\n2. `convert` → convert a block to a different type.\n```ruby\n\u003e\u003e\u003e @block = @client.get_block(\"2cbbe0bf-34cd-409b-9162-64284b33e526\")\n\u003e\u003e\u003e @block.type\n\"text\"\n\u003e\u003e\u003e @new_block = @block.convert(NotionAPI::CalloutBlock)\n\u003e\u003e\u003e @new_block.type\n\"callout\"\n\u003e\u003e\u003e @new_block # new class instance returned...\n#\u003cNotionAPI::CalloutBlock:0x00007ffb75b19ea0 id=\"2cbbe0bf-34cd-409b-9162-64284b33e526\" title=\"New Title Here\" parent_id=\"d2ce338f-19e8-47f5-86bd-17679f490e66\"\u003e\n```\nFor example:\n![Convert a page](https://github.com/danmurphy1217/notion-ruby/blob/master/gifs/change%20to%20todo%2C%20check.gif)\n\n3. `duplicate`→ duplicate the current block.\n```ruby\n\u003e\u003e\u003e @block = @client.get_block(\"2cbbe0bf-34cd-409b-9162-64284b33e526\")\n\u003e\u003e\u003e @block.duplicate # block is duplicated and placed directly after the current block\n\u003e\u003e\u003e @block.duplicate(\"f13da22b-9012-4c49-ac41-6b7f97bd519e\") # the duplicated block is placed after 'f13da22b-9012-4c49-ac41-6b7f97bd519e'\n```\nFor example:\n![Convert a page](https://github.com/danmurphy1217/notion-ruby/blob/master/gifs/duplicate.gif)\n4. `move` → move a block to another location.\n```ruby\n\u003e\u003e\u003e @block = @client.get_block(\"2cbbe0bf-34cd-409b-9162-64284b33e526\")\n\u003e\u003e\u003e @target_block = @client.get_block(\"c3ce468f-11e3-48g5-87be-27679g491e66\")\n\u003e\u003e\u003e @block.move(@target_block) # @block moved to **after** @target_block\n\u003e\u003e\u003e @block.move(@target_block, \"before\") # @block moved to **before** @target_block\n```\nFor example:\n![move a block](https://github.com/danmurphy1217/notion-ruby/blob/master/gifs/move_before_and_after.gif)\n### Get a Collection View\nTo retrieve a collection, you use the `get_collection` method. This method is designed to work with Table collections, but the codebase is actively being updated to support others:\n```ruby\n\u003e\u003e\u003e @page = @client.get_page(\"https://www.notion.so/danmurphy/TEST-PAGE-d2ce338f19e847f586bd17679f490e66\")\n\u003e\u003e\u003e @page.get_collection(\"34d03794-ecdd-e42d-bb76-7e4aa77b6503\")\n#\u003cNotionAPI::CollectionView:0x00007fecd8859770 @id=\"34d03794-ecdd-e42d-bb76-7e4aa77b6503\", @title=\"Car Data\", @parent_id=\"9c50a7b3-9ad7-4f2b-aa08-b3c95f1f19e7\", @collection_id=\"5ea0fa7c-00cd-4ee0-1915-8b5c423f8f3a\", @view_id=\"5fdb08da-0732-49dc-d0c3-2e31fccca73a\"\u003e\n```\nAny Notion Block has access to the following methods:\n1. `row_ids` → retrieve the IDs associated with each row.\n```ruby\n\u003e\u003e\u003e @collection = @page.get_collection(\"34d03794-ecdd-e42d-bb76-7e4aa77b6503\")\n\u003e\u003e\u003e @collection.row_ids\nent.rb\n[\"785f4e24-e489-a316-50cf-b0b100c6673a\", \"78642d95-da23-744c-b084-46d039927bba\", \"96dff83c-6961-894c-39c2-c2c8bfcbfa90\", \"87ae8ae7-5518-fbe1-748e-eb690c707fac\",..., \"5a50bdd4-69c5-0708-5093-b135676e83c1\", \"ff9b8b89-1fed-f955-4afa-5a071198b0ee\", \"721fe76a-9e3c-d348-8324-994c95d77b2e\"]\n```\n2. `rows` → retrieve each Row, returned as an array of TableRowInstance classes.\n```ruby\n\u003e\u003e\u003e @collection = @page.get_collection(\"34d03794-ecdd-e42d-bb76-7e4aa77b6503\")\n\u003e\u003e\u003e @collection.rows\n#\u003cNotionAPI::CollectionViewRow:0x00007ffecca82078 @id=\"785f4e24-e489-a316-50cf-b0b100c6673a\", @parent_id=\"9c50a7b3-9ad7-4f2b-aa08-b3c95f1f19e7\", @collection_id=\"5ea0fa7c-00cd-4ee0-1915-8b5c423f8f3a\", @view_id=\"5fdb08da-0732-49dc-d0c3-2e31fccca73a\"\u003e,..., #\u003cNotionAPI::CollectionViewRow:0x00007ffecca81998 @id=\"fbf44f93-52ee-0e88-262a-94982ffb3fb2\", @parent_id=\"9c50a7b3-9ad7-4f2b-aa08-b3c95f1f19e7\", @collection_id=\"5ea0fa7c-00cd-4ee0-1915-8b5c423f8f3a\", @view_id=\"5fdb08da-0732-49dc-d0c3-2e31fccca73a\"\u003e]\n```\n3. `row(\"\u003crow_id\u003e\")` → retrieve a specific row.\n```ruby\n\u003e\u003e\u003e @collection = @page.get_collection(\"34d03794-ecdd-e42d-bb76-7e4aa77b6503\")\n\u003e\u003e\u003e @collection.row(\"f1c7077f-44a9-113d-a156-90ab6880c3e2\")\n{\"age\"=\u003e[9], \"vin\"=\u003e[\"1C6SRFLT1MN591852\"], \"body\"=\u003e[\"4D Crew Cab\"], \"fuel\"=\u003e[\"Gasoline\"], \"make\"=\u003e[\"Ram\"], \"msrp\"=\u003e[64935], \"year\"=\u003e[2021], \"model\"=\u003e[1500], \"price\"=\u003e[59688], \"stock\"=\u003e[\"21R14\"], \"dealerid\"=\u003e[\"MP2964D\"], \"colour\"=\u003e[\"Bright White Clearcoat\"], \"engine\"=\u003e[\"HEMI 5.7L V8 Multi Displacement VVT\"], \"photos\"=\u003e[\"http://vehicle-photos-published.vauto.com/d0/c2/dd/8b-1307-4c67-8d31-5a301764b875/image-1.jpg\"], \"series\"=\u003e[\"Rebel\"], \"newused\"=\u003e[\"N\"], \"city_mpg\"=\u003e[\"\"],...,\"engine_cylinder_ct\"=\u003e[8], \"engine_displacement\"=\u003e[5.7], \"photos_last_modified_date\"=\u003e[\"11/13/2020 8:16:56 AM\"]}\n```\n\n## Creating New Blocks\nHere's a high-level example:\n![create a callout a block](https://github.com/danmurphy1217/notion-ruby/blob/master/gifs/create.gif)\nThe block types available to the `create` method are:\n1. `DividerBlock`\n2. `TodoBlock`\n3. `CodeBlock`\n4. `HeaderBlock`\n5. `SubHeaderBlock`\n6. `SubSubHeaderBlock`\n7. `PageBlock`\n8. `ToggleBlock`\n9. `BulletedBlock`\n10. `NumberedBlock`\n11. `QuoteBlock`\n12. `CalloutBlock`\n13. `LatexBlock`\n14. `TextBlock`\n15. `ImageBlock`\n16. `TableOfContentsBlock` and\n17. `LinkBlock`\nIf you want to create a collection, utilize the `create_collection` method [defined below].\n\nTo create a new block, you have a few options:\n### Create a block whose parent is the page\nIf you want to create a new block whose parent ID is the **page**, call the `create` method on the PageBlock instance.\n1. `@page.create(\"\u003ctype_of_block\", \"title of block\")` → create a new block at the end of the page.\n```ruby\n\u003e\u003e\u003e @page = @client.get_page(\"https://www.notion.so/danmurphy/Notion-API-Testing-66447bc817f044bc81ed3cf4802e9b00\")\n\u003e\u003e\u003e @page.create(NotionAPI::TextBlock, \"Hiya!\")\n#\u003cNotionAPI::TextBlock:0x00007fecd4459770 **omitted**\u003e\n```\n2. `@page.create(\"\u003ctype_of_block\", \"title of block\", \"target_block_id\")` → create a new block after the target block.\n```ruby\n\u003e\u003e\u003e @page = @client.get_page(\"https://www.notion.so/danmurphy/Notion-API-Testing-66447bc817f044bc81ed3cf4802e9b00\")\n\u003e\u003e\u003e @page.create(NotionAPI::TextBlock, \"Hiya!\", \"ee0a6531-44cd-439f-a68c-1bdccbebfc8a\")\n#\u003cNotionAPI::TextBlock:0x00007fecd8859770 **omitted**\u003e\n```\n3. `@page.create(\"\u003ctype_of_block\"), \"title of block\", \"target_block_id\", \"before/after\")` → create a new block after or before the target block.\n```ruby\n\u003e\u003e\u003e @page = @client.get_page(\"https://www.notion.so/danmurphy/Notion-API-Testing-66447bc817f044bc81ed3cf4802e9b00\")\n\u003e\u003e\u003e @page.create(NotionAPI::TextBlock, \"Hiya!\", \"ee0a6531-44cd-439f-a68c-1bdccbebfc8a\", \"before\")\n#\u003cNotionAPI::TextBlock:0x00007fecd8859880 **omitted**\u003e\n```\n4. `@page.create(\u003ctype_of_block\u003e, \"title of block\", options: { emoji: \"chosen emoji\" })` → create a new block with a chosen emoji for blocks with emojis (`PageBlock` and `CalloutBlock`).\n```ruby\n\u003e\u003e\u003e @page = @client.get_page(\"https://www.notion.so/danmurphy/Notion-API-Testing-66447bc817f044bc81ed3cf4802e9b00\")\n\u003e\u003e\u003e @page.create(NotionAPI::PageBlock, \"Hiya!\", options: { emoji: \"🚀\" })\n#\u003cNotionAPI::PageBlock:0x00007f80ed2abf78 **omitted**\u003e\n```\n5. `@page.create(\u003ctype_of_block\u003e, \"title of block\", options: { content: \"text or markdown\" })` → create a new block with text or markdown content.\n```ruby\n\u003e\u003e\u003e @page = @client.get_page(\"https://www.notion.so/danmurphy/Notion-API-Testing-66447bc817f044bc81ed3cf4802e9b00\")\n\u003e\u003e\u003e @page.create(NotionAPI::PageBlock, \"Hiya!\", options: { content: \"# Yippee Ki Yay\\n\\nJohn McClane\" })\n#\u003cNotionAPI::PageBlock:0x00007fa77a1d0ca8 **omitted**\u003e\n```\n### Create a block whose parent is another block\nIf you want to create a nested block whose parent ID is **another block**, call the `create` method on that block.\n1. `@block.create(\"\u003ctype_of_block\", \"title of block\")` → create a new nested block whose parent ID is @block.id\n```ruby\n\u003e\u003e\u003e @page = @client.get_page(\"https://www.notion.so/danmurphy/Notion-API-Testing-66447bc817f044bc81ed3cf4802e9b00\")\n\u003e\u003e\u003e @block = @page.get_block(\"2cbbe0bf-34cd-409b-9162-64284b33e526\")\n\u003e\u003e\u003e @block.create(NotionAPI::TextBlock, \"Hiya!\") # create a nested text block\n#\u003cNotionAPI::TextBlock:0x00007fecd8861780 **omitted**\u003e\n```\n2. `@block.create(\"\u003ctype_of_block\", \"title of block\", \"target_block\")` → create a new nested block whose parent ID is @block.id and whose location is after the target block\n```ruby\n\u003e\u003e\u003e @page = @client.get_page(\"https://www.notion.so/danmurphy/Notion-API-Testing-66447bc817f044bc81ed3cf4802e9b00\")\n\u003e\u003e\u003e @block = @page.get_block(\"2cbbe0bf-34cd-409b-9162-64284b33e526\")\n\u003e\u003e\u003e @block.create(NotionAPI::TextBlock, \"Hiya!\" \"ae3d1c60-b9d1-0ac0-0fff-16d3fc8907a2\") # create a nested text block after a specific child\n#\u003cNotionAPI::TextBlock:0x00007fecd8859781 **omitted**\u003e\n```\n3. `@block.create(\"\u003ctype_of_block\", \"title of block\", \"target_block\", \"before/after\")` → reate a new nested block whose parent ID is @block.id and whose location is before the target block\n```ruby\n\u003e\u003e\u003e @page = @client.get_page(\"https://www.notion.so/danmurphy/Notion-API-Testing-66447bc817f044bc81ed3cf4802e9b00\")\n\u003e\u003e\u003e @block = @page.get_block(\"2cbbe0bf-34cd-409b-9162-64284b33e526\")\n\u003e\u003e\u003e @block.create(NotionAPI::TextBlock, \"Hiya!\" \"ae3d1c60-b9d1-0ac0-0fff-16d3fc8907a2\", \"before\") # create a nested text block before a specific child\n#\u003cNotionAPI::TextBlock:0x00007fecd8859781 **omitted**\u003e\n```\nThe simplest way to describe this: the parent ID of the created block is the ID of the block the `create` method is invoked on. If the `create` method is invoked on a **PageBlock**, the block is a child of that page. If the `create` method is invoked on a block within the page, the block is a child of that block.\n\n** NOTE: Notion only supports 'nesting' certain block types. If you try to nest a block that cannot be nested, it will fail. **\n## Creating New Collections\nLet's say we have the following JSON data:\n```json\n[\n  {\n    \"emoji\": \"😀\",\n    \"description\": \"grinning face\",\n    \"category\": \"Smileys \u0026 Emotion\",\n    \"aliases\": [\"grinning\"],\n    \"tags\": [\"smile\", \"happy\"],\n    \"unicode_version\": \"6.1\",\n    \"ios_version\": \"6.0\"\n  },\n  {\n    \"emoji\": \"😃\",\n    \"description\": \"grinning face with big eyes\",\n    \"category\": \"Smileys \u0026 Emotion\",\n    \"aliases\": [\"smiley\"],\n    \"tags\": [\"happy\", \"joy\", \"haha\"],\n    \"unicode_version\": \"6.0\",\n    \"ios_version\": \"6.0\"\n  }\n]\n```\nA new table collection view containing this data is created with the following code:\n```ruby\n\u003e\u003e\u003e @page = @client.get_page(\"https://www.notion.so/danmurphy/Notion-API-Testing-66447bc817f044bc81ed3cf4802e9b00\")\n\u003e\u003e\u003e @page.create_collection(\"table\", \"title for table\", JSON.parse(File.read(\"./path/to/emoji_json_data.json\")))\n```\nHere's an example with a larger dataset:\n![create a collection view table](https://github.com/danmurphy1217/notion-ruby/blob/master/gifs/create%20collection.gif)\n\nAdditionally, say you already have a Table and want to add a new row with it containing the following data:\n```ruby\n{\n    \"emoji\": \"😉\",\n    \"description\": \"winking face\",\n    \"category\": \"Smileys \u0026 Emotion\",\n    \"aliases\": [\"wink\"],\n    \"tags\": [\"flirt\"],\n    \"unicode_version\": \"6.0\",\n    \"ios_version\": \"6.0\"\n}\n```\n```ruby\n\u003e\u003e\u003e @page = @client.get_page(\"https://www.notion.so/danmurphy/Notion-API-Testing-66447bc817f044bc81ed3cf4802e9b00\")\n\u003e\u003e\u003e @collection = @page.get_collection(\"f1664a99-165b-49cc-811c-84f37655908a\")\n\u003e\u003e\u003e @collection.add_row(JSON.parse(File.read(\"path/to/new_emoji_row.json\")))\n```\n\nThe first argument passed to `create_collection` determines which type of collection view to create. In the above example, a \"table\" is created, but other supported options are:\n1. list\n2. board\n3. calendar\n4. timeline\n5. gallery\n\n## Updating Collection View Cells\nWhen you retrieve a `CollectionViewRow` instance with `.row(\u003crow_id\u003e)` or a list of `CollectionViewRow` instances with `.rows`, a handful of methods are created. Each row instance has access attributes that represent the properties in the Notion Collection View. So, let's say we are working with the following Notion Collection View:\n| emoji | description  | category            | aliases | tags    | unicode_version | ios_version |\n|-------|--------------|---------------------|---------|---------|-----------------|-------------|\n| 😉     | \"winking face\" | \"Smileys \u0026 Emotion\" | \"wink\"  | \"flirt\" | \"6.0\"           | \"6.0\"       |\n\nIf you wanted to update the unicode and ios versions, you could use the following code:\n```ruby\n\u003e\u003e\u003e collection_view = @page.get_collection(\"1234567\") # the ID of the collection block is 1234567\n\u003e\u003e\u003e rows = collection_view.rows\n\u003e\u003e\u003e row[0].unicode_version = \"updated version here!\"\n\u003e\u003e\u003e row[0].ios_version = \"I was updated too!\"\n```\nNow, your Collection View will look like this:\n| emoji | description  | category            | aliases | tags    | unicode_version | ios_version |\n|-------|--------------|---------------------|---------|---------|-----------------|-------------|\n| 😉     |   \"winking face\"   | \"Smileys \u0026 Emotion\" | \"wink\"  | \"flirt\" | \"updated version here!\"          | \"I was updated too!\" |\n\nYou can also add new rows with the `.add_row({\u003cdata!\u003e})` method and add new properties with the `.add_property(\"name_of_property\", \"type_of_property\")` method.\n\n**One important thing to be aware of:**\nWhen adding a row with `.add_row`, the hash of data passed must be in the same order as it appears in your Notion Collection View.\n## Troubleshooting\n### No results returned when attempting to get a page\nIf an empty hash is returned when you attempt to retrieve a Notion page, you'll need to include the `x-notion-active-user-header` when instantiating the Notion Client.\nThe endpoint used by this wrapper to load a page is `/loadPageChunk`, check out the request headers in your developer tools Network tab.\n\nFrom here, you can instantiate the Notion Client with the following code:\n```ruby\n\u003e\u003e\u003e @client = NotionAPI::Client.new(\n  \"\u003cinsert_v2_token_here\u003e\",\n  \"\u003cinsert_x_notion_active_user_header_here\u003e\"\n)\n```\n### Retrieve a full-page Collection View\nA full-page collection view must have a URL that follows the below pattern:\nhttps://www.notion.so/danmurphy/[page-id]?v=[view-id]\nThen, it can be retrieved with the following code:\n```ruby\n\u003e\u003e\u003e @client = NotionAPI::Client.new(\n  \"\u003cinsert_v2_token_here\u003e\"\n)\n\u003e\u003e\u003e @client.get_page(\"https://www.notion.so/danmurphy/[page-id]?v=[view-id]\")\n```\n### Linking to another page\nYou can create a block that links to another notion page with the following syntax:\n```ruby\n@client = NotionAPI::Client.new(ENV[\"token_v2\"])\n@page = @client.get_page(\"https://www.notion.so/danmurphy/Testing-227581d35fc94fa1a5f9fda1e8478d1e\")\n@page.create(NotionAPI::LinkBlock, \"ea93213d1f21439c870fbe91503e76fe\")\n```\nThis example will create a `LinkBlock` on the `Testing` page to the page with ID `ea93213d1f21439c870fbe91503e76fe`.\n","funding_links":[],"categories":["APIs"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanmurphy1217%2Fnotion-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanmurphy1217%2Fnotion-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanmurphy1217%2Fnotion-ruby/lists"}