CData Python Connector for Instagram

Build 25.0.9454

AccountInsights

Aggregates key performance metrics for an Instagram business account, including reach, engagement, and profile activity data. This summary serves as a central view for tracking account-level trends over time. The permissions required are instagram_basic and instagram_manage_insights.

Select

You can query the following metrics given a date range. The default date range is the last 7 days.

  • Reach (accepts time periods of day, week, and days_28)
  • FollowerCount (only accepts the day period)
  • Views (only accepts the day period)

Specify a date range with the FromDateTime and ToDateTime columns. Specify the intervals of the date range by setting the Period column in the WHERE clause. Note that you cannot use a period on a metric that does not support it. For example, you cannot use FollowerCount with period days_28 because FollowerCount only supports the day period.

The connector will use the Instagram APIs to process filters that refer to a date range or Id. The connector processes other filters client-side within itself.

The following examples show how to retrieve metrics over a given date range:

  • The default query returns results for the following metrics during the last seven days: Reach, FollowerCount, and Views.

    SELECT * FROM AccountInsights

  • Filter on FromDateTime and ToDateTime to explicitly specify a different date range. The max date range cannot be more than 30 days (2592000 s).

    SELECT * FROM AccountInsights WHERE FromDateTime = '2018/01/01' AND ToDateTime = '2018/01/30' AND period = 'day'

  • Return results over a period of 7 days.

    SELECT * FROM AccountInsights WHERE FromDateTime = '2018/01/01' AND period = 'day'

  • Return results from 2018/01/01 to 2018/01/08.

    SELECT * FROM AccountInsights WHERE ToDateTime = '2018/01/08' AND period = 'day'

  • Return a custom projection on account insights for the date range from 2018/01/01 to 2018/01/08.

    SELECT FollowerCount, Views FROM AccountInsights WHERE FromDateTime = '2018/01/01' AND ToDateTime = '2018/01/30' AND period = 'day'

Columns

Name Type Description
InstagramBusinessAccountId String The unique identifier assigned to an Instagram Business Account. This value links the insights data to a specific business entity on Instagram.
EndTime Date The final date for which insight data is relevant in the queried range. This value is not applicable when the MetricType is set to total_value.
Views Integer The total number of times your content — including Reels, posts, and Stories — has been viewed. This metric is exclusively available when using the total_value setting for MetricType.
Reach Integer The total number of distinct Instagram accounts that have seen any content associated with the business profile during the selected time frame.
FollowerCount Integer The current count of unique Instagram accounts that follow this profile. This metric is only accessible when the MetricType is set to default.
MetricType String Specifies the type of metric being used for the query. The common values include default and total_value, which determine the scope and structure of the data returned.

The allowed values are default, total_value, time_series.

Period String Defines the time aggregation used for breaking down the insight data. The valid values include day, week, 28 days, and lifetime. This field is required for all queries.
StartDate Datetime The starting date of when the metric is calculated for a row. Only available when the MetricType is set to total_value. Otherwise, use EndTime.
EndDate Datetime The ending date of when the metric is calculated for a row. Only available when the MetricType is set to total_value. Otherwise, use EndTime.

Pseudo-Columns

Pseudo column fields are used in the WHERE clause of SELECT statements and offer a more granular control over the tuples that are returned from the data source.

Name Type Description
FromDateTime Datetime Indicates the beginning of the time window used to retrieve the insight data. This helps determine the range over which metrics are aggregated.
ToDateTime Datetime Defines the end of the time window for retrieving insight data. This, combined with FromDateTime, establishes the complete time range for the query.

Copyright (c) 2025 CData Software, Inc. - All rights reserved.
Build 25.0.9454