Skip to content

Latest commit

 

History

History
executable file
·
32 lines (23 loc) · 1.06 KB

googleapi.md

File metadata and controls

executable file
·
32 lines (23 loc) · 1.06 KB

Sheets API

  1. Go to console.developers.google.com
  2. Create a project.
  3. Go to console.developers.google.com/apis/credentials and create API key for the project.
  4. Set the sheet to public for the request to work.

The sheet can be public i.e. Anyone who has the link can view, and be only editable privately. This avoids the OAuth part.

let sheet = "c750833d5021f60a1b8ff8bf0a21bb9dc74cff12";
let range = "Sheet 1!A:B";
let apiKey = "6e0ece719a48d5334369bd881b4324aa957e4407";

let url = `https://sheets.googleapis.com/v4/spreadsheets/${sheet}/values/${range}?key=${apiKey}`;

// https://sheets.googleapis.com/v4/spreadsheets/c750833d5021f60a1b8ff8bf0a21bb9dc74cff12/values/Sheet 1!A:B?key=6e0ece719a48d5334369bd881b4324aa957e4407

fetch(url)
    .then((res) => res.json())
    .then((data) => {
        console.log(data);
    })
    .catch((err) => err);

Private sheet

With private user data you would need to use OAuth.

  1. Go to console.developers.google.com/apis/library and pick Sheets.
  2. Configure OAuth.