Introducing the Smartsheet Ruby SDK

Published on 11 November 2017

Working with the Smartsheet API just got a whole lot easier for Rubyists!

We're excited to announce the addition of the Smartsheet Ruby SDK to our stable of native language SDKs. Now, instead of working with the API directly, you can install the smartsheet gem and interact with the Smartsheet API through Ruby methods.

To help you get started with the SDK, we've added a Ruby tab to the Smartsheet API documentation that provides example code for making requests to each of the API endpoints, and the expected responses from those requests.

Ruby tab new in Smartsheet docs

As you can see from the example above, getting a list of sheets through the Ruby SDK requires a simple call to smartsheet.sheets.list. Then, you can parse the response as needed. By default the SDK returns API responses as a Hash. But, you also have the option of returning raw JSON by setting json_output:true when initializing the client.

To get started using the SDK, you'll need to be running at least version 2.2 of Ruby. Install the Smartsheet gem:

gem install smartsheet

Then, to use the gem, require it at the top of your Ruby scripts:

require 'smartsheet'

Next, initialize a smartsheet_client object, using your access token to connect your application to your Smartsheet data.

An access token can be generated in the Smartsheet UI by going to the Account menu and selecting Personal Settings…, and then API Access. There you'll find the Generate new access token button.

Once your token is created, use it in the statement below to create your smartsheet_client.

smartsheet\_client = 'your\_token\_here')

This statement is also where you can tell the SDK that you'd prefer JSON output. To do that, add json\_output: true to the arguments being sent to create the client.

With smartsheet_client initialized you can now call the Smartsheet API. As mentioned above, to grab a list of sheets call:

sheets = smartsheet\_client.sheets.list

Then, to grab the first sheet in the list and print its name, our code would look like this:

sheet\_name = sheets\[:data\]\[0\]\[:name\]  
puts "Sheet from List #{sheet\_name}"

To learn more about the Ruby SDK, visit the project on GitHub, the Ruby-Read-Write-Sheet sample on GitHub, or select the Ruby tab in the Smartsheet API documentation.