6.

PA-API 5.0 SearchItems レスポンス構造とフィールド一覧(旧 ItemSearch との違い)

編集
この記事の要点
  • PA-API 5.0 ではエンドポイント名が ItemSearch から SearchItems に変更(JSON)
  • トップ階層: SearchResult.Items[] に商品配列、SearchResult.TotalResultCount に総件数
  • 各 Item の主要フィールド: ASIN / DetailPageURL / Images.Primary.Large.URL / ItemInfo.Title.DisplayValue / Offers.Listings[0].Price.DisplayAmount / BrowseNodeInfo
  • エラー時は Errors[] 配列が返る (Code / Message)。HTTP 200 でも Errors 入りの場合あり
  • 取得項目は Resources パラメータで明示指定。指定しないと最小限のフィールドのみ
  • 4.0 (XML) との互換性なし。JSON ベース・キャメルケースに統一

SearchItems レスポンス全体構造

{
  "SearchResult": {
    "Items": [
      {
        "ASIN": "B08N5WRWNW",
        "DetailPageURL": "https://www.amazon.co.jp/dp/B08N5WRWNW?tag=yourid-22&linkCode=ogi&th=1&psc=1",
        "Images": {
          "Primary": {
            "Large":  { "URL": "https://m.media-amazon.com/images/I/...L.jpg",  "Width": 500, "Height": 500 },
            "Medium": { "URL": "https://m.media-amazon.com/images/I/...M.jpg",  "Width": 160, "Height": 160 },
            "Small":  { "URL": "https://m.media-amazon.com/images/I/...S.jpg",  "Width": 75,  "Height": 75 }
          },
          "Variants": [ { "Large": { "URL": "..." } } ]
        },
        "ItemInfo": {
          "Title": { "DisplayValue": "Echo Dot (第5世代)", "Label": "Title", "Locale": "ja_JP" },
          "ByLineInfo": {
            "Brand":        { "DisplayValue": "Amazon", "Label": "Brand" },
            "Manufacturer": { "DisplayValue": "Amazon", "Label": "Manufacturer" }
          },
          "Features": {
            "DisplayValues": ["特徴1", "特徴2", "特徴3"]
          },
          "Classifications": {
            "Binding":      { "DisplayValue": "エレクトロニクス" },
            "ProductGroup": { "DisplayValue": "Electronics" }
          }
        },
        "Offers": {
          "Listings": [
            {
              "Id": "abc123...",
              "Price": {
                "DisplayAmount": "¥7,480",
                "Amount":        7480,
                "Currency":      "JPY",
                "Savings":       { "DisplayAmount": "¥500", "Amount": 500, "Percentage": 6 }
              },
              "Availability": { "Message": "在庫あり", "Type": "Now" },
              "Condition":   { "Value": "New", "DisplayValue": "新品" },
              "DeliveryInfo": { "IsPrimeEligible": true, "IsFreeShippingEligible": true }
            }
          ],
          "Summaries": [
            { "Condition": { "Value": "New" }, "HighestPrice": {"Amount":7480}, "LowestPrice": {"Amount":7480}, "OfferCount": 12 }
          ]
        },
        "BrowseNodeInfo": {
          "BrowseNodes": [
            { "Id": "12345", "DisplayName": "スマートスピーカー", "ContextFreeName": "スマートスピーカー", "IsRoot": false,
              "Ancestor": { "Id": "67890", "DisplayName": "Amazon Echo" } }
          ]
        }
      }
    ],
    "TotalResultCount": 1248,
    "SearchURL": "https://www.amazon.co.jp/s?k=echo+dot&tag=yourid-22"
  }
}

主要フィールドの早見表

フィールド意味
SearchResult.Items[]ヒット商品配列
SearchResult.TotalResultCountマッチ総件数
Item.ASINAmazon Standard Identification Number (10 文字)
Item.DetailPageURLアソシエイトタグ付き商品ページ URL
Item.Images.Primary.Large.URLメイン画像 (大)
Item.ItemInfo.Title.DisplayValue商品タイトル (表示用)
Item.Offers.Listings[0].Price.DisplayAmount整形済価格(¥7,480 など)
Item.Offers.Listings[0].Price.Amount数値価格
Item.Offers.Summaries[]新品/中古別の最高・最低価格
Item.BrowseNodeInfo.BrowseNodes[]カテゴリ階層

Resources パラメータ — 取得項目を明示

SearchItems はデフォルトでは ASIN / DetailPageURL くらいしか返さない。欲しい項目を Resources で指定する必要があります:

