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

# Instagram オーディオを検索

> Reel に添付する楽曲を Instagram のライセンス済みオーディオカタログから検索する

export const InstagramAudioNotice = () => <Warning>
  <strong>Requires Instagram linked through Facebook Login.</strong> Instagram's Audio API is only available to accounts connected via <strong>Facebook Login</strong>, which needs a Facebook Page connected to the Instagram account. Accounts connected with <strong>Instagram Login</strong> (the Ayrshare default) cannot search, look up, or attach audio, and every audio request returns <code>code: 514</code>.
  <br /><br />
  This is a Meta restriction, not an Ayrshare one. Meta's documentation states the Audio API "is only available on the Instagram API with Facebook Login. It is not supported on the Instagram API with Instagram Login." No permission or plan upgrade changes it.
  <br /><br />
  <strong>Three things are required:</strong>
  <br />
  1. An Instagram <strong>Business</strong> or <strong>Creator</strong> account<br />
  2. A <strong>Facebook Page connected</strong> to that Instagram account<br />
  3. Instagram linked to Ayrshare with <strong>Instagram Login disabled</strong>, so the Facebook Login flow is used
  <br /><br />
  See the <a href="/docs/dashboard/connect-social-accounts/instagram#music-attach-eligibility-facebook-login-required">step-by-step setup guide</a>.
</Warning>;

export const PlansAvailable = ({plans = [], maxPackRequired}) => {
  let displayPlans = plans;
  if (plans && plans.length === 1) {
    const lowerCasePlan = plans[0].toLowerCase();
    if (lowerCasePlan === "business") {
      displayPlans = ["Launch", "Business", "Enterprise"];
    } else if (lowerCasePlan === "premium") {
      displayPlans = ["Premium", "Launch", "Business", "Enterprise"];
    }
  }
  return <Note>
Available on {displayPlans.length === 1 ? "the " : ""}
{displayPlans.join(", ").replace(/\b\w/g, l => l.toUpperCase())}{" "}
{displayPlans.length > 1 ? "plans" : "plan"}.

{maxPackRequired && <span onClick={() => window.open('https://www.ayrshare.com/docs/additional/maxpack', '_self')} className="flex items-center mt-2 cursor-pointer">
 <span className="px-1.5 py-0.5 rounded text-sm" style={{
    backgroundColor: '#C264B6',
    color: 'white',
    fontSize: '12px'
  }}>
   Max Pack required
 </span>
</span>}
</Note>;
};

