Skip to content

heynicejacket/SSAPI-101

Repository files navigation

Smartsheet API 101

I haven't seen a lot of bite-sized examples (or examples of any size) for interacting with the Smartsheet API. There are surely many people who need to pull data off Smartsheet, but are either not experienced programmers, or don't have the time to futz around with it.

While I'm not quite the former, I have a bit of the latter.

This is intended as a one stop shop, growing repository of simple examples of how to I/O your Smartsheet assets, manipulate the data therein, and push it to other services.

Please note: I'm an advocate of tool democratization. These examples are written far more long hand than necessary, and I've opted for spelling out the logic wherever possible (with accompanying comments). These are not examples of Pythonic best practices. For example, I've opted for:

p_col = False
if i == 0:
  p_col = True
new_column_dict = {'title': col, 'primary': p_col, ... }

...rather than simply:

new_column_dict = {'title': col_title, 'primary': i == 0, ... }

...to make what's going on as clear as posslbe for a complete beginner.

Getting started with the Smartsheet API

These examples require you to have a Smartsheet access token (you can find instructions for that here, and most require you to know the ID of the sheet that you're trying to interact with.

There are a lot of ways to get sheet_id, but in general, if you're new to working with APIs, Postman is a great tool. They have a series of getting started with APIs videos here, if you are so inclined.

If you want a quick start, this video (queued to exactly what you need to watch) from Smartsheet gets you the basics for how to generate an access token and retrieve a list of your sheets, with:

https://api.smartsheet.com/2.0/sheets/?includeAll=true

...which will get you a long list that looks like this:

{
    "pageNumber": 1,
    "totalPages": 1,
    "totalCount": 333,
    "data": [
        {
            "id": 745780222344261,
            "name": "SODO Happy Hour Spots",
            "accessLevel": "OWNER",
            "permalink": "https://app.smartsheet.com/sheets/6RmVPJrpq34tevgbega9384rth3a4rhh",
            "createdAt": "2019-02-23T17:52:40Z",
            "modifiedAt": "2019-02-29T17:37:13Z"
        },
        {
        ...

That "id" is the sheet_id. Everything has an ID - workspaces, reports, sheets, columns, rows, cells.

Lastly, install the smartsheet sdk in the command line with:

pip install smartsheet-python-sdk

...and you've got enough to be dangerous.

Using this code

Releases

No releases published

Packages

No packages published

Languages