{"id":18728799,"url":"https://github.com/rubyonworld/buttercms-ruby","last_synced_at":"2025-08-25T13:05:34.637Z","repository":{"id":174007859,"uuid":"542153329","full_name":"RubyOnWorld/buttercms-ruby","owner":"RubyOnWorld","description":"For a comprehensive list of examples, check out the API documentation.","archived":false,"fork":false,"pushed_at":"2022-09-27T16:42:31.000Z","size":59,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-28T14:26:40.706Z","etag":null,"topics":["api","check","comprehensive","example"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RubyOnWorld.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-27T15:19:29.000Z","updated_at":"2022-09-27T18:17:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"31ba3d58-2d07-414a-b5e3-9299b510b5d6","html_url":"https://github.com/RubyOnWorld/buttercms-ruby","commit_stats":null,"previous_names":["rubyonworld/buttercms-ruby"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fbuttercms-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fbuttercms-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fbuttercms-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fbuttercms-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RubyOnWorld","download_url":"https://codeload.github.com/RubyOnWorld/buttercms-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239599040,"owners_count":19665911,"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":["api","check","comprehensive","example"],"created_at":"2024-11-07T14:24:24.495Z","updated_at":"2025-02-19T04:49:43.202Z","avatar_url":"https://github.com/RubyOnWorld.png","language":"Ruby","readme":"# ButterCMS API Ruby Client\n\n## Documentation\n\nFor a comprehensive list of examples, check out the [API documentation](https://buttercms.com/docs/api/).\n\n## Setup\n\nTo setup your project, follow these steps:\n\n1. Install using `gem install buttercms-ruby` or by adding to your `Gemfile`:\n\n  ```ruby\n  gem 'buttercms-ruby'\n  ```\n\n2. Set your API token.\n\n  ```ruby\n  require 'buttercms-ruby'\n\n  ButterCMS::api_token = \"YourToken\"\n\n  # Fetch content from test mode (eg. for your staging website)\n  # ButterCMS::test_mode = true\n\n  # Set read timeout (Default is 5.0)\n  # ButterCMS::read_timeout = 5.0\n\n  # Set open timeout (Default is 2.0)\n  # ButterCMS::open_timeout = 2.0\n  ```\n\n## Pages\n\nhttps://buttercms.com/docs/api/?ruby#pages\n\n\n```ruby\nparams = {page: 1, page_size: 10, locale: 'en', preview: 1, 'fields.headline': 'foo bar', levels: 2} # optional\npages = ButterCMS::Page.list('news', params)\n\npage = ButterCMS::Page.get('news', 'hello-world', params)\n\npages = ButterCMS::Page.search('query', params)\n```\n\n## Collections\n\nhttps://buttercms.com/docs/api/?ruby#retrieve-a-collection\n\n```ruby\n# list each instance of a given collection with meta data for fetching the next page.\nparams = { page: 1, page_size: 10, locale: 'en', preview: 1, 'fields.headline': 'foo bar', levels: 2 } # optional\nButterCMS::Content.list('collection1', params)\n\n# list instances for multiple collections, this will not return meta data for pagination control.\nButterCMS::Content.fetch(['collection1', 'collection2'], params)\n\n# Test mode can be used to setup a staging website for previewing Collections or for testing content during local development. To fetch content from test mode add the following configuration:\nButterCMS::test_mode = true\n```\n\n## Blog Engine\n\nhttps://buttercms.com/docs/api/?ruby#blog-engine\n\n```ruby\nposts = ButterCMS::Post.all({:page =\u003e 1, :page_size =\u003e 10})\nputs posts.first.title\nputs posts.meta.next_page\n\nposts = ButterCMS::Post.search(\"my favorite post\", {page: 1, page_size: 10})\nputs posts.first.title\n\npost = ButterCMS::Post.find(\"post-slug\")\nputs post.title\n\n# Create a Post.\nButterCMS::write_api_token = \"YourWriteToken\"\nButterCMS::Post.create({\n  slug: 'blog-slug',\n  title: 'blog-title'\n})\n\n# Update a Post\nButterCMS::Post.update('blog-slug', {\n  title: 'blog-title-v2'\n})\n\n# Create a page\nButterCMS::Page.create({\n  slug: 'page-slug',\n  title: 'page-title',\n  status: 'published',\n  \"page-type\": 'page_type',\n  fields: {\n    meta_title: 'test meta title'\n  }\n})\n\n# update a Page\nButterCMS::Page.update('page-slug-2', {\n  status: 'published',\n  fields: {\n    meta_title: 'test meta title'\n  }\n})\n\n\n\nauthor = ButterCMS::Author.find(\"author-slug\")\nputs author.first_name\n\ncategory = ButterCMS::Category.find(\"category-slug\")\nputs category.name\n\ntags = ButterCMS::Tag.all\np tags\n\nrss_feed = ButterCMS::Feed.find(:rss)\nputs rss_feed.data\n```\n\n\n## Fallback Data Store\n\nThis client supports automatic fallback to a data store when API requests fail. When a data store is set, on every successful API request the response is written to the data store. When a subsequent API request fails, the client attempts to fallback to the value in the data store. Currently, Redis and YAML Store are supported.\n\n```ruby\n# Use YAMLstore\nButterCMS::data_store = :yaml, \"/File/Path/For/buttercms.store\"\n\n# Use Redis\nButterCMS::data_store = :redis, ENV['REDIS_URL']\n\n# Set logger (optional)\nButterCMS::logger = MyLogger.new\n```\n\n### Other\n\nView Ruby [Blog engine](https://buttercms.com/ruby-blog-engine/) and [Full CMS](https://buttercms.com/ruby-cms/) for other examples of using ButterCMS with Ruby.\n\n### Development\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyonworld%2Fbuttercms-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubyonworld%2Fbuttercms-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyonworld%2Fbuttercms-ruby/lists"}