Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@googleapis/sheets

Package Overview
Dependencies
Maintainers
3
Versions
26
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
  • Socket score

Version published
Weekly downloads
118K
decreased by-5.28%
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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc