Public Google Sheets Parser


It is a simple and zero dependency parser that helps you use public Google sheets document as if they were a database.
The document to be used must be a Google Sheets document in the 'public' state and have a header in the first row. (e.g. Google sheets for example)
You can optionally specify the sheet's tab name to get data from that specific sheet. (Since v1.1.0)
You can optionally specify the sheet's GID to get data from that specific sheet. (Since v1.3.0)
It does not work in browsers where the fetch API is not available.
No API key required. This means that the server does not need to use the private key to use the SDK.
You can also use it via free API. Please see this documentation.
If you have a public spreadsheet document, and the first row is a header and you have more than one row of data, you can call it free of charge through this API and use the result as a JSON response.
Demo page
Click here
Installation
With yarn:
$ yarn add public-google-sheets-parser
With npm:
$ npm i public-google-sheets-parser
Usage example
const PublicGoogleSheetsParser = require('public-google-sheets-parser')
const spreadsheetId = '10WDbAPAY7Xl5DT36VuMheTPTTpqx9x0C5sDCnh4BGps'
const parser = new PublicGoogleSheetsParser(spreadsheetId)
parser.parse().then((items) => {
})
const anotherSpreadsheetId = '1oCgY0UHHRQ95snw7URFpOOL_DQcVG_wydlOoGiTof5E'
parser.id = anotherSpreadsheetId
parser.parse().then((items) => {
})
parser.parse(spreadsheetId).then((items) => {
})
parser.parse(spreadsheetId, 'Sheet2').then((items) => {
})
parser.parse(spreadsheetId, { sheetId: '784337977' }).then((items) => {
})
const parser = new PublicGoogleSheetsParser(spreadsheetId, { sheetId: '784337977'})
parser.parse().then((items) => {
})
You can use any of the 4 methods you want!
- with import (Vue.js or whatever)
import PublicGoogleSheetsParser from 'public-google-sheets-parser'
export default {
data () {
return {
items: [],
}
},
computed: {
parser () {
return new PublicGoogleSheetsParser()
},
},
methods: {
async getItems (spreadsheetId) {
this.items = await this.parser.parse(spreadsheetId)
},
},
}
<script src="https://cdn.jsdelivr.net/npm/public-google-sheets-parser@latest"></script>
<script>
const spreadsheetId = '10WDbAPAY7Xl5DT36VuMheTPTTpqx9x0C5sDCnh4BGps'
const parser = new PublicGoogleSheetsParser()
parser.parse(spreadsheetId).then((items) => {
})
parser.parse(spreadsheetId, 'Sheet2').then((items) => {
})
</script>
curl -X GET "https://api.fureweb.com/spreadsheets/10WDbAPAY7Xl5DT36VuMheTPTTpqx9x0C5sDCnh4BGps" -H "accept: */*"
{"data":[{"a":1,"b":2,"c":3},{"a":4,"b":5,"c":6},{"a":7,"b":8,"c":9}]}
That's it!