A Wrapper Client for Google Spreadsheet API (Sheets API)


Service Account and Key File

  1. Create a service account on Google Cloud Platform. Refer:
  2. Generate and Download a key file (json) that relates the service account you created. Refer:

Sheets API

  1. Enable Sheets API on your project. Refer:


  1. Create a spreadsheet on your google drive.
  2. Specify your table schema on the spreadsheet. Row ‘1’ is column name cell. And rows ‘2’ or greater are data cell. Cell ‘1A’ must be ‘id’.
  3. Invite the service account as a editor, without notification.


Init Senmai Client

	// KeyFile path of your key file you generated at PREPARATION section 
	const KeyFile = "/path/to/identity.json"

	// SpreadsheetID is identity string of spreadsheet that you want to manipulate. Refer:
	const SpreadsheetID = "1234567890qwertyuiopASDFGHJKL"

	// SheetName is a name of a sheet you want to manipulate 
	SheetName = "book"

	// Init Senmai Client
	sm, err := senmai.New(KeyFile)
	if err != nil {

Get Table struct

	// Get Table struct that named "book"
	book, err := sm.GetTable(SpreadsheetID, SheetName)
	if err != nil {

Fetch a row

	// Fetch
	row, err := book.FetchRow("mybook0001")
	if err != nil {
	fmt.Printf("%#v\n", row)

Update a row

	// Update
	row.Cols["price_yen"] = "4000"
	err = row.Update()
	if err != nil {

Create a new row

	// Build a new row struct
	b1 := book.NewRow()

	// Fill-in field values
	b1.Cols = map[string]string{
		"id":         "mybook0003",
		"name":       "Slack: Getting Past Burnout, Busywork, and the Myth of Total Efficiency",
		"author":     "Tom DeMarco",
		"price_yen":  "2800",

	// Insert into spreadsheet
	err = b1.Insert()
	if err != nil {


View Github