Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@maxim_mazurok/gapi.client.sheets-v4
Advanced tools
TypeScript typings for Google Sheets API v4
Reads and writes Google Sheets. For detailed description please check documentation.
Install typings for Google Sheets API:
npm install @types/gapi.client.sheets-v4 --save-dev
You need to initialize Google API client in your code:
gapi.load('client', () => {
// now we can use gapi.client
// ...
});
Then load api client wrapper:
gapi.client.load(
'https://sheets.googleapis.com/$discovery/rest?version=v4',
() => {
// now we can use:
// gapi.client.sheets
}
);
// Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
gapi.client.load('sheets', 'v4', () => {
// now we can use:
// gapi.client.sheets
});
Don't forget to authenticate your client before sending any request to resources:
// declare client_id registered in Google Developers Console
var client_id = '',
scope = [
// See, edit, create, and delete all of your Google Drive files
'https://www.googleapis.com/auth/drive',
// See, edit, create, and delete only the specific Google Drive files you use with this app
'https://www.googleapis.com/auth/drive.file',
// See and download all your Google Drive files
'https://www.googleapis.com/auth/drive.readonly',
// See, edit, create, and delete all your Google Sheets spreadsheets
'https://www.googleapis.com/auth/spreadsheets',
// See all your Google Sheets spreadsheets
'https://www.googleapis.com/auth/spreadsheets.readonly',
],
immediate = true;
// ...
gapi.auth.authorize(
{client_id: client_id, scope: scope, immediate: immediate},
authResult => {
if (authResult && !authResult.error) {
/* handle successful authorization */
} else {
/* handle authorization error */
}
}
);
After that you can use Google Sheets API resources:
/*
Applies one or more updates to the spreadsheet. Each request is validated before being applied. If any request is not valid then the entire request will fail and nothing will be applied. Some requests have replies to give you some information about how they are applied. The replies will mirror the requests. For example, if you applied 4 updates and the 3rd one had a reply, then the response will have 2 empty replies, the actual reply, and another empty reply, in that order. Due to the collaborative nature of spreadsheets, it is not guaranteed that the spreadsheet will reflect exactly your changes after this completes, however it is guaranteed that the updates in the request will be applied together atomically. Your changes may be altered with respect to collaborator changes. If there are no collaborators, the spreadsheet should reflect your changes.
*/
await gapi.client.sheets.spreadsheets.batchUpdate({
spreadsheetId: 'spreadsheetId',
});
/*
Creates a spreadsheet, returning the newly created spreadsheet.
*/
await gapi.client.sheets.spreadsheets.create({});
/*
Returns the spreadsheet at the given ID. The caller must specify the spreadsheet ID. By default, data within grids is not returned. You can include grid data in one of 2 ways: * Specify a [field mask](https://developers.google.com/sheets/api/guides/field-masks) listing your desired fields using the `fields` URL parameter in HTTP * Set the includeGridData URL parameter to true. If a field mask is set, the `includeGridData` parameter is ignored For large spreadsheets, as a best practice, retrieve only the specific spreadsheet fields that you want. To retrieve only subsets of spreadsheet data, use the ranges URL parameter. Ranges are specified using [A1 notation](/sheets/api/guides/concepts#cell). You can define a single cell (for example, `A1`) or multiple cells (for example, `A1:D5`). You can also get cells from other sheets within the same spreadsheet (for example, `Sheet2!A1:C4`) or retrieve multiple ranges at once (for example, `?ranges=A1:D5&ranges=Sheet2!A1:C4`). Limiting the range returns only the portions of the spreadsheet that intersect the requested ranges.
*/
await gapi.client.sheets.spreadsheets.get({spreadsheetId: 'spreadsheetId'});
/*
Returns the spreadsheet at the given ID. The caller must specify the spreadsheet ID. This method differs from GetSpreadsheet in that it allows selecting which subsets of spreadsheet data to return by specifying a dataFilters parameter. Multiple DataFilters can be specified. Specifying one or more data filters returns the portions of the spreadsheet that intersect ranges matched by any of the filters. By default, data within grids is not returned. You can include grid data one of 2 ways: * Specify a [field mask](https://developers.google.com/sheets/api/guides/field-masks) listing your desired fields using the `fields` URL parameter in HTTP * Set the includeGridData parameter to true. If a field mask is set, the `includeGridData` parameter is ignored For large spreadsheets, as a best practice, retrieve only the specific spreadsheet fields that you want.
*/
await gapi.client.sheets.spreadsheets.getByDataFilter({
spreadsheetId: 'spreadsheetId',
});
FAQs
TypeScript typings for Google Sheets API v4
The npm package @maxim_mazurok/gapi.client.sheets-v4 receives a total of 3,348 weekly downloads. As such, @maxim_mazurok/gapi.client.sheets-v4 popularity was classified as popular.
We found that @maxim_mazurok/gapi.client.sheets-v4 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.