搜尋 Instagram 音訊
curl --request GET \
--url https://api.ayrshare.com/api/media/instagram/audio/search \
--header 'Authorization: Bearer <token>'const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.ayrshare.com/api/media/instagram/audio/search', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.ayrshare.com/api/media/instagram/audio/search"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/media/instagram/audio/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.ayrshare.com/api/media/instagram/audio/search"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.ayrshare.com/api/media/instagram/audio/search")
.header("Authorization", "Bearer <token>")
.asString();{
"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
}
]
}
{
"status": "success",
"query": "asdfghjkl",
"audio": []
}
{
"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"
}
Media
搜尋 Instagram 音訊
搜尋 Instagram 的授權音訊目錄,尋找可附加到 Reel 的曲目
GET
/
media
/
instagram
/
audio
/
search
搜尋 Instagram 音訊
curl --request GET \
--url https://api.ayrshare.com/api/media/instagram/audio/search \
--header 'Authorization: Bearer <token>'const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.ayrshare.com/api/media/instagram/audio/search', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.ayrshare.com/api/media/instagram/audio/search"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/media/instagram/audio/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.ayrshare.com/api/media/instagram/audio/search"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.ayrshare.com/api/media/instagram/audio/search")
.header("Authorization", "Bearer <token>")
.asString();{
"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
}
]
}
{
"status": "success",
"query": "asdfghjkl",
"audio": []
}
{
"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"
}
以關鍵字搜尋 Instagram 的音訊目錄。將回傳的
錯誤碼 514 到 518 的說明請參閱 Instagram Reels 音訊錯誤;其餘錯誤碼請參閱 Ayrshare 錯誤參考。
audioId 搭配 instagramOptions.audioConfiguration 使用,即可在發布 Reel 時附加該曲目。
標頭參數
查詢參數
string
必填
要搜尋的關鍵字,例如藝人或曲目名稱。空值或僅含空白字元的值會回傳
code: 101。string
預設值:"music"
要搜尋的目錄。
music 代表授權的商業曲目,original_sound 代表取自
其他創作者 Reels 的音訊。其他任何值會回傳 code: 101。integer
要回傳的曲目數量上限,介於
1 到 100 之間。非整數或超出範圍的值會回傳
code: 101。省略時,套用 Instagram 自身的預設值。回應欄位
Instagram 不會為每首曲目回傳所有欄位,因此除audioId 以外的所有曲目欄位都應視為選填。
string
搜尋完成時為
success。即使目錄中沒有符合項目,仍屬於成功。string
所搜尋的關鍵字,原樣回傳。
array
{
"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
}
]
}
{
"status": "success",
"query": "asdfghjkl",
"audio": []
}
{
"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"
}
錯誤
| Code | 意義 |
|---|---|
| 101 | query 缺少或為空、audioType 無法識別,或 limit 超出 1 到 100 的範圍。 |
| 156 | Instagram 尚未連結至此 Profile。 |
| 161 | Instagram 的授權已過期或被撤銷。請重新連結帳號。 |
| 239 | Instagram 因帳號層級的原因拒絕了請求,包括曲目無法使用。在搜尋端點上會回報 239,而非查詢端點回傳的 517。 |
| 258 | Instagram 回傳了格式錯誤的回應或未對應的失敗。 |
| 425 | 此連結缺少必要的 Instagram 權限。請重新連結並授予所有權限。 |
| 435 | 已達 Instagram 的速率限制。請稍候再重試。 |
| 514 | Instagram 是以 Instagram Login 連結的。Audio API 需要 Facebook Login。 |