# Amazon PA-API v5 Search (JP / US / UK / DE) (`fruitful_quintessence/amazon-paapi-jp-actor`) Actor

Amazon Product Advertising API v5 専用 Actor.SearchItems / GetItems / GetVariations を AWS Signature V4 で署名し、co.jp / com / co.uk / de の 4 リージョンに対応.

- **URL**: https://apify.com/fruitful\_quintessence/amazon-paapi-jp-actor.md
- **Developed by:** [atushi ino](https://apify.com/fruitful_quintessence) (community)
- **Categories:** E-commerce
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Amazon PA-API v5 Actor (JP / US / UK / DE)

[![Tests](https://img.shields.io/badge/tests-70%20passing-brightgreen)]()
[![Mypy](https://img.shields.io/badge/mypy-strict-blue)]()
[![License: MIT](https://img.shields.io/badge/license-MIT-green)]()
[![Apify](https://img.shields.io/badge/Apify-Actor-orange)]()

Amazon Product Advertising API v5 (PA-API v5) 専用の Apify Actor.
**SearchItems** / **GetItems** / **GetVariations** を **AWS Signature V4** で署名して呼び出し、
4 リージョン (co.jp / com / co.uk / de) に対応する。

- **AWS Signature V4 自前実装** — `botocore` 不要、軽量ビルド
- **httpx + asyncio** — 高速・同期 I/O なしの非同期通信
- **mypy strict** — 0 errors
- **70 件の pytest** — AWS 署名 / パース / Apify 統合を全てカバー
- **Apify Store 公開対応** — 価格戦略・SEO ドキュメント同梱
- **MIT ライセンス**

***

### 特徴

| 機能 | 説明 |
|------|------|
| SearchItems | キーワード / カテゴリ / 価格フィルタ / ソート (Relevance / PriceLowToHigh / PriceHighToLow / NewestArrivals) |
| GetItems | ASIN を最大 10 件直接指定して取得 |
| GetVariations | 親 ASIN からバリエーション展開 |
| Multi-region | co.jp / com / co.uk / de を `region` 入力で切替 |

***

### 必要環境

- Python 3.11+
- Amazon アソシエイト・アカウント (Associate Tag)
- AWS IAM ユーザー (ProductAdvertisingAPI:\* ポリシー付与済み)
- (デプロイ時のみ) Apify Personal API Token

詳細は [`docs/paapi-setup.md`](docs/paapi-setup.md) を参照.

***

### インストール

```bash
git clone <your-fork-or-clone-url> amazon-paapi-jp-actor
cd amazon-paapi-jp-actor
pip install -r requirements.txt -r requirements-dev.txt
```

***

### ローカル実行

`.env` を `.env.example` からコピーして値を埋める:

```bash
cp .env.example .env
set -a; source .env; set +a
```

#### テスト実行

```bash
## 全 70 件のテスト.
python3 -m pytest tests/ -v

## AWS Signature V4 関連.
python3 -m pytest tests/test_paapi_client.py -v

## 型チェック (mypy strict).
mypy src/
```

#### smoke test (実 API を 1 回呼ぶ)

```bash
LOCAL_KEYWORD="Nintendo Switch" LOCAL_MAX_ITEMS=5 python3 -m src
```

ログに「取得件数: N」と表示されれば成功.

***

### Apify へのデプロイ

```bash
export APIFY_TOKEN=apify_api_xxxxxxxxxxxx
python3 scripts/deploy_apify.py
```

スクリプトは次の順に処理:

1. Actor を作成 (既存なら再利用)
2. Version 作成 (ソースコードを TAR でアップロード)
3. ビルドを起動
4. ビルド完了までポーリング

詳細は [`docs/deploy-guide.md`](docs/deploy-guide.md) を参照.

***

### Apify INPUT\_SCHEMA

| フィールド | 型 | 必須 | デフォルト | 説明 |
|-----------|----|------|----------|------|
| keyword | string | ✓ | — | 検索キーワード (1〜200 文字) |
| category | string | — | — | Amazon の SearchIndex (例: Electronics) |
| maxItems | int | — | 10 | 1〜10 (PA-API v5 上限) |
| sortBy | enum | — | Relevance | Relevance / PriceLowToHigh / PriceHighToLow / NewestArrivals |
| minPrice | int | — | — | 最低価格 |
| maxPrice | int | — | — | 最高価格 |
| region | enum | — | co.jp | co.jp / com / co.uk / de |

***

### 出力フォーマット

各レコードは以下のキーを持つ:

```json
{
  "asin": "B08N5WRWNW",
  "title": "Echo Dot (第4世代) - スマートスピーカー",
  "url": "https://www.amazon.co.jp/dp/B08N5WRWNW",
  "imageUrl": "https://m.media-amazon.com/images/I/echodot.jpg",
  "price": "¥5,980",
  "currency": "JPY",
  "listPrice": "¥7,980",
  "discountPercent": 25,
  "rating": "4.7",
  "reviewCount": "1234",
  "availability": "在庫あり",
  "isPrime": true,
  "category": "CE",
  "scrapedAt": "2026-09-05T15:00:00Z"
}
```

***

### ディレクトリ構成

```
amazon-paapi-jp-actor/
├── .actor/
│   ├── actor.json         # Apify Actor メタデータ
│   └── INPUT_SCHEMA.json  # 入力フォーム定義
├── src/
│   ├── __init__.py        # パッケージマーカー
│   ├── __main__.py        # `python3 -m src` エントリポイント
│   ├── main.py            # Apify Actor の main()
│   ├── paapi_client.py    # AWS Signature V4 + httpx クライアント
│   ├── parser.py          # PA-API レスポンス → ProductRecord
│   └── models.py          # TypedDict / 定数定義
├── tests/
│   ├── conftest.py
│   ├── test_paapi_client.py   # AWS 署名 + httpx モック (45 tests)
│   ├── test_parser.py         # パーサ (17 tests)
│   └── test_main.py           # Actor 統合 (13 tests)
├── scripts/
│   └── deploy_apify.py    # ワンコマンドデプロイ
├── docs/
│   ├── paapi-setup.md          # PA-API 認証情報セットアップ
│   ├── deploy-guide.md         # Apify デプロイ手順
│   └── seo-keyword-strategy.md # SEO キーワード戦略
├── Dockerfile
├── requirements.txt
├── requirements-dev.txt
├── mypy.ini
├── .env.example
├── .gitignore
├── LICENSE                  # MIT
└── README.md                # このファイル
```

***

### 開発メモ

- PA-API v5 は **1 req/sec** のレート制限. 連続実行を避け、必要なら `sleep_ms` 入力で待機を入れる.
- AWS Signature V4 は [`docs/paapi-setup.md`](docs/paapi-setup.md) の IAM ポリシーが必要.
- `mypy.ini` で `strict = True` を有効化済み. CI で 0 errors を維持すること.
- テストは全て httpx をモック化しており、実 API の呼び出しは行わない (1 テスト 0.1 秒以下).

***

### ライセンス

MIT License — 詳細は [LICENSE](LICENSE) を参照.

# Actor input Schema

## `keyword` (type: `string`):

Amazon で検索したいキーワード (例: Nintendo Switch, MacBook Pro).

## `category` (type: `string`):

Amazon の SearchIndex (例: Electronics, Books, Home). 省略可.

## `maxItems` (type: `integer`):

取得する最大商品数 (1-10、PA-API v5 の上限 10).

## `sortBy` (type: `string`):

Relevance / PriceLowToHigh / PriceHighToLow / NewestArrivals

## `minPrice` (type: `integer`):

この価格 (整数) 以上の商品のみ取得. 通貨は Marketplace のデフォルト通貨.

## `maxPrice` (type: `integer`):

この価格 (整数) 以下の商品のみ取得. 通貨は Marketplace のデフォルト通貨.

## `region` (type: `string`):

co.jp (日本) / com (米国) / co.uk (英国) / de (ドイツ)

## Actor input object example

```json
{
  "maxItems": 10,
  "sortBy": "Relevance",
  "region": "co.jp"
}
```

# Actor output Schema

## `asin` (type: `string`):

Amazon Standard Identification Number

## `title` (type: `string`):

商品名

## `url` (type: `string`):

商品ページのURL

## `imageUrl` (type: `string`):

商品画像のURL

## `price` (type: `string`):

現在価格 (DisplayAmount)

## `currency` (type: `string`):

通貨コード (JPY/USD/GBP/EUR)

## `listPrice` (type: `string`):

元値 (SavingBasis.DisplayAmount)

## `discountPercent` (type: `string`):

割引率 (0-100, 空文字可)

## `rating` (type: `string`):

評価 (例: 4.5)

## `reviewCount` (type: `string`):

レビュー件数

## `availability` (type: `string`):

在庫メッセージ (例: 在庫あり)

## `isPrime` (type: `string`):

Amazon Prime 対応可否 (true/false/空文字)

## `category` (type: `string`):

商品カテゴリ (ProductGroup)

## `scrapedAt` (type: `string`):

データ取得日時 (ISO 8601 UTC)

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("fruitful_quintessence/amazon-paapi-jp-actor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("fruitful_quintessence/amazon-paapi-jp-actor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call fruitful_quintessence/amazon-paapi-jp-actor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,fruitful_quintessence/amazon-paapi-jp-actor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/doneSfO13IuNgcWPk/builds/VagG7ViplRbeIfAdw/openapi.json
