跳至主要內容

Instagram通用搜索 API (V1) ​

GET
API 端點健康狀態
健康 可用 少量可用 基本不可用 暫無資料
正在載入健康狀態…

通過關鍵詞在 Instagram 上執行通用搜索,使用基於令牌的分頁。用於發現匹配結果、研究主題,並繼續瀏覽後續結果頁。

請求參數 ​

參數名 位置 類型 必填 預設值 說明
token query string 是 - API服務的訪問令牌。
keyword query string 是 - 在 Instagram 上搜索的關鍵詞。
paginationToken query string 否 來自上一個回應的分頁令牌。第一頁請省略。

程式碼範例 ​

bash
curl --max-time 120 -X GET 'https://api.justoneapi.com/api/instagram/general-search/v1?token=YOUR_API_KEY&keyword=VALUE'
text
我想使用 JustOneAPI 提供的“通用搜索 (V1)”接口。
接入地址: https://api.justoneapi.com。
接口路徑: /api/instagram/general-search/v1?token=YOUR_API_KEY&keyword=VALUE
接口地址: BASE_URL + /api/instagram/general-search/v1?token=YOUR_API_KEY&keyword=VALUE
HTTP 方法: GET
身份驗證: 在 URL 中傳入 token 查詢參數。
OpenAPI 定義: https://docs.justoneapi.com/openapi/instagram/general-search-v1-zh-hant.json

請求參數說明:
- token (query): API服務的訪問令牌。 (必填)
- keyword (query): 在 Instagram 上搜索的關鍵詞。 (必填)
- paginationToken (query): 來自上一個回應的分頁令牌。第一頁請省略。

返回格式: 請根據實際 Content-Type 安全處理 JSON 或文本回應。

回應處理與錯誤代碼:
1. 需通過返回體中的 "code" 欄位判斷業務結果(code 為 0 表示成功)。
2. 逾時建議:建議將請求逾時時間設置為 120 秒;如果 120 秒偏長,請至少設置為 60 秒,但可能會有少量請求因逾時而未接收到結果。
3. 業務碼說明:
   - 0: 成功
   - 100: Token 無效或已失效
   - 301: 採集失敗,請重試
   - 302: 超出速率限制
   - 303: 超出每日配額
   - 400: 參數錯誤
   - 500: 內部伺服器錯誤
   - 600: 權限不足
   - 601: 帳戶餘額不足
   - 602: TOKEN 限額超限
4. code 601 表示帳戶共享餘額不足。code 602 表示當前 API TOKEN 自身的累計消費上限已達到。TOKEN 限額不是資金劃撥,多個 TOKEN 仍共享同一個帳戶餘額。

請幫我用我擅長的編程語言寫一個腳本來呼叫這個接口,並處理返回結果。
python
import requests

BASE_URL = "https://api.justoneapi.com"  # 由 OpenAPI servers 提供

url = BASE_URL + "/api/instagram/general-search/v1?token=YOUR_API_KEY&keyword=VALUE"
response = requests.get(url, timeout=120)
print(response.status_code)
if response.content:
    content_type = response.headers.get("content-type", "").lower()
    if "json" in content_type:
        try:
            print(response.json())
        except ValueError:
            print(response.text)
    elif content_type.startswith("text/") or "xml" in content_type or content_type.split(";", 1)[0].strip() in {"application/javascript", "application/x-www-form-urlencoded", "application/graphql"}:
        print(response.text)
    else:
        with open("response.bin", "wb") as output:
            output.write(response.content)
        print(f"Saved {len(response.content)} bytes to response.bin")
js
const BASE_URL = "https://api.justoneapi.com"; // 由 OpenAPI servers 提供
const url = BASE_URL + "/api/instagram/general-search/v1?token=YOUR_API_KEY&keyword=VALUE";

const response = await fetch(url, {
  method: "GET",
  signal: AbortSignal.timeout(120000)
});
console.log(response.status);
const responseBytes = await response.arrayBuffer();
if (responseBytes.byteLength) {
  const contentType = (response.headers.get("content-type") || "").toLowerCase();
  const mediaType = contentType.split(";", 1)[0].trim();
  const textual = contentType.startsWith("text/") || contentType.includes("json") || contentType.includes("xml") || ["application/javascript", "application/x-www-form-urlencoded", "application/graphql"].includes(mediaType);
  if (textual) {
    const responseText = new TextDecoder().decode(responseBytes);
    let data = responseText;
    if (contentType.includes("json")) {
      try { data = JSON.parse(responseText); } catch { /* Keep the raw body. */ }
    }
    console.log(data);
  } else {
    console.log(`Received ${responseBytes.byteLength} binary bytes`);
  }
}
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;

