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

# Số lượng Người theo dõi Instagram đang Trực tuyến

> Truy xuất tổng số lịch sử người theo dõi Instagram của bạn

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>)}
  </>;

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>;
};

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

Truy xuất tổng số lịch sử người theo dõi Instagram của bạn đang trực tuyến theo từng giờ, cho phép bạn tối ưu hóa thời điểm đăng bài để đạt được mức tương tác tối đa.

<ul class="custom-bullets">
  <li>Không khả dụng đối với những người dùng Instagram có ít hơn 100 người theo dõi.</li>
  <li>Dữ liệu phân tích chỉ khả dụng cho 30 ngày gần nhất.</li>

  <li>
    Khoảng thời gian cho một ngày được yêu cầu là từ ngày trước đó lúc T07:00:00.000Z đến ngày hiện tại
    lúc T06:59:59.999Z theo UTC.

    Ví dụ: sử dụng định dạng `YYYY-MM-DDThh:mm:ssZ` và gửi dưới dạng `2026-07-08T12:30:00Z`.
    Vui lòng xem [utctime](https://www.utctime.net/) để biết thêm ví dụ.
  </li>
</ul>

## Tham số Header

<HeaderAPI />

## Tham số Query

<ParamField query="date" type="string" required>
  Một ngày với định dạng: `YYYY-MM-DD`.

  Ví dụ: sử dụng định dạng `YYYY-MM-DDThh:mm:ssZ` và gửi dưới dạng `2026-07-08T12:30:00Z`.
  Vui lòng xem [utctime](https://www.utctime.net/) để biết thêm ví dụ.
</ParamField>

<ParamField query="formatUTC" type="boolean" default={false} required>
  Định dạng kết quả đầu ra với ngày bắt đầu và ngày kết thúc theo UTC.
</ParamField>

<RequestExample>
  ```bash cURL theme={"system"}
  curl \
  -H "Authorization: Bearer API_KEY" \
  -X GET https://api.ayrshare.com/api/analytics/getInstagramOnlineFollowers?date=2023-12-03
  ```

  ```javascript JavaScript theme={"system"}
  const API_KEY = "API_KEY";
  const date = "2023-12-03";
  fetch(`https://api.ayrshare.com/api/analytics/getInstagramOnlineFollowers?date=${date}`, {
    method: "GET",
    headers: {
      Authorization: `Bearer ${API_KEY}`
    }
  })
    .then((res) => res.json())
    .then((json) => console.log(json))
    .catch(console.error);
  ```

  ```python Python theme={"system"}
  import requests

  headers = {'Authorization': 'Bearer API_KEY'}

  r = requests.get('https://api.ayrshare.com/api/analytics/getInstagramOnlineFollowers?date=2023-12-03', headers=headers)

  print(r.json())
  ```

  ```php PHP theme={"system"}
  <?php

  // URL và thông tin xác thực
  $url = 'https://api.ayrshare.com/api/analytics/getInstagramOnlineFollowers?date=2023-12-03';
  $apiKey = 'API_KEY';  // Thay thế 'API_KEY' bằng khóa API thực tế của bạn

  // Khởi tạo một phiên cURL
  $curl = curl_init();

  // Thiết lập các tùy chọn cURL
  curl_setopt($curl, CURLOPT_URL, $url);
  curl_setopt($curl, CURLOPT_HTTPHEADER, array(
      'Content-Type: application/json',
      'Authorization: Bearer ' . $apiKey
  ));
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

  // Thực thi phiên cURL và nhận phản hồi
  $response = curl_exec($curl);

  // Kiểm tra xem có lỗi nào xảy ra không
  if(curl_errno($curl)){
      echo 'Curl error: ' . curl_error($curl);
  } else {
      // Giải mã và mã hóa lại phản hồi JSON để in đẹp
      echo json_encode(json_decode($response), JSON_PRETTY_PRINT);
  }

  // Đóng phiên cURL
  curl_close($curl);
  ```

  ```csharp C# theme={"system"}
  using System;
  using System.Net.Http;
  using System.Threading.Tasks;

  namespace InstagramFollowerCountGETRequest_csharp
  {
     class InstagramFollowerCount
     {
         private static readonly HttpClient client = new HttpClient();

         static async Task Main(string[] args)
         {
             string API_KEY = "API_KEY";
             string url = "https://api.ayrshare.com/api/analytics/getInstagramOnlineFollowers?date=2023-12-03";

             client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);

             try
             {
                 HttpResponseMessage response = await client.GetAsync(url);
                 response.EnsureSuccessStatusCode();
                 string responseBody = await response.Content.ReadAsStringAsync();
                 Console.WriteLine(responseBody);
             }
             catch (HttpRequestException e)
             {
                 Console.WriteLine($"Error: {e.Message}");
             }
         }
     }
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200: Success theme={"system"}
  {
    "status": "success",
    "onlineFollowersByHour": {
      "0": 120, // 12 AM
      "1": 113, // 1 AM
      "2": 117, // 2 AM
      "3": 110, // 3 AM
      "4": 129, // 4 AM
      "5": 170, // 5 AM
      "6": 166, // 6 AM
      "7": 173, // 7 AM
      "8": 177, // 8 AM
      "9": 168, // 9 AM
      "10": 178, // 10 AM
      "11": 160, // 11 AM
      "12": 154, // 12 PM
      "13": 153, // 1 PM
      "14": 131, // 2 PM
      "15": 118, // 3 PM
      "16": 109, // 4 PM
      "17": 128, // 5 PM
      "18": 129, // 6 PM
      "19": 134, // 7 PM
      "20": 123, // 8 PM
      "21": 111, // 9 PM
      "22": 102, // 10 PM
      "23": 98 // 11 PM
    },
    "startTime": "2024-03-29T07:00:00.000Z",
    "endTime": "2024-03-30T07:00:00.000Z"
  }
  ```

  ```json 200: Success formatUTC theme={"system"}
  {
    "status": "success",
    "onlineFollowersByHour": [
      {
        "start": "2024-03-29T07:00:00.000Z",
        "end": "2024-03-29T07:59:59.999Z",
        "onlineFollowers": 33
      },
      {
        "start": "2024-03-29T08:00:00.000Z",
        "end": "2024-03-29T08:59:59.999Z",
        "onlineFollowers": 90
      },
      {
        "start": "2024-03-29T09:00:00.000Z",
        "end": "2024-03-29T09:59:59.999Z",
        "onlineFollowers": 21
      },
      {
        "start": "2024-03-29T10:00:00.000Z",
        "end": "2024-03-29T10:59:59.999Z",
        "onlineFollowers": 109
      },
      {
        "start": "2024-03-29T11:00:00.000Z",
        "end": "2024-03-29T11:59:59.999Z",
        "onlineFollowers": 99
      },
      {
        "start": "2024-03-29T12:00:00.000Z",
        "end": "2024-03-29T12:59:59.999Z",
        "onlineFollowers": 10
      },
      {
        "start": "2024-03-29T13:00:00.000Z",
        "end": "2024-03-29T13:59:59.999Z",
        "onlineFollowers": 82
      },
      {
        "start": "2024-03-29T14:00:00.000Z",
        "end": "2024-03-29T14:59:59.999Z",
        "onlineFollowers": 101
      },
      {
        "start": "2024-03-29T15:00:00.000Z",
        "end": "2024-03-29T15:59:59.999Z",
        "onlineFollowers": 91
      },
      {
        "start": "2024-03-29T16:00:00.000Z",
        "end": "2024-03-29T16:59:59.999Z",
        "onlineFollowers": 12
      },
      {
        "start": "2024-03-29T17:00:00.000Z",
        "end": "2024-03-29T17:59:59.999Z",
        "onlineFollowers": 93
      },
      {
        "start": "2024-03-29T18:00:00.000Z",
        "end": "2024-03-29T18:59:59.999Z",
        "onlineFollowers": 21
      },
      {
        "start": "2024-03-29T19:00:00.000Z",
        "end": "2024-03-29T19:59:59.999Z",
        "onlineFollowers": 95
      },
      {
        "start": "2024-03-29T20:00:00.000Z",
        "end": "2024-03-29T20:59:59.999Z",
        "onlineFollowers": 97
      },
      {
        "start": "2024-03-29T21:00:00.000Z",
        "end": "2024-03-29T21:59:59.999Z",
        "onlineFollowers": 101
      },
      {
        "start": "2024-03-29T22:00:00.000Z",
        "end": "2024-03-29T22:59:59.999Z",
        "onlineFollowers": 74
      },
      {
        "start": "2024-03-29T23:00:00.000Z",
        "end": "2024-03-29T23:59:59.999Z",
        "onlineFollowers": 61
      },
      {
        "start": "2024-03-30T00:00:00.000Z",
        "end": "2024-03-30T00:59:59.999Z",
        "onlineFollowers": 31
      },
      {
        "start": "2024-03-30T01:00:00.000Z",
        "end": "2024-03-30T01:59:59.999Z",
        "onlineFollowers": 28
      },
      {
        "start": "2024-03-30T02:00:00.000Z",
        "end": "2024-03-30T02:59:59.999Z",
        "onlineFollowers": 19
      },
      {
        "start": "2024-03-30T03:00:00.000Z",
        "end": "2024-03-30T03:59:59.999Z",
        "onlineFollowers": 21
      },
      {
        "start": "2024-03-30T04:00:00.000Z",
        "end": "2024-03-30T04:59:59.999Z",
        "onlineFollowers": 23
      },
      {
        "start": "2024-03-30T05:00:00.000Z",
        "end": "2024-03-30T05:59:59.999Z",
        "onlineFollowers": 92
      },
      {
        "start": "2024-03-30T06:00:00.000Z",
        "end": "2024-03-30T06:59:59.999Z",
        "onlineFollowers": 32
      }
    ],
    "startTime": "2024-03-29T07:00:00.000Z",
    "endTime": "2024-03-30T07:00:00.000Z"
  }
  ```

  ```json 200: Success No Data theme={"system"}
  {
    "status": "success",
    "onlineFollowersByHour": {}
  }
  ```

  ```json 400: Incorrect date theme={"system"}
  {
    "action": "request",
    "status": "error",
    "code": 101,
    "message": "Missing or incorrect parameters. Please verify with the docs. .../ayrshare.com/rest-api/endpoints"
  }
  ```
</ResponseExample>
