> ## 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.

# 自社ドメインの Citation Share

> 自社ドメインのヘッドライン Citation Share と期間比較の差分を計算します。Profound の Citation Share タイルに表示される内容です

Profound アプリの "Citation Share" タイルには、全引用のうち自社が所有するドメインを
指す引用の割合と、同じ長さの前の期間からの変化(`+1.3% / -0.5%` の差分バッジ)が
表示されます。Visibility の期間比較と同じ 2 回呼び出しのパターンです。引用の集計を
現在の期間に 1 回、前の期間に 1 回実行し、2 つのシェアの差を
求めます。

## この例の仕組み

1. `/categories/{id}/assets` で**自社ドメインを調べます**。`is_owned` が
   付いた行を残し、その `website` と `alternate_domains` を集めます。
2. `dimensions: ["root_domain"]` を指定した**引用の呼び出し**は、引用されたドメインごとに
   1 行を返します。`root_domain` が自社ドメインのいずれかに一致する行の `citation_share` を
   合計すると、ヘッドラインの値になります。
3. **呼び出しを 2 回実行し**(現在の期間と前の期間)、2 つのシェアの差を求めて
   期間比較の差分を得ます。

<Note>
  ほとんどの Profound カテゴリでは、引用は `prompt_type`(UI のトグル)に
  スコープされます。UI のデフォルト値に合わせるには、
  `filters=[{"field": "prompt_type", "operator": "is", "value": "visibility"}]` を送信してください。
</Note>

<RequestExample>
  ```python Python theme={null}
  import os
  from datetime import date, timedelta
  from urllib.parse import urlparse
  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>"
  DAYS          = 7
  INCLUSIVE_END = date(2026, 5, 11)    # the last day of your current window


  def normalize(host_or_url):
      """Strip scheme, www, and trailing slash so domains compare cleanly."""
      p = urlparse(host_or_url if "://" in host_or_url else f"https://{host_or_url}")
      return (p.hostname or "").replace("www.", "").rstrip("/")


  def get_owned_domains(category_id):
      """All domains across assets flagged is_owned in the category."""
      out = set()
      for a in client.organizations.categories.assets(category_id):
          if not a.is_owned:
              continue
          if a.website:
              out.add(normalize(a.website))
          for d in a.alternate_domains or []:
              out.add(normalize(d))
      return out


  def get_owned_citation_share(category_id, owned_domains, start, end):
      """Sum citation_share across all rows whose root_domain is one of yours."""
      res = client.reports.citations(
          category_id=category_id,
          start_date=start.isoformat(),
          end_date=end.isoformat(),
          metrics=["count", "citation_share"],
          dimensions=["root_domain"],
          filters=[{"field": "prompt_type", "operator": "is", "value": "visibility"}],
      )
      m = res.info.query["metrics"]
      d = res.info.query["dimensions"]
      i_share  = m.index("citation_share")
      i_domain = d.index("root_domain")
      return sum(
          row.metrics[i_share]
          for row in res.data
          if normalize(row.dimensions[i_domain]) in owned_domains
      )


  def current_and_prior_windows(inclusive_end, days):
      """Two (start, end_exclusive) pairs of equal length, back-to-back."""
      current = (
          inclusive_end - timedelta(days=days - 1),
          inclusive_end + timedelta(days=1),     # +1 day → exclusive end
      )
      prior = (current[0] - timedelta(days=days), current[0])
      return current, prior


  # Helper — translate the category name to the UUID the report API expects.

  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}")


  # Resolve name → ID, then run both windows.
  category_id    = find_category_id(CATEGORY_NAME)
  owned          = get_owned_domains(category_id)
  current, prior = current_and_prior_windows(INCLUSIVE_END, DAYS)

  current_share = get_owned_citation_share(category_id, owned, *current)
  prior_share   = get_owned_citation_share(category_id, owned, *prior)
  delta_pp      = (current_share - prior_share) * 100

  print(f"Citation Share: {current_share:.1%}  ({delta_pp:+.1f} pp vs prev period)")
  ```

  ```bash curl theme={null}
  export PROFOUND_API_KEY=your_api_key_here
  export CATEGORY_ID=your-category-uuid

  # 1) Owned domains
  curl "https://api.tryprofound.com/v1/org/categories/$CATEGORY_ID/assets" \
    -H "X-API-Key: $PROFOUND_API_KEY"

  # 2a) Current window
  curl -X POST "https://api.tryprofound.com/v1/reports/citations" \
    -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": ["count", "citation_share"],
      "dimensions": ["root_domain"],
      "filters": [{"field": "prompt_type", "operator": "is", "value": "visibility"}]
    }'

  # 2b) Previous window (same body, prior dates)
  curl -X POST "https://api.tryprofound.com/v1/reports/citations" \
    -H "X-API-Key: $PROFOUND_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "category_id": "your-category-uuid",
      "start_date": "2026-04-28",
      "end_date": "2026-05-05",
      "metrics": ["count", "citation_share"],
      "dimensions": ["root_domain"],
      "filters": [{"field": "prompt_type", "operator": "is", "value": "visibility"}]
    }'
  ```
</RequestExample>
