Public Google Sheets Parser


Demo page
https://fureweb-com.github.io/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 that you intend to use must be a Google Sheet that is set to "public" and must contain a header in the first row. For instance, you can use a Google Sheet like the one in the example provided.
You have the option to specify the name of the sheet's tab to retrieve data from a specific sheet. This feature has been available since version 1.1.0. Additionally, you can also specify the sheet's GID to obtain data from a specific sheet. This feature has been added since version 1.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.
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!