Access Google Spreadsheet as JSON : Method 2

Share:

Google spreadheet to JOSN

 

Google Sheets is a free, web-based software office suite offered by Google within its Google Drive service.

One useful feature of Google Spreadsheets is the ability to access the data as JSON by using a particular URL. 


To access a spread as JSON First, you must create and publish/share your spreadsheet to the web.


Endpoint URL:
https://sheets.googleapis.com/v4/spreadsheets/SpreadsheetheetID/values/SheetName?alt=json&key=APIKey

Change the three-parameter:
  • SpreadsheetheetID
  • SheetName
  • APIKey

For example, your google sheet shared URLs will look something like belo URL. Highlighter long string is a unique  SpreadsheetheetID. Copy form your sheet and replace SpreadsheetheetID in the Endpoint URL.
 
https://docs.google.com/spreadsheets/d/1p02wgf2uNRPibqZ_QBssa2v4BtRGZqbhZgGnDi4_9AZ/edit?usp=sharing


Steps to generate a google API key for the spreadsheet:
  • Go to the Google Developers Console at https://console.developers.google.com/ and log in to your Google account. Google may ask you to identify your country and agree to its terms of service.
  • Click on Create a Project Or alternatively, go to the upper-left drop-down menu to Select a project > New project.
  • In the next screen, give your new project a meaningful name to remind you of its purpose, such as codebrary.
  • In the next screen, press the + Enable APIs and Services at the top of the menu. Make sure that your new project name appears near the top.
  • In the next screen, enter Google Sheets into the search bar, and select this result
  • In the next screen, select the Enable button to turn on the Google Sheets API for your project
  • In the left sidebar menu, click Credentials, then click + Create Credentials and select API key
  • In the next screen, the console will generate your API key. Copy it, then press Restrict key

Hi! I am Sartaj Husain. I am a Professional Software Developer, live in Delhi. I write blogs in my free time. I love to learn and share the knowledge with others because it is no good to try to stop knowledge from going forward. So free posts and tutorials. more..

No comments