Google Sheets Export – How to Export a Filtered View in JSON

google sheetsgoogle-apps-scriptjson

I use Google Spreadsheets as a "web service" to generate a JSON having the information to display in my website. It is OK to export a JSON file:

var url =
 'spreadsheets.//list/1gRIVkL117xxG8m9nQRa--ChSsQOQvPqcAI4-0RTlPCg/'
 + id_spreadsheet + '/public/full?alt=json';

but I would like to do some ORDER/group operations in the backend, and to be able to export a JSON just thanks to the URL.

I understood there is a REST-API that allow me to do that but how do I export a filtered view?

A filtered view has fvid= at the end of the URL. It is OK to pass this link to a friend and to see the view filtered, but it does not work when I want to export it via JSON. I have also seen there is some SQL technique to inject in the URL in order to do it (maybe) but I am looking for the simplest solution in my context.

Best Answer

You will have to create a web app by using the Google Sheets API or Google Apps Script. If you decide to use Google Apps Script, you will have to use the HTML Service.