microCMS

Getting Started

Getting Started

This document outlines the quickest steps to use microCMS from a Ruby application.
If you are using microCMS from a Ruby application for the first time, please try these steps first.

Things to Check in Advance

  • You need to understand how to register for a microCMS account, create a service, and create an API. Please refer to the operation manual for more information.


Setting Up microCMS

First, we will create a very simple API in microCMS.

  • Object format
  • One text field


Below is an example of the configuration. For detailed steps on creating the API, please refer to Creating an API.

In the API creation screen, enter a desired API name and endpoint.



Next, select the object format.


Finally, set the fields. This time, we will set only one text field.



With the above settings, the API will be created, allowing you to submit content.
Move to the editing screen, enter the desired values, and publish.



At this point, a response containing content data will be returned from the API.
Click on the API preview in the upper right corner to access the created API and confirm that a JSON response is being returned.


Getting Data with Ruby

This is how to retrieve data using Ruby. First, install the microcms-ruby-sdk in your environment.

$ bundle init
$ bundle add microcms-ruby-sdk


Next, create a main.rb file to retrieve the data. Please set your own service-domain and api-key.

require 'microcms'

MicroCMS.service_domain = 'service-domain'
MicroCMS.api_key = 'api-key'

puts MicroCMS.list('hello')


Now, let's run the local main.rb. You will be able to retrieve the content you submitted to microCMS.

$ bundle exec ruby main.rb