1

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}

2
  • "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. Commented May 13, 2017 at 3:27
  • 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. Commented May 13, 2017 at 7:14

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

The JSON response starts like this: google.visualization.Query.setResponse(JSON); How do I just get the JSON? Why would google put the JSON inside a function like that??

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.