Reputation: 138
Can you some help to get google sheets multiple tabs data as single JSON ?
Upvotes: 0
Views: 879
Reputation: 15357
You can use the Sheets API to get the data of each sheet pre-compiled as a JSON.
The spreadsheets.get endpoint of the Google Sheets API allows you to get the data from a Spreadsheet by specifying the Spreadsheet ID. The URL for the endpoint is:
https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET-ID
You can use a field mask to narrow down the data in the response you get from the API. In order to only get the Sheet name and the data, you can use:
sheets(properties/title,data/rowData/values/userEnteredValue)
to test using the Try this API, or if using the URL directly:
https://sheets.googleapis.com/v4/spreadsheets/yourSpreadsheetId?fields=sheets(properties/title,data/rowData/values/userEnteredValue)
{
"sheets": [
{
"properties": {
"title": "Sheet1"
},
"data": [
{
"rowData": [
{
"values": [
{
"userEnteredValue": {
"numberValue": 1
}
},
{
"userEnteredValue": {
"numberValue": 12
}
}
]
},
{
"values": [
{},
{},
{
"userEnteredValue": {
"numberValue": 123
}
}
]
}
]
}
]
}
]
}
Upvotes: 2