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

# Phân tích Bài đăng theo Social ID

> Nhận dữ liệu phân tích theo thời gian thực cho các bài đăng bằng cách sử dụng Social Post ID

export const XByoNotice = () => <Info>
  <strong>Targeting X/Twitter?</strong> Starting March 31, 2026, all X operations require your own API credentials. After linking X via OAuth, include these 2 headers in your request:
  <br /><br />
  <code>X-Twitter-OAuth1-Api-Key</code> — Your API Key (Consumer Key)<br />
  <code>X-Twitter-OAuth1-Api-Secret</code> — Your API Key Secret (Consumer Secret)
  <br /><br />
  <strong>One-time setup per Ayrshare account.</strong> You create one X Developer App and reuse the same API Key and Secret across every sub-profile / end-user you link. You do <em>not</em> create a new app per customer.
  <br /><br />
  Not linked yet? See the <a href="/dashboard/connect-social-accounts/x-twitter-byo-keys">full setup guide</a> to connect your X account.
  <br /><br />
  Your keys are never logged or stored by Ayrshare.
</Info>;

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="/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="/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="/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField>)}
  </>;

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

<XByoNotice />

Truy xuất dữ liệu phân tích cho các bài đăng không có nguồn gốc từ Ayrshare bằng cách cung cấp [Social Post ID](/apis/overview#social-post-id) cấp thấp.
ID này được trả về trong trường `postIds` của [endpoint /post](/apis/post/post).

Tài khoản được liên kết phải là chủ sở hữu của bài đăng để truy xuất dữ liệu phân tích (ngoại lệ: YouTube; xem bên dưới). Các nền tảng được hỗ trợ: `Facebook`, `Instagram`, `LinkedIn`, `Threads`, `TikTok`, `Twitter`, và `YouTube`.

<ul className="custom-bullets">
  <li>
    Lệnh gọi giống với [endpoint Phân tích một Bài đăng](/apis/analytics/post). Sự khác biệt chính là
    bạn sử dụng post id được trả về bởi mạng xã hội thay vì Ayrshare ID. Đồng thời
    hãy bao gồm tham số `searchPlatformId: true` để thông báo cho endpoint biết rằng bạn đang tìm kiếm theo
    Social Post ID.
  </li>

  <li>
    Sử dụng [endpoint Get All Post History](/apis/history/overview) để truy xuất các bài đăng và ID
    có nguồn gốc bên ngoài Ayrshare được tìm thấy trong trường `id`.
  </li>

  <li>
    Chỉ khuyến nghị sử dụng cho các bài đăng không được gửi qua Ayrshare. Đối với các bài đăng được gửi qua Ayrshare, hãy sử dụng
    [endpoint analytics](/apis/analytics/post).
  </li>

  <li>
    Phân tích trên các bài đăng Instagram được xuất bản trước khi tài khoản của người dùng được chuyển đổi thành
    tài khoản doanh nghiệp từ tài khoản cá nhân sẽ có dữ liệu phân tích hạn chế.
  </li>

  <li>
    Nếu truy xuất phân tích YouTube cho một bài đăng không thuộc kênh của bạn bằng phương thức social
    ID, API sẽ trả về metadata mô tả về nội dung trong khi hiển thị giá trị bằng 0 cho
    tất cả các chỉ số số học. Thông tin mô tả như tiêu đề, mô tả, thẻ, tiêu đề kênh,
    trạng thái riêng tư và URL hình thu nhỏ sẽ được điền đúng, cung cấp ngữ cảnh về
    nội dung video. Tuy nhiên, tất cả các chỉ số hiệu suất số học bao gồm lượt xem, lượt thích, bình luận,
    lượt chia sẻ, thay đổi người đăng ký, thời gian xem và các lần thêm vào playlist sẽ trả về giá trị bằng 0.
  </li>

  <li>
    Khi sử dụng `postIds` cho các thread X/Twitter, Social Post ID của mỗi tweet phải được cung cấp
    riêng lẻ, các tweet trong thread không được tự động bao gồm khi truy vấn bài đăng gốc.
  </li>
</ul>

## Tham số Header

<HeaderAPI />

## Tham số Body

<Note>
  Phải cung cấp `id` hoặc `postIds`. Sử dụng `id` cho một bài đăng đơn lẻ hoặc `postIds` để truy xuất dữ liệu phân tích cho nhiều bài đăng trong một yêu cầu duy nhất.
</Note>

<ParamField body="id" type="string">
  [Social Post ID](/apis/overview#social-post-id) được trả về từ [endpoint
  /post](/apis/post/post). Đây là trường `id` cho một mạng xã hội riêng lẻ được tìm thấy trong
  mảng `postIds`. Yêu cầu `id` hoặc `postIds`.
</ParamField>

<ParamField body="postIds" type="array">
  Mảng các [Social Post ID](/apis/overview#social-post-id) để truy xuất dữ liệu phân tích cho nhiều bài đăng trong một yêu cầu duy nhất. Cho phép tối đa 100 ID. Yêu cầu `id` hoặc `postIds`.

  ```json theme={"system"}
  {
    "postIds": ["1979851549871354062", "2011793803951137234"]
  }
  ```
</ParamField>

<ParamField body="platforms" type="array" required>
  Mảng chuỗi các nền tảng để truy xuất dữ liệu phân tích. Chỉ cho phép một giá trị.

  Các giá trị khả dụng:

  ```json theme={"system"}
  {
    "platforms": ["facebook", "instagram", "linkedin", "threads",
                  "tiktok", "twitter", "youtube"]
  }
  ```
</ParamField>

<ParamField body="searchPlatformId" type="boolean" default={false} required>
  Đặt thành `true` để tìm kiếm theo Social Post ID.
</ParamField>

<RequestExample>
  ```json Single Post theme={"system"}
  {
      // Facebook Social Post ID
      "id": "104923907983682_108329000309742",
      "platforms": [
        // Select only one platform at a time:
        // facebook, instagram, youtube, threads, tiktok, or twitter
          "facebook"
      ],
      "searchPlatformId": true // Required
  }
  ```

  ```json Multiple Posts theme={"system"}
  {
      // Array of Social Post IDs (max 100)
      "postIds": ["1979851549871354062", "2011793803951137234"],
      "platforms": [
        // Select only one platform at a time:
        // facebook, instagram, youtube, threads, tiktok, or twitter
          "twitter"
      ],
      "searchPlatformId": true // Required
  }
  ```
</RequestExample>

<Info>
  Khi các chỉ số tích lũy (ví dụ: lượt thích, bình luận, lượt xem) tạm thời không có sẵn từ mạng xã hội, API sẽ tự động điền bổ sung từ dữ liệu đã lưu trữ. Hai trường tùy chọn có thể xuất hiện trong đối tượng `analytics` theo từng nền tảng:

  * **`backfilledFrom`** (string, ISO 8601) — Xuất hiện khi một hoặc nhiều chỉ số tích lũy được thay thế từ dữ liệu đã lưu trữ. Timestamp cho biết khi nào dữ liệu đã lưu trữ được cập nhật lần cuối.
  * **`recoveredFrom`** (string, ISO 8601) — Xuất hiện khi toàn bộ phản hồi phân tích được khôi phục từ dữ liệu đã lưu trữ do lỗi API hoàn toàn. Timestamp cho biết khi nào dữ liệu đã lưu trữ được cập nhật lần cuối.

  Dữ liệu đã lưu trữ cũ hơn 4 ngày được coi là lỗi thời và sẽ không được sử dụng để điền bổ sung hoặc khôi phục.
</Info>

<ResponseExample>
  ```json 200: Single Post Response theme={"system"}
  {
    /**
      The response is the same as Analytics on a Post.
      Please see that endpoint for details.

      Note: Some metrics are not available for posts not owned by the authorized account.
      For example: X does not return non-public metrics or organic metrics for Tweets not sent by the authorized user.
    */
  }
  ```

  ```json 200: Multiple Posts Response theme={"system"}
  {
      "twitter": [
          {
              "id": "1313589441919827982",    // Twitter Social Post ID
              "postUrl": "https://www.twitter.com/myaccount/1313589441919827982",
              "analytics": {
                  "created": "2022-09-07T22:12:10.000Z",
                  "entities": {
                      "urls": [
                          {
                              "start": 77,
                              "end": 96,
                              "url": "https://t.co/abc123",
                              "expandedUrl": "https://www.ayrshare.com/docs",
                              "displayUrl": "ayrshare.com/docs",
                              "unwoundUrl": "https://www.ayrshare.com/docs"
                          }
                      ],
                      "hashtags": [
                          {
                              "start": 97,
                              "end": 112,
                              "tag": "SocialMediaAPI"
                          }
                      ],
                      "mentions": [
                          {
                              "start": 113,
                              "end": 122,
                              "username": "ayrshare"
                          }
                      ]
                  },
                  "name": "Wonder World",
                  "post": "Just launched our social media campaign using Ayrshare! Check out the API at https://t.co/abc123 #SocialMediaAPI @ayrshare",
                  "publicMetrics": {
                      "retweetCount": 0,
                      "quoteCount": 0,
                      "likeCount": 0,
                      "replyCount": 0,
                      "bookmarkCount": 0,
                      "impressionCount": 23
                  },
                  "nonPublicMetrics": {
                      "userProfileClicks": 1,
                      "engagements": 1,
                      "impressionCount": 5
                  },
                  "organicMetrics": {
                      "likeCount": 0,
                      "impressionCount": 5,
                      "replyCount": 0,
                      "retweetCount": 0,
                      "userProfileClicks": 1
                  },
                  "username": "wondrous"
              },
              "lastUpdated": "2022-04-23T18:44:29.778Z",
              "nextUpdate": "2022-04-23T19:19:29.778Z"
          },
          {
              "id": "1313589441919827999",    // Twitter Social Post ID
              "postUrl": "https://www.twitter.com/myaccount/1313589441919827999",
              "analytics": {
                  "created": "2022-09-08T14:30:00.000Z",
                  "name": "Wonder World",
                  "post": "Another great day for social media automation!",
                  "publicMetrics": {
                      "retweetCount": 5,
                      "quoteCount": 2,
                      "likeCount": 15,
                      "replyCount": 3,
                      "bookmarkCount": 1,
                      "impressionCount": 150
                  },
                  "nonPublicMetrics": {
                      "userProfileClicks": 8,
                      "engagements": 12,
                      "impressionCount": 145
                  },
                  "organicMetrics": {
                      "likeCount": 15,
                      "impressionCount": 145,
                      "replyCount": 3,
                      "retweetCount": 5,
                      "userProfileClicks": 8
                  },
                  "username": "wondrous"
              },
              "lastUpdated": "2022-04-23T18:44:29.778Z",
              "nextUpdate": "2022-04-23T19:19:29.778Z"
          }
      ],
      "status": "success",
      "code": 200
  }
  ```

  ```json 200: Backfilled Response theme={"system"}
  {
      "twitter": [
          {
              "id": "1313589441919827982",
              "postUrl": "https://www.twitter.com/myaccount/1313589441919827982",
              "analytics": {
                  "created": "2022-09-07T22:12:10.000Z",
                  "name": "Wonder World",
                  "post": "Just launched our social media campaign!",
                  "publicMetrics": {
                      "retweetCount": 5,
                      "quoteCount": 2,
                      "likeCount": 15,
                      "replyCount": 3,
                      "bookmarkCount": 1,
                      "impressionCount": 150
                  },
                  "username": "wondrous",
                  "backfilledFrom": "2026-04-08T14:30:00.000Z"
              },
              "lastUpdated": "2026-04-09T10:15:00.000Z",
              "nextUpdate": "2026-04-09T10:26:00.000Z"
          }
      ],
      "status": "success",
      "code": 200
  }
  ```

  ```json 200: Recovered Response theme={"system"}
  {
      "twitter": [
          {
              "id": "1313589441919827982",
              "postUrl": "https://www.twitter.com/myaccount/1313589441919827982",
              "analytics": {
                  "created": "2022-09-07T22:12:10.000Z",
                  "name": "Wonder World",
                  "post": "Just launched our social media campaign!",
                  "publicMetrics": {
                      "retweetCount": 5,
                      "quoteCount": 2,
                      "likeCount": 15,
                      "replyCount": 3,
                      "bookmarkCount": 1,
                      "impressionCount": 150
                  },
                  "username": "wondrous",
                  "recoveredFrom": "2026-04-08T14:30:00.000Z"
              },
              "lastUpdated": "2026-04-09T10:15:00.000Z",
              "nextUpdate": "2026-04-09T10:26:00.000Z"
          }
      ],
      "status": "success",
      "code": 200
  }
  ```

  ```json 400: Bad Request theme={"system"}
  {
      "lastUpdated": "2023-12-08T03:40:31.185Z",
      "nextUpdate": "2023-12-08T03:51:31.185Z",
      "youtube": {
          "action": "post",
          "status": "error",
          "code": 186,
          "message": "Post ID not found. Please verify the top level ID returned from the /post endpoint is being sent, the Profile Key is included if applicable, and the post at the social network has not been deleted. If you are trying to retrieve a post originating outside of Ayrshare, please use the /rest-api/endpoints/analytics#analytics-by-social-id",
          "id": "dtuu-jDp4381"
      }
  }
  ```
</ResponseExample>
