Getting Started with microCMS
Getting Started
This document outlines the quickest steps to use microCMS from a Go application.
If you are using microCMS from a Go application for the first time, please try these steps first.
Things to Check in Advance
- You need to understand how to register 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 an API, please refer to Creating an API.
On the API creation screen, enter the 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.

Fetching Data with Go
First, here is how to fetch data using Go. Install the microcms-go-sdk in your environment.
$ go mod init test-project
$ go get github.com/microcmsio/microcms-go-sdkNext, create a main.go file to fetch the data. Please set your own service-domain and api-key.
package main
import (
"fmt"
"time"
"github.com/microcmsio/microcms-go-sdk"
)
type Content struct {
Text string `json:"text,omitempty"`
CreatedAt time.Time `json:"createdAt,omitempty"`
UpdatedAt time.Time `json:"updatedAt,omitempty"`
PublishedAt time.Time `json:"publishedAt,omitempty"`
RevisedAt time.Time `json:"revisedAt,omitempty"`
}
func main() {
serviceDomain := "service-domain"
apiKey := "api-key"
c := microcms.New(serviceDomain, apiKey)
params := microcms.GetParams{
Endpoint: "hello",
}
var data Content
err := c.Get(params, &data)
if err != nil {
panic(err)
}
fmt.Printf("%+v", data)
}Let's run the local main.go. You will be able to fetch the content you submitted to microCMS.
$ go run main.go