jsongoogle-sheetsgoogle-sheets-apiapi-key

How to add API key to the google spreadsheet?


I have created a google sheet and have converted it into JSON using the URL. example: https://spreadsheets.google.com/feeds/list/SHEETID/od6/public/values?alt=json

I want to add a api key to this google sheet. I have generated a API key though Google Cloud Platform - https://console.cloud.google.com/flows/enableapi?apiid=sheets.googleapis.com

Now, how can i add this API key to the sheet?? Please could anyone help.


Solution

  • I thought that your endpoint of https://spreadsheets.google.com/feeds/list/SHEETID/od6/public/values?alt=json is for Sheets API v3. When the official document of Sheets API v3 is seen, it says as follows.

    Update: The Google Sheets v3 API will be shut down on June 8, 2021.

    From this situation, I would like to propose to use Sheets API v4. If the Spreadsheet is publicly shared and you want to retrieve the values from the Spreadsheet, you can use the following endpoint using the API key. Ref

    https://sheets.googleapis.com/v4/spreadsheets/[SPREADSHEETID]/values/[RANGE]?key=[YOUR_API_KEY]
    

    In this case, [SPREADSHEETID], [RANGE] and [YOUR_API_KEY] are the Spreadsheet ID, the range (you can also use the sheet name as [RANGE].) and your API key, respectively.

    Note:

    References: