googleads
CRUD operation on Google Spreadsheet using NodeJS
preloder
Node.js Tips & Tricks

CRUD operation on Google Spreadsheet using NodeJS

We all must have heard about CRUD(Create, Retrieve, Update and Delete) operation. In this blog, let’s see how we can do CRUD operation on Google Spreadsheet using Node.js,

When we are going to implement APIs, 

What is Google Spreadsheet?

Google Spreadsheets is a Web-based application that allows users to create, update and modify spreadsheets and share the data live online. The Ajax-based program is compatible with Microsoft Excel and CSV (comma-separated values) files. Spreadsheets can also be saved as HTML.

What exactly is Node JS?

Node.js is an open-source, cross-platform JavaScript run-time environment that executes JavaScript code server-side.

The Node run-time environment includes everything you need to execute a program written in JavaScript.

Node.js came into existence when the original developers of JavaScript extended it from something you could only run in the browser to something you could run on your machine as a standalone application.

Now you can do much more with JavaScript than just making websites interactive.

Prerequisites

To run this simple example, all you’ll need is

Node.js & npm installed and a Google account.

Step 1: Turn on the Google Sheets API & Create the credentials file

Step 1.1: Use this URL link to create a new console project.

Step 1.2: To enable the spreadsheet API, please check the screenshot.

Step 1.3: In search box, type the word google sheet and click the card to enable the spreadsheet API

Step 1.4: Once the google spreadsheet API enables, then you need to create credentials, Use this URL link to create a credentials

Step 1.5: then click the “create credentials” from the dropdown and select the OAuth client ID.

Step 1.6: Select the checkbox “other” option and click the create.


Step 1.7: then download the credentials file and we can use this file in our sample code.

Step 2: Install The Client Library

Run the following commands to install the libraries using npm:

 

Related:  How To Deploy NodeJS App to Heroku

 

Step 3: Set up the sample in NodeJS

 

Also Read: 10 JavaScript concepts every Node.js developer should know

 

Step 3.1: CREATE (or) UPDATE

CREATE or UPDATE both the operations can be done by the below mentioned code so copy and paste this code for applying both,

 

Step 3.1: READ

 

Step 3.1: DELETE

 

4: Run the sample

 

Note: Access permission

The first time you run the sample, it will prompt you to authorize access:

Browse to the provided URL in your web browser.

If you have not logged into your Google account, then you will be prompted to log in. If you are logged into multiple Google accounts, then you will be asked to select one account to use for the authorization.

Now, click the Accept button.

Copy the given code, paste it into the command-line prompt, and press Enter.

That’s all guys! We done it. Here we used NodeJS and we can also use “Google App Script” to apply this CRUD operation. If you’re interested to know then let us know your opinions in comment box, will surely discuss about it in coming days.

Mad over reading? Then never miss out anything from our blog works, there you can read about all latest technologies & it’s updates which would be perfect for your 15 minutes tea break! What else guys hit the subscribe link and go crazy over learning.

The following two tabs change content below.

Ken

Senior Full Stack Developer having 3 years of experience in Web development arena , Expertise in MEAN stack, Python, Javascript, Angular. And, This freaking humor bomb loves to involve himself in playing auspicious Games but Once you reach him, he ll always make sure to light up your terrific days with laughter's.

Leave a Reply

Your email address will not be published. Required fields are marked *

[contact-form-7 id="120788" title="Web Page Form"]

Schedule Your Call