SerpBase

地域・言語・デバイス

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 で調べます。
devicemobile(既定)または 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=5

q(必須)は地名または正規名に大文字小文字を区別せず一致します。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 StatesusNew York,New York,United States
United KingdomgbLondon,England,United Kingdom
GermanydeMunich,Bavaria,Germany
AustriaatVienna,Vienna,Austria
SwitzerlandchZurich,Zurich,Switzerland
FrancefrParis,Ile-de-France,France
ItalyitMilan,Lombardy,Italy
SpainesMadrid,Community of Madrid,Spain
PolandplWarsaw,Masovian Voivodeship,Poland
CanadacaToronto,Ontario,Canada
AustraliaauSydney,New South Wales,Australia
JapanjpTokyo,Tokyo,Japan
IndonesiaidJakarta,Jakarta,Indonesia
PhilippinesphManila,Metro Manila,Philippines
BrazilbrSao Paulo,State of Sao Paulo,Brazil
MexicomxMexico City,Mexico City,Mexico

アカウントごとに毎分 60 回まで。一覧にない location はエラーにならず無視され、location なしで検索されます。location はモバイル検索(device mobile、デフォルト)でのみ有効です。