šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

@googleapis/sheets

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@googleapis/sheets

sheets

9.7.0
latest
Source
npm
Version published
Weekly downloads
140K
-11.89%
Maintainers
2
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 22 Apr 2025

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