# sheets-api

> A Google Sheets API v4 implementation that abstracts authorization.

Latest version **1.0.8** (published 2019-02-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install sheets-api
pnpm add sheets-api
yarn add sheets-api
bun add sheets-api
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2019-02-08 |
| First published | 2017-01-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 7 |
| Author | kmedley |
| Maintainers | kurtlocker |
| Keywords | spreadsheets, google, Google Sheets, googleapis, sheets, api |

## Links

- npm: https://www.npmjs.com/package/sheets-api
- Repository: https://github.com/kurtlocker/sheets-api
- Homepage: https://github.com/kurtlocker/sheets-api#readme
- Issues: https://github.com/kurtlocker/sheets-api/issues
- npm.io page: https://npm.io/package/sheets-api

## Dependencies (2)

- [googleapis](https://npm.io/package/googleapis.md) ^16.0.0
- [google-authorize](https://npm.io/package/google-authorize.md) ^1.0.4

## Alternatives

- [csv-to-markdown-table](https://npm.io/package/csv-to-markdown-table.md) — 47.0K weekly downloads
- [@sapphire/ratelimits](https://npm.io/package/@sapphire/ratelimits.md) — 4.4K weekly downloads
- [js-csvparser](https://npm.io/package/js-csvparser.md) — 2.0K weekly downloads
- [@adadapted/js-sdk](https://npm.io/package/@adadapted/js-sdk.md) — 251 weekly downloads
- [@grapecity/spread-sheets-sparklines](https://npm.io/package/@grapecity/spread-sheets-sparklines.md) — 103 weekly downloads

## Recent versions

- 1.0.8 (latest) — 2019-02-08
- 1.0.7 — 2019-01-26
- 1.0.6 — 2018-11-06
- 1.0.5 — 2017-01-09
- 1.0.4 — 2017-01-09
- 1.0.3 — 2017-01-09
- 1.0.2 — 2017-01-06
- 1.0.1 — 2017-01-06
- 1.0.0 — 2017-01-05

## README

# Sheets API v4

Allows you to start working with the Google Sheets API v4 right away.


A Google Sheets API v4 implementation that abstracts the authorization portion of each request away from the user a bit. Simply call authorize to get a promise that resolves the OAuth2 client which can be used to make requests. Provides generic 'collection' methods that assist with calling methods associated with those collections i.e. 'values' maps to spreadsheets.values. Really just a wrapper around googleapis.

Here's how to use it:

Visit [Node quickstart](https://developers.google.com/sheets/api/quickstart/nodejs) and complete Step 1 to get your client_secret.json.

```bash
npm i sheets-api --save
```
```javascript
// sheets-client.js
const SheetsAPI = require('sheets-api');
const sheets = new SheetsAPI();
const SPREADSHEET_ID = "19uTpwB-PM9TtUGUCRMdgWdkH0pqEHVv3J6sjzCNoMRM";

// ValueRange(https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values#ValueRange)
let payload = {
  spreadsheetId: SPREADSHEET_ID,
  range: "Orders!A1:D1",
  valueInputOption: 'USER_ENTERED',
  resource : {
    majorDimension: "ROWS",
    values: [
      ["Door", "$15", "2", "3/15/2017"],
      ["Engine", "$100", "1", "3/20/2016"]
    ]
  }
}

sheets
  // Get me an authorized OAuth2 client thats ready to make requests.
  .authorize()

  // https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append
  // Using the spreadsheets.values collection, use the 'append' method to
  // append data (payload) to a spreadsheet.
  .then(auth => sheets.values('append', auth, payload))

  // 'response' is an object that contains the response from the request to the
  // API (append) and the OAuth2 client to be chained further. It looks like this:
  // {auth:auth, response:response}
  .then(response => sheets.values('get', response.auth, {
    spreadsheetId: SPREADSHEET_ID,
    range: 'Orders!A1:D1'
  }))

  // The results of the request to spreadsheets.values.get collection.
  .then(response => {
    console.log(response.response);
  })

  // Derp
  .catch(e => console.error(e))
```

![Zoolander - Its so simple](https://cdn.meme.am/cache/instances/folder28/500x/65581028.jpg)

##Change Log

### 1.0.5 - Jan 8, 2017
Fixing typo where response was undefined.

### 1.0.4 - Jan 8, 2017
Publishing README.md to NPM.

### 1.0.3 - Jan 8, 2017
Fixed fn#collections not correctly resolving the response from sheets api. Promise.resolve takes a single object. You can't simply pass n arguments to it. It has single arity.

### 1.0.2 - Jan 5, 2017
Fixed not returning promises from collection methods.

### 1.0.1 - Jan 5, 2017
Added other collection helper methods (spreadsheets.sheets, spreadsheets).

### 1.0.0 - Jan 4, 2017
Initial publish.

---
_Source: https://npm.io/package/sheets-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