{
  "Keywords": "echo dot",
  "SearchIndex": "Electronics",
  "ItemCount": 10,
  "PartnerTag": "yourid-22",
  "PartnerType": "Associates",
  "Marketplace": "www.amazon.co.jp",
  "Resources": [
    "Images.Primary.Large",
    "Images.Primary.Medium",
    "ItemInfo.Title",
    "ItemInfo.Features",
    "ItemInfo.ByLineInfo",
    "ItemInfo.Classifications",
    "Offers.Listings.Price",
    "Offers.Listings.Availability.Message",
    "Offers.Listings.DeliveryInfo.IsPrimeEligible",
    "Offers.Summaries.HighestPrice",
    "Offers.Summaries.LowestPrice",
    "BrowseNodeInfo.BrowseNodes",
    "ParentASIN"
  ]
}

エラーレスポンス構造

{
  "__type": "com.amazon.paapi5#ErrorData",
  "Errors": [
    {
      "Code": "InvalidParameterValue",
      "Message": "The PartnerTag is not present or is not mapped to a valid associate store with the given access key."
    }
  ]
}

注意: HTTP 200 で返ってきても SearchResult が空で Errors だけ存在するケースがある(部分エラー / 一部商品取得失敗)。両方チェックすること。

エラーコード意味対処
InvalidParameterValueパラメータ不正PartnerTag / Resources / SearchIndex を再確認
InvalidAssociateアソシエイト無効3 件売上ルール未達成・アカウント審査落ち
TooManyRequestsレート超過リクエスト頻度を下げる、Retry-After 待機
UnrecognizedClientキー / 署名不正Access Key / Secret 確認、リージョン確認
NoResults0 件ヒットキーワード / SearchIndex を見直し

4.0 (XML) → 5.0 (JSON) の主な違い

項目4.0 (旧)5.0 (現行)
形式XMLJSON
メソッド名ItemSearch / ItemLookupSearchItems / GetItems
取得項目指定ResponseGroupResources (より細かい)
署名SHA256 シンプル署名AWS SigV4
タイトル取得パスItem.ItemAttributes.TitleItem.ItemInfo.Title.DisplayValue
価格取得パスItem.OfferSummary.LowestNewPriceItem.Offers.Listings[0].Price

PHP でレスポンスをパースする例

searchItems($req);

// エラーチェック
if ($resp->getErrors() !== null) {
    foreach ($resp->getErrors() as $err) {
        error_log($err->getCode() . ': ' . $err->getMessage());
    }
}

$result = $resp->getSearchResult();
if ($result === null) return;

echo "総ヒット数: " . $result->getTotalResultCount() . "\n";

foreach ($result->getItems() ?? [] as $item) {
    $asin    = $item->getASIN();
    $url     = $item->getDetailPageURL();
    $title   = $item->getItemInfo()?->getTitle()?->getDisplayValue() ?? '(no title)';
    $image   = $item->getImages()?->getPrimary()?->getLarge()?->getURL();
    $listing = $item->getOffers()?->getListings()[0] ?? null;
    $price   = $listing?->getPrice()?->getDisplayAmount() ?? '不明';
    $isPrime = $listing?->getDeliveryInfo()?->getIsPrimeEligible() ?? false;

    echo "$asin | $title | $price" . ($isPrime ? ' [Prime]' : '') . "\n";
    echo "  $url\n  $image\n\n";
}

FAQ

Q: 価格情報が含まれない商品がある
A: 在庫切れ・販売停止商品は Offersnull。null チェック必須。Kindle 本など一部商品は Offers.Summaries のみで Listings が無いことも。

Q: Resources で指定しなかった項目は返ってこない
A: 仕様通り。デフォルトは ASIN と DetailPageURL のみ。「とりあえず全部」と指定しても、PA-API は不要項目を返さない方針なのでクォータ節約のため必要な分のみ指定推奨。

Q: アフィリエイト URL になっていない
A: PartnerTag が未指定または無効。DetailPageURL 内に tag=yourid-22 が含まれていれば OK。含まれない場合は PartnerTag 値を再確認。

編集
Post Share
子ページ

子ページはありません

同階層のページ
  1. アカウントの作成とキーの生成
  2. PA-APIの使い方 リクエストの構造とパラメータの指定
  3. リクエストにスペースを含める方法
  4. 署名認証の方法(PHPサンプル ItemSearch)
  5. エラー一覧
  6. レスポンスの構造(ItemSearch)