
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@googleapis/sheets
Advanced tools
@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.
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);
}
}
The google-spreadsheet package is another popular library for interacting with Google Sheets. It provides a simpler interface for reading and writing data to Google Sheets. Compared to @googleapis/sheets, it abstracts away some of the complexities of the Google Sheets API, making it easier to use for basic operations.
The gsheets package is a lightweight library for accessing Google Sheets. It offers basic functionalities for reading and writing data. While it is not as feature-rich as @googleapis/sheets, it is suitable for simple use cases and quick integrations.
Reads and writes Google Sheets.
$ npm install @googleapis/sheets
All documentation and usage information can be found on GitHub. Information on classes can be found in Googleapis Documentation.
This library is licensed under Apache 2.0. Full license text is available in LICENSE.
We love contributions! Before submitting a Pull Request, it's always good to start with a new issue first. To learn more, see CONTRIBUTING.
Crafted with ❤️ by the Google Node.js team
140.0.0 (2024-06-06)
FAQs
sheets
The npm package @googleapis/sheets receives a total of 128,883 weekly downloads. As such, @googleapis/sheets popularity was classified as popular.
We found that @googleapis/sheets demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.