SerpApi 互換エンドポイント
SerpApi 向けのコードは、ベース URL を変えるだけで動きます。engine 名、パラメーター、応答フィールドは同じで、料金は SerpBase の価格です。
切り替え方
https://serpapi.com/search.json を下の URL に置き換え、api_key に SerpBase のキーを指定します。SerpApi と同じく GET リクエストです。キーは X-API-Key ヘッダーでも送れ、URL やログに残りません。
BASH
curl "https://api.serpbase.dev/google/serpapi/search.json?engine=google&q=coffee&gl=us&hl=en" \
-H "X-API-Key: YOUR_API_KEY"
curl "https://api.serpbase.dev/google/serpapi/search.json?engine=amazon&k=headphones&amazon_domain=amazon.com" \
-H "X-API-Key: YOUR_API_KEY"PYTHON
import requests
res = requests.get(
"https://api.serpbase.dev/google/serpapi/search.json",
headers={"X-API-Key": "YOUR_API_KEY"},
params={"engine": "google_news", "q": "semiconductors", "gl": "us"},
)
print(res.json()["news_results"][0]["title"])対応 engine
各 engine は 2 列目の SerpBase エンドポイントで実行され、料金もそのエンドポイントと同じです。一覧にない engine は 400 で拒否されます。
| engine | 実行先 | 1 回あたりのクレジット |
|---|---|---|
google | Google Web Search | 1 |
google_images | Google Images Search | 1 |
google_news | Google News Search | 1 |
google_videos | Google Videos Search | 1 |
google_autocomplete | Google Search Autocomplete | 1 |
google_shopping | Google Shopping Search | 2 |
google_jobs | Google Jobs Search | 2 |
google_patents_details | Google Patent Details | 2 |
google_play | Google Play Search | 1 |
google_play_product | Google Play App Details | 1 |
google_trends | Google Trends | 2 |
google_trends_autocomplete | Google Trends Autocomplete | 2 |
google_trends_trending_now | Google Trends Trending Now | 2 |
google_maps | Google Maps Search | 2 |
google_maps_reviews | Google Maps Reviews | 2 |
duckduckgo | DuckDuckGo Search | 1 |
youtube | YouTube Search | 1 |
youtube_video_transcript | YouTube Video Transcripts | 2 |
amazon | Amazon Product Search | 2 |
amazon_product | Amazon Product Details | 2 |
amazon_autocomplete | Amazon Search Autocomplete | 1 |
walmart | Walmart Product Search | 2 |
walmart_product | Walmart Product Details | 2 |
ebay | eBay Product Search | 1 |
ebay_product | eBay Product Details | 2 |
apple_product | Apple Product Details | 1 |
SerpApi との違い
- 返るのは SerpBase が抽出したフィールドで、名前は SerpApi に合わせています。SerpBase が持たないフィールドは推測で埋めずに省略するため、読む前に存在を確認してください。
- 未対応:output=html(engine=google を除く)、google_maps の場所詳細(/google/maps/detail を使用)、TIMESERIES 以外の google_trends の data_type、apps 以外の Play ストア、SerpApi のアカウント・アーカイブ・非同期 API。no_cache、async、json_restrictor は受け付けますが効果はありません。
- エラーは SerpApi と同じです。拒否されたリクエストは 400・401・429 と {"error": …}、実行して失敗した検索は 200 で search_metadata.status が "Error" です。失敗した検索は課金されません。