1
votes

I want to send an SQL query to Google Sheets REST API, which returns JSON for values, instead of HTML or JSONP(text)

The API i am talking about is this: https://developers.google.com/sheets/api/reference/rest/

But i cannot see any Reference for giving SQL query as part of the API. Is this not possible?

Google Sheets does allow to process SQL query but it is giving me only HTML or some text based JSONP data back, instead of pure json.

The endpoint i am using is this:

GET https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/{range}

1
"Google Sheets does allow to process SQL query" -- could you point out the API you're using the SQL query to? AFAIK, there is the Google Query Function which is similar to SQL, but not exactly the same.AL.
Hi AL, Thanks for your comment. I am using this API: developers.google.com/sheets/api/reference/rest In your document, it describes how to use the SQL like query in the Google Sheets itself. I am looking for this capability in the API. Thanks again for your help.vinit

1 Answers

1
votes

Check out my SO answer to another question which may contain what you're seeking — https://stackoverflow.com/a/37868852/305689 — be sure to read the actual question above, esp. the tail end of it.

I didn't mention this in the other answer, but the response defaults to JSON, however you can also select HTML or CSV with the tqx variable. See this page in the docs.

Also, I don't believe it works with the spreadsheets.readonly scope yet, so if you do this, read these authorization instructions.