Google Suggest API

Google Suggestの、検索キーワードの候補を取得できます。

http://www.google.com/complete/search?
パラメータ 説明
q 検索キーワード
hl 言語
output 「toolbar」と指定することで、XML形式で結果が返されるようになる
json JSON形式で結果が返されるようになる
(値は任意。「true」などと指定する必要はない)

出力形式には次の3種類があり、これを明示しない場合にはJavaScript形式となります。

現在ではXML形式以外は無効となっており、「400 Bad Request」が返されます。

JavaScript形式

廃止されています。

http://www.google.com/complete/search?hl=en&q=hello
window.google.ac.h(
    ["hello",[
        ["hello kitty","","0"],
        ["hello","","1"],
        ["hello world lyrics","","2"],
        ["hello kitty games","","3"],
        ["hello dolly","","4"],
        ["hellogoodbye","","5"],
        ["hello lyrics","","6"],
        ["hello world","","7"],
        ["hello cupcake","","8"],
        ["hello in russian","","9"]
        ],
        {}]
    )
※改行して書式を整えてあります。

XML形式

http://www.google.com/complete/search?hl=en&q=hello&output=toolbar
<?xml version="1.0"?>
<toplevel>
  <CompleteSuggestion>
    <suggestion data="hello kitty" />
    <num_queries int="108000000" />
  </CompleteSuggestion>
  <CompleteSuggestion>
    <suggestion data="hello" />
    <num_queries int="798000000" />
  </CompleteSuggestion>
  <CompleteSuggestion>
    <suggestion data="hello world lyrics" />
    <num_queries int="4260000" />
  </CompleteSuggestion>
  <CompleteSuggestion>
    <suggestion data="hello kitty games" />
    <num_queries int="37500000" />
  </CompleteSuggestion>
  <CompleteSuggestion>
    <suggestion data="hello dolly" />
    <num_queries int="2070000" />
  </CompleteSuggestion>
  <CompleteSuggestion>
    <suggestion data="hellogoodbye" />
    <num_queries int="2500000" />
  </CompleteSuggestion>
  <CompleteSuggestion>
    <suggestion data="hello lyrics" />
    <num_queries int="7100000" />
  </CompleteSuggestion>
  <CompleteSuggestion>
    <suggestion data="hello world" />
    <num_queries int="71400000" />
  </CompleteSuggestion>
  <CompleteSuggestion>
    <suggestion data="hello cupcake" />
    <num_queries int="7300000" />
  </CompleteSuggestion>
  <CompleteSuggestion>
    <suggestion data="hello in russian" />
    <num_queries int="60500000" />
  </CompleteSuggestion>
</toplevel>

使用例

検索キーワード
言語

JSON形式

廃止されています。

http://www.google.com/complete/search?hl=en&q=hello&json=true
["hello",
  ["hello kitty","hello","hello world lyrics","hello kitty games","hello dolly","hellogoodbye","hello lyrics","hello world","hello cupcake","hello in russian"],
  ["","","","","","","","","",""]
]
※改行して書式を整えてあります。

Google Suggestを利用したサービス