public class Main {
    public static void main(String[] args) throws Exception {
        final String BASE_URL = "https://api.justoneapi.com"; // 由 OpenAPI servers 提供
        final String url = BASE_URL + "/api/instagram/general-search/v1?token=YOUR_API_KEY&keyword=VALUE";

        HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(120)).build();
        HttpRequest.Builder builder = HttpRequest.newBuilder()
            .uri(URI.create(url))
            .timeout(Duration.ofSeconds(120))
            .method("GET", HttpRequest.BodyPublishers.noBody());

        HttpRequest request = builder.build();

        HttpResponse<byte[]> response = client.send(request, HttpResponse.BodyHandlers.ofByteArray());
        System.out.println(response.statusCode());
        String contentType = response.headers().firstValue("content-type").orElse("").toLowerCase();
        String mediaType = contentType.split(";", 2)[0].trim();
        if (contentType.startsWith("text/") || contentType.contains("json") || contentType.contains("xml") || mediaType.equals("application/javascript") || mediaType.equals("application/x-www-form-urlencoded") || mediaType.equals("application/graphql")) {
            System.out.println(new String(response.body(), StandardCharsets.UTF_8));
        } else {
            Files.write(Path.of("response.bin"), response.body());
            System.out.println("Saved " + response.body().length + " bytes to response.bin");
        }
    }
}
go
package main

import (
	"fmt"
	"io"
	"os"
	"strings"
	"net/http"
	"time"
)

const BASE_URL = "https://api.justoneapi.com" // 由 OpenAPI servers 提供

func main() {
	client := &http.Client{Timeout: 120 * time.Second}
	url := BASE_URL + "/api/instagram/general-search/v1?token=YOUR_API_KEY&keyword=VALUE"
	req, _ := http.NewRequest("GET", url, nil)
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	fmt.Println(resp.StatusCode)
	bodyBytes, _ := io.ReadAll(resp.Body)
	contentType := strings.ToLower(resp.Header.Get("Content-Type"))
	mediaType := strings.TrimSpace(strings.SplitN(contentType, ";", 2)[0])
	if strings.HasPrefix(contentType, "text/") || strings.Contains(contentType, "json") || strings.Contains(contentType, "xml") || mediaType == "application/javascript" || mediaType == "application/x-www-form-urlencoded" || mediaType == "application/graphql" {
		fmt.Println(string(bodyBytes))
	} else {
		os.WriteFile("response.bin", bodyBytes, 0600)
		fmt.Printf("Saved %d bytes to response.bin\n", len(bodyBytes))
	}
}
php
<?php
$BASE_URL = 'https://api.justoneapi.com'; // 由 OpenAPI servers 提供
$url = $BASE_URL . '/api/instagram/general-search/v1?token=YOUR_API_KEY&keyword=VALUE';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$contentType = strtolower((string) curl_getinfo($ch, CURLINFO_CONTENT_TYPE));
curl_close($ch);
echo $status . PHP_EOL;
$mediaType = trim(explode(';', $contentType, 2)[0]);
if (str_starts_with($contentType, 'text/') || str_contains($contentType, 'json') || str_contains($contentType, 'xml') || in_array($mediaType, ['application/javascript', 'application/x-www-form-urlencoded', 'application/graphql'], true)) {
    echo $response;
} else {
    file_put_contents('response.bin', $response);
    echo 'Saved ' . strlen($response) . ' bytes to response.bin' . PHP_EOL;
}

返回欄位 ​

業務成功時(code = 0)的主要返回欄位。

結果與續頁5 個欄位

data

Instagram 通用搜索的結果和返回時可用的續頁信息。

欄位 類型 說明
data object 本次搜索頁返回的結果。
data.count integer 本次搜索頁返回的條目數。
data.items array 本次搜索頁返回的媒體條目列表。
data.items[] object 一條 Instagram 媒體結果,欄位可以按媒體類型變化。
pagination_token string 搜索返回的續頁值。有返回時,將它作為 paginationToken 與同一關鍵詞一起傳入以獲取下一頁。
媒體信息12 個欄位

data.data.items[]

欄位 類型 說明
id string 接口返回的 Instagram 媒體標識。
code string 有返回時表示 Instagram 帖子的短代碼。
taken_at integer 帖子的 Unix 秒級時間戳。
taken_at_date string 以日期和時間文本返回的帖子時間。
media_type integer Instagram 返回的帖子媒體類型代碼。
product_type string 接口返回的 Instagram 媒體產品類型。
media_format string 接口返回的媒體格式標籤。
is_video boolean Instagram 是否將該媒體標記為視頻。
is_pinned boolean Instagram 是否將該帖子標記為置頂。
is_paid_partnership boolean 帖子是否標記為付費合作內容。
original_width integer 接口返回的原始媒體寬度。
original_height integer 接口返回的原始媒體高度。
互動資料8 個欄位

data.data.items[]

欄位 類型 說明
like_count integer 平台返回的作品點贊數。
comment_count integer 平台返回的帖子評論數。
share_count integer | null 接口返回的帖子分享數,可以為 null。
repost_count integer | null 接口返回的帖子轉發數,可以為 null。
play_count integer | null 接口返回的帖子播放量,可以為 null。
ig_like_count integer 單獨提供時,表示 Instagram 側的點贊數。
fb_like_count integer | null 接口提供時返回的 Facebook 側點贊數。
fb_play_count integer | null 接口提供時返回的 Facebook 側播放量。
文案與話題12 個欄位

data.data.items[]

欄位 類型 說明
caption_is_edited boolean 配文是否標記為已編輯。
caption object 帖子返回的說明文案信息。
caption.id string 以文本返回的說明文案標識。
caption.text string 帖子的說明文案文本。
caption.created_at integer 文案創建時間,使用 Unix 秒級時間戳。
caption.created_at_utc integer 說明文案的 UTC 創建時間,以 Unix 秒級時間戳返回。
caption.content_type string 接口返回的說明文案內容類型標籤。
caption.text_translation string | null 有提供時返回的說明文案譯文。
caption.hashtags array 說明文案中包含的話題標籤列表。
caption.hashtags[] string 說明文案中的一個話題標籤。
caption.mentions array 說明文案中提及的帳號列表。
caption.mentions[] string 說明文案中提及的一個帳號。
作者與帳號標註37 個欄位

data.data.items[]

欄位 類型 說明
caption.user object 隨說明文案返回的帳號信息。
caption.user.id string 以文本返回的 Instagram 帳號標識。
caption.user.username string 接口返回的 Instagram 帳號用戶名。
caption.user.full_name string 接口返回的 Instagram 帳號顯示名稱。
caption.user.is_private boolean Instagram 是否將該帳號標記為私密。
caption.user.is_verified boolean Instagram 是否將該帳號標記為已認證。
caption.user.profile_pic_id string Instagram 頭像圖片標識。
caption.user.profile_pic_url string 接口返回的帳號頭像圖片連結。
caption.user.follower_count integer 接口返回的 Instagram 帳號粉絲數。
user object 隨媒體返回的 Instagram 作者帳號信息。
user.id string 以文本返回的 Instagram 帳號標識。
user.username string 接口返回的 Instagram 帳號用戶名。
user.full_name string 接口返回的 Instagram 帳號顯示名稱。
user.is_private boolean Instagram 是否將該帳號標記為私密。
user.is_verified boolean Instagram 是否將該帳號標記為已認證。
user.profile_pic_id string Instagram 頭像圖片標識。
user.profile_pic_url string 接口返回的帳號頭像圖片連結。
user.follower_count integer 接口返回的 Instagram 帳號粉絲數。
coauthor_producers array 帖子所列共同作者的公開資料列表。
coauthor_producers[] object 接口返回的一位共同作者的資料。
coauthor_producers[].id string 以文本返回的 Instagram 帳號標識。
coauthor_producers[].username string 接口返回的 Instagram 帳號用戶名。
coauthor_producers[].full_name string 接口返回的 Instagram 帳號顯示名稱。
coauthor_producers[].is_private boolean Instagram 是否將該帳號標記為私密。
coauthor_producers[].is_verified boolean Instagram 是否將該帳號標記為已認證。
coauthor_producers[].profile_pic_id string Instagram 頭像圖片標識。
coauthor_producers[].profile_pic_url string 接口返回的帳號頭像圖片連結。
tagged_users array | null 有返回時表示媒體中標註的帳號列表。
tagged_users[] object 媒體中的一項帳號標註。
tagged_users[].user object 被標註帳號的資料。
tagged_users[].user.id string 以文本返回的 Instagram 帳號標識。
tagged_users[].user.username string 接口返回的 Instagram 帳號用戶名。
tagged_users[].user.full_name string 接口返回的 Instagram 帳號顯示名稱。
tagged_users[].user.is_private boolean Instagram 是否將該帳號標記為私密。
tagged_users[].user.is_verified boolean Instagram 是否將該帳號標記為已認證。
tagged_users[].user.profile_pic_id string Instagram 頭像圖片標識。
tagged_users[].user.profile_pic_url string 接口返回的帳號頭像圖片連結。
地點與 AI 標識8 個欄位

data.data.items[]

欄位 類型 說明
location object | null 有返回時表示帖子的公開地點標註。
location.id string 以文本返回的地點標註標識。
location.name string 被標註地點的顯示名稱。
location.short_name string 被標註地點的簡稱。
location.city string 接口返回的被標註地點所在城市。
ai_label_info object | null 媒體返回的 AI 標識展示信息。
ai_label_info.attribution_label_text string | null 有提供時返回的 AI 標識文案。
ai_label_info.subtitle_text string 隨 AI 標識返回的副標題文案。
圖片版本16 個欄位

data.data.items[]

欄位 類型 說明
thumbnail_url string 接口返回的媒體縮略圖連結。
image_versions object 與該媒體一起返回的圖片版本。
image_versions.items array 接口返回的媒體候選圖片列表。
image_versions.items[] object 接口返回的一張媒體候選圖片。
image_versions.items[].url string 接口返回的此圖片版本連結。
image_versions.items[].width integer 接口返回的此圖片版本寬度。
image_versions.items[].height integer 接口返回的此圖片版本高度。
image_versions.additional_items object | null 媒體的其他具名圖片版本。
image_versions.additional_items.first_frame object 接口返回的視頻首幀圖片版本。
image_versions.additional_items.first_frame.url string 接口返回的此圖片版本連結。
image_versions.additional_items.first_frame.width integer 接口返回的此圖片版本寬度。
image_versions.additional_items.first_frame.height integer 接口返回的此圖片版本高度。
image_versions.additional_items.igtv_first_frame object 回包中標為 IGTV 的首幀圖片版本。
image_versions.additional_items.igtv_first_frame.url string 接口返回的此圖片版本連結。
image_versions.additional_items.igtv_first_frame.width integer 接口返回的此圖片版本寬度。
image_versions.additional_items.igtv_first_frame.height integer 接口返回的此圖片版本高度。
視頻與字幕14 個欄位

data.data.items[]

欄位 類型 說明
has_audio boolean | null 接口是否報告該媒體帶有音頻。
video_url string 接口返回的媒體視頻播放連結。
video_duration number | null 以數值返回的視頻時長,可以為 null。
video_codec string | null 接口返回的媒體視頻編碼格式標籤。
video_versions array | null 接口返回的媒體視頻版本列表。
video_versions[] object 返回結果中的一個可用視頻版本。
video_versions[].id string 以文本返回的視頻版本標識。
video_versions[].type integer 接口返回的此視頻版本的類型代碼。
video_versions[].url string 接口返回的此視頻版本連結。
video_versions[].width integer 接口返回的此視頻版本寬度。
video_versions[].height integer 接口返回的此視頻版本高度。
video_subtitles_enabled boolean | null 接口是否報告此視頻啓用了字幕。
video_subtitles_locale string | null 接口報告的視頻字幕語言區域。
video_subtitles_uri string | null 有提供時返回的視頻字幕 URI。
輪播媒體16 個欄位

data.data.items[]

欄位 類型 說明
carousel_media_count integer | null 接口返回的輪播媒體條目數。
carousel_media array | null 輪播帖子返回的媒體條目列表。
carousel_media[] object 輪播中的一條媒體。
carousel_media[].id string 以文本返回的輪播媒體條目標識。
carousel_media[].carousel_parent_id string 接口為輪播條目返回的父級輪播標識。
carousel_media[].media_type integer 接口返回的輪播條目媒體類型代碼。
carousel_media[].is_video boolean Instagram 是否將該輪播條目標記為視頻。
carousel_media[].original_width integer 接口返回的輪播條目原始寬度。
carousel_media[].original_height integer 接口返回的輪播條目原始高度。
carousel_media[].thumbnail_url string 接口返回的輪播條目縮略圖連結。
carousel_media[].image_versions object 接口返回的輪播條目圖片版本。
carousel_media[].image_versions.items array 接口返回的輪播條目候選圖片列表。
carousel_media[].image_versions.items[] object 此輪播條目的一張候選圖片。
carousel_media[].image_versions.items[].url string 接口返回的此圖片版本連結。
carousel_media[].image_versions.items[].width integer 接口返回的此圖片版本寬度。
carousel_media[].image_versions.items[].height integer 接口返回的此圖片版本高度。
原聲音頻18 個欄位

data.data.items[].clips_metadata

部分媒體結果隨附的短視頻元資料。

欄位 類型 說明
audio_type string 接口返回的短視頻音頻類型標籤。
audio_canonical_id string 短視頻信息中返回的音頻標識。
original_sound_info object | null 隨短視頻返回的原聲音頻信息。
original_sound_info.audio_id string 以文本返回的原聲音頻標識。
original_sound_info.original_audio_title string 原聲音頻的顯示標題。
original_sound_info.original_media_id string 隨此音頻返回的原始媒體標識。
original_sound_info.duration_in_ms integer 原聲音頻時長,單位為毫秒。
original_sound_info.is_explicit boolean 原聲音頻是否帶有露骨內容標記。
original_sound_info.time_created integer 原聲音頻創建時間,以 Unix 秒級時間戳返回。
original_sound_info.progressive_download_url string 接口為原聲返回的音頻媒體連結。
original_sound_info.ig_artist object 接口為原聲音頻返回的 Instagram 藝術家資料。
original_sound_info.ig_artist.id string 以文本返回的 Instagram 帳號標識。
original_sound_info.ig_artist.username string 接口返回的 Instagram 帳號用戶名。
original_sound_info.ig_artist.full_name string 接口返回的 Instagram 帳號顯示名稱。
original_sound_info.ig_artist.is_private boolean Instagram 是否將該帳號標記為私密。
original_sound_info.ig_artist.is_verified boolean Instagram 是否將該帳號標記為已認證。
original_sound_info.ig_artist.profile_pic_id string Instagram 頭像圖片標識。
original_sound_info.ig_artist.profile_pic_url string 接口返回的帳號頭像圖片連結。
曲庫配樂29 個欄位

data.data.items[].clips_metadata

欄位 類型 說明
music_info object | null 隨短視頻返回的曲庫音樂信息。
music_info.music_asset_info object 接口返回的曲庫音樂素材信息。
music_info.music_asset_info.id string 曲庫音樂素材標識。
music_info.music_asset_info.audio_id string 曲庫音樂素材的音頻標識。
music_info.music_asset_info.artist_id string | null 有提供時表示曲庫音樂的藝術家標識。
music_info.music_asset_info.title string 接口返回的曲庫音樂標題。
music_info.music_asset_info.subtitle string 曲庫音樂信息返回的副標題。
music_info.music_asset_info.display_artist string 曲庫音樂藝術家的顯示名稱。
music_info.music_asset_info.ig_username string | null 接口返回的音樂藝術家 Instagram 用戶名。
music_info.music_asset_info.duration_in_ms integer 曲庫音樂素材時長,單位為毫秒。
music_info.music_asset_info.has_lyrics boolean 接口是否報告此音樂素材帶有歌詞。
music_info.music_asset_info.is_explicit boolean 曲庫音樂是否帶有露骨內容標記。
music_info.music_asset_info.cover_artwork_uri string 曲庫音樂的封面圖片 URI。
music_info.music_asset_info.cover_artwork_thumbnail_uri string 曲庫音樂的封面縮略圖 URI。
music_info.music_asset_info.progressive_download_url string 接口返回的曲庫音樂音頻媒體連結。
music_info.music_asset_info.fast_start_progressive_download_url string 接口返回的曲庫音樂快啓播放連結。
music_info.music_asset_info.highlight_start_times_in_ms array 接口返回的音樂素材高亮片段起始偏移量列表。
music_info.music_asset_info.highlight_start_times_in_ms[] integer 一項高亮片段的起始偏移量,單位為毫秒。
music_info.music_consumption_info object 短視頻中所用曲庫音樂片段的信息。
music_info.music_consumption_info.audio_asset_start_time_in_ms integer | null 片段在音樂素材中的起始偏移量,單位為毫秒。
music_info.music_consumption_info.overlap_duration_in_ms integer | null 接口返回的音樂與短視頻重疊的時長,單位為毫秒。
music_info.music_consumption_info.ig_artist object | null 隨所用曲庫音樂返回的 Instagram 藝術家資料。
music_info.music_consumption_info.ig_artist.id string 以文本返回的 Instagram 帳號標識。
music_info.music_consumption_info.ig_artist.username string 接口返回的 Instagram 帳號用戶名。
music_info.music_consumption_info.ig_artist.full_name string 接口返回的 Instagram 帳號顯示名稱。
music_info.music_consumption_info.ig_artist.is_private boolean Instagram 是否將該帳號標記為私密。
music_info.music_consumption_info.ig_artist.is_verified boolean Instagram 是否將該帳號標記為已認證。
music_info.music_consumption_info.ig_artist.profile_pic_id string Instagram 頭像圖片標識。
music_info.music_consumption_info.ig_artist.profile_pic_url string 接口返回的帳號頭像圖片連結。

回應示例 ​

正在載入回應範例…