> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tryprofound.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 自社アセットと競合の推移を比較する

> 任意のアセットのリストについて、Visibility Score の複数折れ線グラフを作成します

Profound アプリの「自社アセット vs 競合」の複数折れ線グラフは、1 回の
呼び出しで取得できます。dimensions に `asset_name` を追加してアセットごとの行を取得し、
`in` フィルターを使って関心のあるアセットに絞り込みます。

<Warning>
  **日次の行を平均して期間スコアを算出しないでください**：両者は計算方法が
  異なります。詳しくは [規約と注意点](/ja-jp/cookbook/setup/conventions#dont-average-daily-rows-to-get-a-period-score) を参照してください。
</Warning>

## この例の仕組み

1. **`dimensions: ["date", "asset_name"]`** — (日付、アセット)ごとに 1 行。
2. **`in` 演算子を使った `filters`** — 任意に選んだアセットのセットに絞り込みます。
   フィルターを使わないと、カテゴリ内のすべてのアセットが返されます。
3. プロットする前に、**レスポンスをアセットごとに 1 つの系列へピボットします**。

<RequestExample>
  ```python Python theme={null}
  import os
  from collections import defaultdict
  from profound import Profound

  client = Profound(api_key=os.environ["PROFOUND_API_KEY"])

  # What to fetch — replace with your own values.
  CATEGORY_NAME = "<your-category-name>"
  ASSETS        = ["<your-asset>", "<competitor-1>", "<competitor-2>", "<competitor-3>"]
  START_DATE    = "2026-05-05"
  END_DATE      = "2026-05-12"   # exclusive — returns data through 2026-05-11


  def get_competitor_series(category_id, asset_names, start_date, end_date, interval="day"):
      """Daily Visibility Score for each asset in `asset_names`. Returns {asset: [(date, score), ...]}."""
      res = client.reports.visibility(
          category_id=category_id,
          start_date=start_date,
          end_date=end_date,
          metrics=["visibility_score"],
          dimensions=["date", "asset_name"],
          date_interval=interval,
          filters=[{"field": "asset_name", "operator": "in", "value": asset_names}],
      )
      m_order = res.info.query["metrics"]
      d_order = res.info.query["dimensions"]
      i_score = m_order.index("visibility_score")
      i_date  = d_order.index("date")
      i_asset = d_order.index("asset_name")

      by_asset = defaultdict(list)
      for row in res.data:
          by_asset[row.dimensions[i_asset]].append(
              (row.dimensions[i_date], row.metrics[i_score])
          )
      for asset in by_asset:
          by_asset[asset].sort(key=lambda x: x[0])
      return by_asset


  # Helpers — translate human-readable names into the IDs the report API needs.

  def find_category_id(name):
      """Return the UUID of the category whose name matches (case-insensitive)."""
      for c in client.organizations.categories.list():
          if c.name.lower() == name.lower():
              return c.id
      raise ValueError(f"No category named {name!r}")


  def find_asset_names(category_id, names):
      """Return the canonical names for each input name (case-insensitive)."""
      by_lower = {
          a.name.lower(): a.name
          for a in client.organizations.categories.assets(category_id)
      }
      out = []
      for n in names:
          if n.lower() not in by_lower:
              raise ValueError(f"No asset named {n!r} in this category")
          out.append(by_lower[n.lower()])
      return out


  # Resolve names → IDs, then run.
  category_id   = find_category_id(CATEGORY_NAME)
  canonical     = find_asset_names(category_id, ASSETS)
  series_by_asset = get_competitor_series(category_id, canonical, START_DATE, END_DATE)

  # Print a labeled table: one row per asset, one column per day.
  print(f"Daily Visibility Score · {START_DATE} → {END_DATE} (exclusive)\n")
  dates = [d for d, _ in next(iter(series_by_asset.values()))]
  print(f"{'Asset':<14} " + "  ".join(f"{d:>10}" for d in dates))
  for asset, points in series_by_asset.items():
      cells = "  ".join(f"{s:>10.1%}" for _, s in points)
      print(f"{asset:<14} {cells}")
  ```

  ```bash curl theme={null}
  export PROFOUND_API_KEY=your_api_key_here

  curl -X POST "https://api.tryprofound.com/v1/reports/visibility" \
    -H "X-API-Key: $PROFOUND_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "category_id": "your-category-uuid",
      "start_date": "2026-05-05",
      "end_date": "2026-05-12",
      "metrics": ["visibility_score"],
      "dimensions": ["date", "asset_name"],
      "date_interval": "day",
      "filters": [
        {"field": "asset_name", "operator": "in", "value": ["<your-asset>", "<competitor-1>", "<competitor-2>", "<competitor-3>"]}
      ]
    }'
  ```
</RequestExample>

## プロットする競合の選び方

アセット名のハードコードを避けるには、まず[上位 N 件の
リーダーボード](/ja-jp/cookbook/visibility/leaderboard)を取得し、スコア上位 5 件を選んで、
それらの名前をこの呼び出しの `in` フィルターに渡します。
