This section presents a codelab you can use to become familiar with the Sheets API. Also provided are a set of 'recipe' examples that demostrate how to translate an intended Sheets action into an API request.
In many cases there is more than one way to complete a given task with the API. When you are deciding on how to approach a task, keep the following in mind:
- If you just need to read or write cell values, the spreadsheets.values collection is a better choice than the spreadsheets collection. The former's interface is easier to use for simple read/write operations.
- Wherever possible, use the batch methods (spreadsheet.batchUpdate, spreadsheet.values.batchGet, and spreadsheet.values.batchUpdate) to bundle multiple requests into a single method call. Using these batch methods improve efficiency; they reduce client HTTP overhead, reduce the number of queries made, reduce the number of revisions on the doc, and ensure atomicity of all the changes in the batch.
The examples listed in this section demonstrate how to express common actions in Google Sheets as Sheets API v4 requests.
These examples are presented in the form of HTTP requests to be language neutral. To learn how implement Sheets API request protocols in a specific language using Google API client libraries, see the Reading and Writing Values guide and the Updating Spreadsheets guide.
Recipes in this section are divided into the following categories:
- Basic Reading — Recipes that show the most direct ways of reading values from a sheet.
- Basic Writing — Recipes that show the most direct ways of writing values to a sheet.
- Basic Formatting — Recipes that show how to change the appearance of sheets and cells.
- Charts — Recipes that show how to create and alter charts in a sheet.
- Conditional Formatting — Recipes that show how to alter cell appearence based on conditions.
- Data Operations — Recipes that show how to create, move, and manipulate data in a spreadsheet.
- Named and Protected Ranges — Recipes that show how to create, update, and remove named and protected ranges in a spreadsheet.
- Pivot Tables — Recipes that show how to create pivot tables in a sheet.
- Row and Column Operations — Recipes that show how to add, remove, and move rows and columns and update their properties.
- Sheet Operations — Recipes that show how to create, delete, and update sheet properties within a spreadsheet.