Google Sheets – How to View Google Visualization API Query URL as Table

google sheets

What is the correct syntax for the URL (see also a related question about documentation) to view a Google Visualization API Query result as a web page containing the tabulated results of the query? "Directly" in the question subject line implies these constraints:

  1. From the URL only, and,
  2. Not requiring separate special web pages that read that Javascript output and reformulate it, and,
  3. Not requiring manual cut and paste operations, and
  4. Not requiring a bridge through a Google document that has to be created (since I want just a direct URL to render the page),

My failed attempt: My query is of the form (key value CENSORED):

http://spreadsheets.google.com/a/google.com/tq?key=CENSORED&tq=SELECT%20*%20WHERE%20lower(C)%20CONTAINS%20'something'

Browsing to that page dumps out the result as one long Javascript call containing JSON encoded info. Useful for programmers I bet, but not for direct viewing of a query result just by browsing to the query URL.

Tacking on a "&output=html":

http://spreadsheets.google.com/a/google.com/tq?key=CENSORED&tq=SELECT%20*%20WHERE%20lower(C)%20CONTAINS%20'something'&output=html

Does not change the output. Obviously "output=html" is not recognized or is ignored (guessing the syntax from Google Spreadsheets URL Syntax and Display Options?). This should be documented but I could not find it (hence another related question)

Best Answer

Try this: addition for html output in bold.

http://spreadsheets.google.com/a/google.com/tq?tqx=out:html&tq=key=CENSORED&tq=SELECT%20*%20WHERE%20lower(C)%20CONTAINS%20'something'

or the way google usually rearranges it:

http://docs.google.com/spreadsheets/d/CENSORED/tq?tqx=out:html&tq=key=CENSORED&tq=SELECT%20*%20WHERE%20lower(C)%20CONTAINS%20'something'