New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@googleapis/sheets

Package Overview
Dependencies
Maintainers
3
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@googleapis/sheets

sheets

4.0.0
Source
npm
Version published
Weekly downloads
155K
11.3%
Maintainers
3
Weekly downloads
 
Created

What is @googleapis/sheets?

@googleapis/sheets is an npm package that provides a client library for accessing the Google Sheets API. It allows developers to interact with Google Sheets programmatically, enabling them to read, write, and manipulate spreadsheet data.

What are @googleapis/sheets's main functionalities?

Read Data from a Spreadsheet

This feature allows you to read data from a specified range in a Google Sheets spreadsheet. The code sample demonstrates how to use the Google Sheets API to fetch data from a specific range in a sheet.

const { google } = require('@googleapis/sheets');
const sheets = google.sheets('v4');

async function readData(auth) {
  const request = {
    spreadsheetId: 'your-spreadsheet-id',
    range: 'Sheet1!A1:D5',
    auth: auth,
  };

  try {
    const response = await sheets.spreadsheets.values.get(request);
    console.log(response.data.values);
  } catch (err) {
    console.error(err);
  }
}

Write Data to a Spreadsheet

This feature allows you to write data to a specified range in a Google Sheets spreadsheet. The code sample demonstrates how to use the Google Sheets API to update a range of cells with new data.

const { google } = require('@googleapis/sheets');
const sheets = google.sheets('v4');

async function writeData(auth) {
  const request = {
    spreadsheetId: 'your-spreadsheet-id',
    range: 'Sheet1!A1',
    valueInputOption: 'RAW',
    resource: {
      values: [
        ['Item', 'Cost'],
        ['Apple', '$1'],
        ['Banana', '$2'],
      ],
    },
    auth: auth,
  };

  try {
    const response = await sheets.spreadsheets.values.update(request);
    console.log(response.data);
  } catch (err) {
    console.error(err);
  }
}

Append Data to a Spreadsheet

This feature allows you to append data to a specified range in a Google Sheets spreadsheet. The code sample demonstrates how to use the Google Sheets API to add new rows of data to a sheet.

const { google } = require('@googleapis/sheets');
const sheets = google.sheets('v4');

async function appendData(auth) {
  const request = {
    spreadsheetId: 'your-spreadsheet-id',
    range: 'Sheet1!A1',
    valueInputOption: 'RAW',
    insertDataOption: 'INSERT_ROWS',
    resource: {
      values: [
        ['Orange', '$3'],
        ['Grapes', '$4'],
      ],
    },
    auth: auth,
  };

  try {
    const response = await sheets.spreadsheets.values.append(request);
    console.log(response.data);
  } catch (err) {
    console.error(err);
  }
}

Other packages similar to @googleapis/sheets

Keywords

google

FAQs

Package last updated on 28 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts