地域・言語・デバイス
Google は同じクエリでも国・言語・都市・デバイスによって結果を変えます。4 つのパラメーターでどの結果を受け取るかを選びます。
gl · hl · location · device
| 名前 | 説明 |
|---|---|
gl | 結果の国(2 文字コード):us、gb、de、jp… |
hl | ページの言語:en、de、ja、pt-BR…。同じ市場の gl と組み合わせます。 |
location | 都市や地域から検索したことにします(例 "Munich,Bavaria,Germany")。モバイル結果のみ。名前は GET /google/locations で調べます。 |
device | mobile(既定)または pc。レイアウトが異なり、片方にしか出ないブロックもあります。 |
gl と hl はほとんどの Google エンドポイントで、device と location は Google ウェブ検索で使えます。各エンドポイントのパラメーター表に対応状況があります。料金は変わりません。
BASH
curl -X POST https://api.serpbase.dev/google/search \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"q": "coffee shops", "gl": "de", "hl": "de", "location": "Munich,Bavaria,Germany"}'検索ロケーション
Google Search の location パラメータで使える値を検索します。結果の canonical_name を /google/search の location に渡せます。このリクエストはクレジットを消費しません。
GET
0 credits
/google/locations?q=munich&country_code=de&limit=5q(必須)は地名または正規名に大文字小文字を区別せず一致します。country_code は ISO 3166-1 alpha-2 で絞り込み、limit は 1-100(既定 20)です。完全一致が先、次に広い地域の順です。同名の地名が多いため(Paris, France と Paris, Texas など)、country_code で絞り込んでください。キーは X-API-Key ヘッダーで渡してください。
BASH
curl "https://api.serpbase.dev/google/locations?q=munich&country_code=de&limit=2" \
-H "X-API-Key: your_api_key"
curl -X POST https://api.serpbase.dev/google/search \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{"q":"crossfit software","gl":"de","hl":"de","device":"mobile","location":"Munich,Bavaria,Germany"}'JSON
{
"status": 0,
"locations": [
{
"canonical_name": "Munich,Bavaria,Germany",
"name": "Munich",
"country_code": "DE",
"target_type": "City"
},
{
"canonical_name": "Taufkirchen,Munich,Bavaria,Germany",
"name": "Taufkirchen",
"country_code": "DE",
"target_type": "City"
}
]
}| 国(location の値) | gl | 都市の例 |
|---|---|---|
| United States | us | New York,New York,United States |
| United Kingdom | gb | London,England,United Kingdom |
| Germany | de | Munich,Bavaria,Germany |
| Austria | at | Vienna,Vienna,Austria |
| Switzerland | ch | Zurich,Zurich,Switzerland |
| France | fr | Paris,Ile-de-France,France |
| Italy | it | Milan,Lombardy,Italy |
| Spain | es | Madrid,Community of Madrid,Spain |
| Poland | pl | Warsaw,Masovian Voivodeship,Poland |
| Canada | ca | Toronto,Ontario,Canada |
| Australia | au | Sydney,New South Wales,Australia |
| Japan | jp | Tokyo,Tokyo,Japan |
| Indonesia | id | Jakarta,Jakarta,Indonesia |
| Philippines | ph | Manila,Metro Manila,Philippines |
| Brazil | br | Sao Paulo,State of Sao Paulo,Brazil |
| Mexico | mx | Mexico City,Mexico City,Mexico |
アカウントごとに毎分 60 回まで。一覧にない location はエラーにならず無視され、location なしで検索されます。location はモバイル検索(device mobile、デフォルト)でのみ有効です。