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

> Пошук треку в каталозі ліцензованого аудіо Instagram для прикріплення до Reel

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` для ліцензованих комерційних треків, або `original_sound` для
  аудіо, взятого з Reels інших авторів. Будь-яке інше значення повертає `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">
      ID, який передається як `audioConfiguration.audioId` під час публікації Reel.
    </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>

## Помилки

| Код | Значення |
| - | - |
| 101 | Відсутній або порожній `query`, нерозпізнаний `audioType`, або `limit` поза межами від 1 до 100. |
| 156 | Instagram не прив'язано до цього профілю. |
| 161 | Авторизація Instagram закінчилася або була відкликана. Повторно прив'яжіть обліковий запис. |
| 239 | Instagram відхилив запит з причини на рівні облікового запису, включно з недоступним треком. У пошуку це повідомляється як 239, а не як 517, який повертає ендпоінт отримання даних. |
| 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 />


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.