Insights API

Availability

PubNub Insights metrics are available through API only in Insights Premium.

Besides accessing Insights metrics through Admin Portal, Premium users can access their apps' metrics using the Insights API.

Insights metrics

There are two sets of Insights metrics for which you can request data:

UTC timezone for metrics

PubNub Insights API returns all metrics in the UTC timezone.

Metrics

Metrics available on the /insights endpoint.

  • Channels
MetricDescription
percent_unique_channels_with_messagesThe percentage of channels with messages out of all unique channels in the specified period and date range.
unique_channelsNumber of unique channels for the specified period and date range.
unique_channels_combinationUnique channels, unique channels with messages, and unique channels with message chats (for the Chat use case). Message chats refer to any messages that contain text information.
  • Users
MetricDescription
new_vs_recurring_usersNumber of new unique users and returning unique users (compared with the preceding period) for the specified period and date range.
percent_unique_users_with_messagesThe percentage of users with messages out of all unique users in the specified period and date range.
unique_usersNumber of unique users for the specified period and date range.
unique_users_by_countryNumber of unique users across all channels per country for the specified period and date range.
unique_users_combinationUnique users, unique users with messages, and unique users with message chats (for the Chat use case). Message chats refer to any messages that contain text information.
  • Messages
MetricDescription
messagesNumber of messages published across all channels for the specified period and date range.
message_by_countryTotal number of messages published across all channels per country for the specified period and date range. This metric also shows message timestamps.
top_10_message_typesTop 10 types of messages for the specified period and date range. The message types can be defined by updating the JSON path in the Messages section of the Dashboard Settings in the Insights dashboard.

Top metrics

Metrics available on the /insights/top endpoint.

  • Channels
MetricDescription
top_20_channelsTop 20 channels for the specified period, category, and date range.
top_1000_channelsTop 1000 channels for the specified period, category, and date range.
  • Users
MetricDescription
top_20_usersTop 20 users for the specified period, category, and date range.
top_1000_usersTop 1000 users for the specified period, category, and date range.

Categories

Top metrics have a few categories that are either added in requests or returned in responses.

Requests

You can group the top metrics in each call by the following categories:

  • all
  • by_chats
  • by_messages
  • by_subscribers
  • by_users_with_chats
  • by_subscribed_channels
  • by_users_with_messages

Responses

Top metrics for a given hour (period=hourly) or day (period=daily) return the following categories in response:

Returned categoryDescriptiontop_20_channelstop_1000_channelstop_20_userstop_1000_users
count_messagesNumber of messages published.YesYesYesYes
count_subscribersNumber of subscribers for the channel.YesYes--
count_users_with_messagingNumber of unique users publishing messages within the channel.YesYes--
count_chatNumber of messages (that contain textual information) published.YesYesYesYes
count_users_with_chatNumber of unique users publishing messages within the channel.YesYes--
count_channels_subscribed_toNumber of channels the user has subscribed to.--YesYes
timestamp_valueTimestamp of the hour or day for which the top 20 / 1000 channels / users have been requested. This timestamp is in UTC.YesYesYesYes

For example, if you want to get metrics for the top 20 channels (top_20_channels) by the number of messages, choose the by_messages category.

Limitations

To manage the size of the response returned, there are limitations to how much data you can request in a single API call. This limit depends on:

  • Type of metric (for example, unique_channels)
  • Time period (period parameter, for example, hourly)
  • Date range (fromDate and toDate parameters, for example, 2023-10-02 and 2023-10-09 if you want data for 7 days)

Date range restrictions with period

When you request metrics data from Insights API, keep these limitations in mind.

PeriodRestrictionsExample
hourlyYou can request a maximum 1 day in one API call and only till the preceding 10 hours.If the current date is 2023-11-28 (22:10:00 UTC), you can request metrics for the hourly period from 2023-11-27 (12:00:00 UTC) till 2023-11-28 (12:00:00 UTC).
dailyYou can request maximum 7 days in one API call and only till the preceding/previous day.If the current date is 2023-11-28 (22:10:00 UTC), you can request metrics for the daily period from 2023-11-21 (00:00:00 UTC) till 2023-11-27 (end of day).
weeklyYou can request maximum 8 weeks in one API call and only till the previous week (only for complete weeks, with weeks starting on Sunday).If the current date is 2023-11-28 (22:10:00 UTC), you can request metrics for the weekly period from Sun 2023-10-01 (00:00:00 UTC) till Sat 2023-11-25 (end of day).
monthlyYou can request maximum 3 months in one API call and only for the preceding month on the first day of this month.If the current date is 2023-11-28 (22:10:00 UTC), you can request metrics for the monthly period from Sun 2023-08-01 (00:00:00 UTC) till Sun 2023-10-31 (end of day).
API specification

For the full Open API specification, technical information on authentication, examples of sample calls, responses, and error codes, refer to the REST API documentation.

Period restrictions for metrics

You can retrieve data for some metrics only in selected periods.

  • Channels
Metric namehourlydailyweeklymonthly
top_20_channelsYesYes--
top_1000_channelsYesYes--
percent_unique_channels_with_messagesYesYesYesYes
unique_channelsYesYesYesYes
unique_channels_combinationYesYesYesYes
  • Users
Metric namehourlydailyweeklymonthly
top_20_usersYesYes--
top_1000_usersYesYes--
new_vs_recurring_users-YesYesYes
percent_unique_users_with_messagesYesYesYesYes
unique_usersYesYesYesYes
unique_users_by_countryYesYes--
unique_users_combinationYesYesYesYes
  • Messages
Metric namehourlydailyweeklymonthly
messagesYesYesYesYes
message_by_countryYesYes--
top_10_message_typesYesYes--
Last updated on