REST API

Feed Group Types

LAST EDIT Mar 18 2024

Flat Feeds

Copied!

Flat is the default feed type - and the only feed type that you can follow and apply a custom ranking. It's not possible to follow either aggregated or notification feeds.

Create new feed groups based on the flat type in the dashboard.

Options

Copied!

Name

Description

Default

Realtime Notifications

Enable realtime notifications

True

Aggregated Feeds

Copied!

Aggregated feeds are helpful if you want to group activities. Here are some examples of what you can achieve using aggregated feeds:

  • 'Eric followed 10 people'

  • 'Julie and 14 others liked your photo'

You can create new aggregated feed groups in the dashboard.

Options

Copied!

There are several options you can configure for aggregated feeds. The most important setting is the aggregation format. This format determines how activities are grouped together.

Name

Description

Type

Realtime Notifications

Enable realtime notifications

true

Aggregation Format

The aggregation format to use. This is used as a key to group activities by.

{{ verb }}_{{ time.strftime("%Y-%m-%d") }}

How Aggregated Feeds Work

Copied!

When you insert an activity to an aggregated feed we apply the aggregation format. The aggregation format + the activity's data lead to a value for the "group". This group is used to combine the activities.

The aggregation format is applied at write time. Changing the aggregation format only affects activities inserted after the change. The dashboard allows you to preview changes on your existing data though.

Aggregation Format Syntax

Copied!

The following variables are available:

  • verb the activity verb as it is sent to the APIs (e.g. "like")
  • time the activity creation date and time (or the value sent to APIs)
  • object the activity object as it is sent to the APIs (e.g. Item:13)
  • actor the activity actor (e.g. User:9)
  • feed.group the feed group name (e.g. if the feed is "notification:123", feed.group is notification)
  • feed.user_id the feed user id (e.g. if the feed is "notification:123", feed.user_id is 123))
  • id the internal unique activity id. This will be unique so if you use this nothing will be aggregated. Use this when you don't want aggregation, but only the mark_read/mark_seen functionality.

In addition, you can use any of the custom values you've provided when adding the activity.

Here are some common examples of aggregation formats:

  • Per actor, verb id and day: {{ actor }}_{{ verb }}_{{ time.strftime("%Y-%m-%d") }}

  • Per activity verb and day: {{ verb }}_{{ time.strftime("%Y-%m-%d") }}

  • Follows by actor, everything else grouped by verb and day {% if verb == 'follow' %} {{ actor }}_{{ verb }}_{{ time.strftime("%Y-%m-%d") }} {% else %} {{ verb }}_{{ time.strftime("%Y-%m-%d") }} {% endif %}

The aggregation rule uses the Jinja2 Template Syntax. Control structures like if and else are available, as well as these filters:  int,  lower  and  strftime  to format the time variable. The options for strftime are documented here. Please get in touch with support if you need help with your aggregation formula.

Each activity group inside an aggregated feed contains the 15 most recent activities. If you add more than 15 activities to one group, older activities will no longer be visible. Enterprise customers can contact support to increase this limit.

Data Format

Copied!

The data format in which Aggregated Feeds are returned differs from regular Flat Feeds.

At the top level of the JSON response, the 'results' field contains an array of Activity Groups, plus additional metadata about the feed. Within the results array, each Activity Group contains a count of Activities and unique 'actors' contained within the group.

Notification Feeds

Copied!

Notification Feed Groups extend the "Aggregated Feed Group" concept with additional features that make them well suited to notification systems:

  • Notification Feeds contain Activity Groups, each with a seen and read status field. These fields can be updated to reflect how a user has interacted with a given notification.

  • When retrieved, the Feed includes a real-time count of the total number of unseen and unread Activity Groups (notifications).

For example, take the notification system on Facebook. If you click the notification icon, all notifications get marked as seen. However, an individual notification only gets marked as read when you click on it.

You can create new Notification Feed Groups in the dashboard.

Options

Copied!

There are several options to configure:

Name

Description

Type

Realtime Notifications

Enable realtime notifications

True

Aggregation Format

The aggregation format to use. The default {{ verb.id }}_{{ time.strftime("%Y-%m-%d") }} (verbs grouped by day) or {{ id }} (to achieve a single activity per group) are most commonly used.

{{ verb }}_{{ time.strftime("%Y-%m-%d") }}

Data Format

Copied!

Similar to Aggregated Feeds, the data format in which Notification Feeds are retrieved differs from regular Flat Feeds.

At the top level of the JSON response the results field contains an array of Activity Groups, along with overall unseen and unread counts and other metadata about the feed. Within the results array, each Activity Group contains the additional status fields that indicate the group is seen/read.

When reading the feed, set the mark_read and mark_seen parameter. The next time the feed is read, the seen and/or read status will be updated accordingly. Please keep in mind that the first call will always return the read and seen state prior to the change. This allows you to read a notification feed, mark activities as read or seen and display them according to the current state in a single API request.

nametypedescriptiondefaultoptional
mark_readarray

Comma-separated list of activity group ids to mark as read, or True which means all

-
mark_seenarray

Comma-separated list of activity group ids to mark as seen, or True which means all

-

If passing IDs to mark_seen or mark_read, be sure to pass the ID of the activity group as returned by the API, not the IDs of individual activities.

Here's an example:

You'll often want to listen to feed changes in real-time. This is explained in the section on real-time updates.

Each activity group inside a notification feed contains the 15 most recent activities. If you add more than 15 activities to one group, older activities will no longer be visible. Enterprise customers can contact support to increase this limit.