export const HeaderAPI = ({noProfileKey, profileKeyRequired}) => <>
    <ParamField header="Authorization" type="string" required>
      <a href="/docs/apis/overview#authorization">API Key</a> of the Primary Profile.
      <br />
      <br />
      Format: <code>Authorization: Bearer API_KEY</code>
    </ParamField>
    {!noProfileKey && (profileKeyRequired ? <ParamField header="Profile-Key" type="string" required>
          <a href="/docs/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField> : <ParamField header="Profile-Key" type="string">
          <a href="/docs/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField>)}
  </>;

<PlansAvailable plans={["premium"]} maxPackRequired={false} />

キーワードで Instagram のオーディオカタログを検索します。返された `audioId` を [`instagramOptions.audioConfiguration`](/docs/apis/post/social-networks/instagram#adding-music-to-a-reel) で使用すると、Reel の公開時にその楽曲を添付できます。

<InstagramAudioNotice />

## ヘッダーパラメータ

<HeaderAPI />

## クエリパラメータ

<ParamField query="query" type="string" required>
  アーティスト名や楽曲名などの検索キーワード。空の値や空白のみの値は `code: 101` を返します。
</ParamField>

<ParamField query="audioType" type="string" default="music">
  検索対象のカタログ。ライセンスされた商用楽曲は `music`、他のクリエイターの Reels から取得されたオーディオは
  `original_sound` を指定します。それ以外の値は `code: 101` を返します。
</ParamField>

<ParamField query="limit" type="integer">
  返される楽曲の最大数で、`1` から `100` までです。整数でない値や範囲外の値は `code: 101` を返します。
  省略した場合は、Instagram 自身のデフォルトが適用されます。
</ParamField>

## レスポンスフィールド

Instagram はすべての楽曲についてすべてのフィールドを返すとは限らないため、`audioId` 以外のすべての楽曲フィールドはオプションとして扱ってください。

<ResponseField name="status" type="string">
  検索が完了した場合は `success`。カタログに一致がない場合も成功として扱われます。
</ResponseField>

<ResponseField name="query" type="string">
  検索されたキーワードがそのまま返されます。
</ResponseField>

<ResponseField name="audio" type="array">
  一致した楽曲。空の配列は、検索は実行されたものの何も一致しなかったことを意味します。

  <Expandable title="楽曲フィールド">
    <ResponseField name="audioId" type="string">
      Reel の公開時に `audioConfiguration.audioId` として渡す ID。
    </ResponseField>

    <ResponseField name="title" type="string">楽曲のタイトル。</ResponseField>
    <ResponseField name="displayArtist" type="string">Instagram が表示するアーティスト名。</ResponseField>
    <ResponseField name="durationMs" type="integer">楽曲の長さ（ミリ秒）。</ResponseField>
    <ResponseField name="thumbnailUrl" type="string">カバーアートワークのサムネイル URL。</ResponseField>
    <ResponseField name="audioType" type="string">`music` または `original_sound` のいずれか。</ResponseField>

    <ResponseField name="isAdsEligible" type="boolean">
      その楽曲を広告で使用できるかどうか。ライセンスされた音楽は、オーガニックな Reel では利用可能でも、
      広告では利用できないことがよくあります。
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseExample>
  ```json 200: Success theme={"system"}
  {
    "status": "success",
    "query": "summer",
    "audio": [
      {
        "audioId": "17901234567890123",
        "title": "Summer Nights",
        "displayArtist": "The Example Band",
        "durationMs": 32000,
        "thumbnailUrl": "https://scontent.example.com/cover.jpg",
        "audioType": "music",
        "isAdsEligible": true
      }
    ]
  }
  ```

  ```json 200: No matches theme={"system"}
  {
    "status": "success",
    "query": "asdfghjkl",
    "audio": []
  }
  ```

  ```json 400: Instagram Login account theme={"system"}
  {
    "status": "error",
    "code": 514,
    "action": "post",
    "message": "Adding music to a Reel requires an Instagram account connected via Facebook Login. This profile is connected with Instagram Login, which Meta does not permit for music attach, search, or lookup. Please relink Instagram using Facebook Login and grant the instagram_content_publish permission, then try again.",
    "platform": "instagram"
  }
  ```
</ResponseExample>

## エラー

| Code | 意味                                                                                         |
| ---- | ------------------------------------------------------------------------------------------ |
| 101  | `query` の欠落または空、認識されない `audioType`、または 1 から 100 の範囲外の `limit`。                             |
| 156  | Instagram がこのプロファイルに連携されていません。                                                             |
| 161  | Instagram の認可が期限切れになったか取り消されました。アカウントを再連携してください。                                           |
| 239  | 利用できない楽曲を含む、アカウントレベルの理由により Instagram がリクエストを拒否しました。検索では、照会エンドポイントが返す 517 ではなく 239 が報告されます。 |
| 258  | Instagram が不正な形式のレスポンス、またはマッピングされていない失敗を返しました。                                             |
| 425  | 接続に必要な Instagram の権限が不足しています。再連携してすべての権限を付与してください。                                         |
| 435  | Instagram のレート制限に達しました。しばらく待ってから再試行してください。                                                 |
| 514  | Instagram が Instagram Login で連携されています。Audio API には Facebook Login が必要です。                   |

コード 514 から 518 については [Instagram Reels オーディオエラー](/docs/errors/errors-ayrshare#instagram-reels-audio-errors) で説明されています。その他については [Ayrshare エラーリファレンス](/docs/errors/errors-ayrshare) を参照してください。

## 次のステップ

<Card title="楽曲を Reel に添付する" icon="music" href="/docs/apis/post/social-networks/instagram#adding-music-to-a-reel" horizontal />

<Card title="単一の楽曲を照会する" icon="magnifying-glass" href="/docs/apis/media/get-instagram-audio" horizontal />
