Select your Platform:
backend SDKs
client SDKs
Reactions
Confused about "Reactions"?
Let us know how we can improve our documentation:
Reactions are a special kind of data that can be used to capture user interaction with specific activities. Common examples of reactions are likes, comments, and upvotes. Reactions are automatically returned to feeds' activities at read time when the reactions parameters are used.
Adding Reactions
Copied!Confused about "Adding Reactions"?
Let us know how we can improve our documentation:
Reactions are a special kind of data that can be used to capture user interaction with specific activities. Common examples of reactions are likes, comments, and upvotes. Reactions are automatically returned to feeds' activities at read time when the reactions parameters are used.
Reactions are always related to activities; in order to add a reaction to an activity you need to provide its ID.
Parameters
Copied!Confused about "Parameters"?
Let us know how we can improve our documentation:
name | type | description | default | optional |
---|---|---|---|---|
kind | string | The type of reaction (eg. like, comment, ...) | - | |
activity_id | string | - | ||
data | object | Additional data to attach to the reaction | - | ✓ |
target_feeds | array | The feeds that should receive a notification activity | - | ✓ |
target_feeds_extra_data | object | Additional data to attach to the notification activities | - | ✓ |
1
2
3
4
5
6
7
8
// add a like reaction to the activity with id activityId
const like = await client.reactions.add("like", activityId);
// adds a comment reaction to the activity with id activityId
const comment = await client.reactions.add("comment", activityId, {"text": "awesome post!"});
// for server side auth, userId is required
const comment = await client.reactions.add("comment", activityId, {"text": "awesome post!"}, {userId});
1
2
3
4
5
6
7
# add a like reaction to the activity with id activity_id
client.reactions.add("like", activity_id, user_id="mike")
# adds a comment reaction to the activity with id activityId
client.reactions.add(
"comment", activity_id, user_id="mike", data={"text": "awesome post!"}
)
1
2
3
4
5
6
7
# add a like reaction to the activity with id activity_id
client.reactions.add("like", activity_id, user_id="mike")
# adds a comment reaction to the activity with id activity_id
client.reactions.add(
"comment", activity_id, user_id="mike", data: {text: "awesome post!"}
)
1
2
3
4
5
// add a like reaction to the activity with id activity_id
$client->reactions()->add("like", $activity_id, "mike");
// adds a comment reaction to the activity with id activity_id
$client->reactions()->add("comment", $activity_id, "mike", ["text"=>"awesome post!"]);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Reaction like = new Reaction.Builder()
.kind("like")
.activityID(activity.getID())
.build();
// add a like reaction to the activity with id activityId
like = client.reactions().add("john-doe", like).get();
Reaction comment = new Reaction.Builder()
.kind("comment")
.activityID(activity.getID())
.extraField("text", "awesome post!")
.build();
// adds a comment reaction to the activity with id activityId
comment = client.reactions().add("john-doe", comment).get();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// add a like reaction to the activity with id activityID
r := stream.AddReactionRequestObject{
Kind: "like",
ActivityID: activityID,
}
like, err := client.Reactions().Add(r)
// adds a comment reaction to the activity with id activityId
r = stream.AddReactionRequestObject{
Kind: "comment",
ActivityID: activityID,
UserID: "bob",
}
comment, err := client.Reactions().Add(r)
1
2
3
4
5
// add a like reaction to the activity with id activityId
client.add(reactionTo: activityId, kindOf: "like") { result in /* ... */ }
// adds a comment reaction to the activity with id activityId
client.add(reactionTo: activityId, kindOf: "comment", extraData: Comment(text: "awesome post!")) { result in /* ... */ }
1
2
3
4
5
// add a like reaction to the activity with id activityId
var like = await client.Reactions.Add("like", activityId);
// adds a comment reaction to the activity with id activityId
var comment = await client.Reactions.Add("comment", activityId, "bob");
Here's a complete example:
1
2
3
4
5
6
// first let's read current user's timeline feed and pick one activity
const response = await client.feed('timeline', 'mike').get();
const activity = response.activities[0];
// then let's add a like reaction to that activity
await client.reactions.add("like", activity.id);
1
2
3
4
5
6
# first let's read current user's timeline feed and pick one activity
response = client.feed("timeline", "mike").get()
activity = response["results"][0]
# then let's add a like reaction to that activity
client.reactions.add("like", activity["id"], user_id="bob")
1
2
3
4
5
6
# first let's read current user's timeline feed and pick one activity
response = client.feed("timeline", "mike").get()
activity = response["results"][0]
# then let's add a like reaction to that activity
client.reactions.add("like", activity["id"], "bob")
1
2
3
4
5
// first let's read current user's timeline feed and pick one activity
$activity = $client->feed('timeline', 'mike')->getActivities(0,1)["results"][0];
// then let's add a like reaction to that activity
$client->reactions()->add("like", $activity["id"], "bob");
1
2
3
4
5
6
7
8
9
// first let's read current user's timeline feed and pick one activity
List<activity> response = client.flatFeed("timeline", "mike").getActivities().get();
Activity activity = response.get(0);
// then let's add a like reaction to that activity
client.reactions().add("john-doe", Reaction.builder()
.kind("like")
.activityID(activity.getID())
.build()).join();</activity>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// first let's read current user's timeline feed and pick one activity
response, err := client.FlatFeed("timeline", "bob").GetActivities()
if err != nil {
//...
}
activity := response.Results[0]
// then let's add a like reaction to that activity
r := stream.AddReactionRequestObject{
Kind: "like",
ActivityID: activity.ID,
UserID: "bob",
}
result, err := client.Reactions().Add(r)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// we recommend to add reaction kinds to the extention of the `ReactionKind` to avoid typos
extension ReactionKind {
static let like = "like"
static let comment = "comment"
}
// first let's read current user's timeline feed and pick one activity
client.flatFeed(feedSlug: "timeline", userId: "mike").get { result in
if let response = try? result.get(), let activity = response.results.first, let activityId = activity.id {
// then let's add a like reaction to that activity
client.add(reactionTo: activityId, kindOf: .like) { result in
print(result) // will print a reaction object in the result.
}
}
}
1
2
3
4
5
6
// first let's read current user's timeline feed and pick one activity
var response = await client.Feed("timeline", "bob").GetActivities();
var activity = response.FirstOrDefault();
// then let's add a like reaction to that activity
await client.Reactions.Add("like", activity.Id, "bob");
Retrieving Reactions
Copied!Confused about "Retrieving Reactions"?
Let us know how we can improve our documentation:
You can read reactions and filter them based on their user_id
or activity_id
values.
Further filtering can be done with the kind
parameter (e.g. retrieve all likes by one user, retrieve all comments for one activity, etc.).
Reactions are returned in descending order (newest to oldest) by default and when using id_lt[e]
, and in ascending order (oldest to newest) when using id_gt[e]
.
Parameters
Copied!Confused about "Parameters"?
Let us know how we can improve our documentation:
name | type | description | default | optional |
---|---|---|---|---|
activity_id | string | Retrieve reactions by activity_id | - | |
user_id | string | Retrieve reactions by user_id | - | |
reaction_id | string | Retrieve children reaction by reaction_id | - | ✓ |
kind | string | If provided it will only retrieve reactions of a certain kind (e.g. "like") | - | ✓ |
limit | integer | The number of reactions to retrieve | 10 | ✓ |
id_gte | string | Retrieve reactions created after the on with ID equal to the parameter (inclusive) | - | ✓ |
id_gt | string | Retrieve reactions created after the one with ID equal to the parameter. | - | ✓ |
id_lte | string | Retrieve reactions created before the one with ID equal to the parameter (inclusive) | - | ✓ |
id_lt | string | Retrieve reactions before the one with ID equal to the parameter | - | ✓ |
with_activity_data | boolean | Returns activity data when paginating using activity_id | - | ✓ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// retrieve all kind of reactions for an activity
const reactions = await client.reactions.filter({
'activity_id': 'ed2837a6-0a3b-4679-adc1-778a1704852d'
});
// retrieve first 10 likes for an activity
const response = await client.reactions.filter({
'activity_id': 'ed2837a6-0a3b-4679-adc1-778a1704852d',
'kind': 'like',
'limit': 10
});
// retrieve the next 10 likes using the id_lt param
const response = await client.reactions.filter({
'activity_id': 'ed2837a6-0a3b-4679-adc1-778a1704852d',
'kind': 'like',
'id_lt': 'e561de8f-00f1-11e4-b400-0cc47a024be0',
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# retrieve all kind of reactions for an activity
reactions = client.reactions.filter(
activity_id="ed2837a6-0a3b-4679-adc1-778a1704852d"
)
# retrieve first 10 likes for an activity
response = client.reactions.filter(
activity_id="ed2837a6-0a3b-4679-adc1-778a1704852d", kind="like", limit=10
)
# retrieve the next 10 likes using the id_lt param
response = client.reactions.filter(
activity_id="ed2837a6-0a3b-4679-adc1-778a1704852d",
kind="like",
id_lt="e561de8f-00f1-11e4-b400-0cc47a024be0",
)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# retrieve all kind of reactions for an activity
reactions = client.reactions.filter(
activity_id: "ed2837a6-0a3b-4679-adc1-778a1704852d"
)
# retrieve first 10 likes for an activity
response = client.reactions.filter(
activity_id: "ed2837a6-0a3b-4679-adc1-778a1704852d", kind: "like", limit: 10
)
# retrieve the next 10 likes using the id_lt param
response = client.reactions.filter(
activity_id: "ed2837a6-0a3b-4679-adc1-778a1704852d",
kind: "like",
id_lt: "e561de8f-00f1-11e4-b400-0cc47a024be0",
)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// retrieve all kind of reactions for an activity
$client->reactions()->filter("activity_id", "827509c1-2872-11e9-8ec6-0a544dd61b80", "comment");
// retrieve first 10 likes for an activity
$client->reactions()->filter(
"activity_id",
"827509c1-2872-11e9-8ec6-0a544dd61b80",
"like",
["limit" => 10],
);
// retrieve the next 10 likes using the id_lt param
$client->reactions()->filter(
"activity_id",
"827509c1-2872-11e9-8ec6-0a544dd61b80",
"like",
["limit" => 10
"id_lt" => "e561de8f-00f1-11e4-b400-0cc47a024be0"],
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// retrieve all kind of reactions for an activity
List<reaction> reactions = client.reactions().filter(LookupKind.ACTIVITY, "ed2837a6-0a3b-4679-adc1-778a1704852d").get();
// retrieve first 10 likes for an activity
reactions = client.reactions()
.filter(LookupKind.ACTIVITY,
"ed2837a6-0a3b-4679-adc1-778a1704852d",
new Filter().limit(10),
"like").join();
// retrieve the next 10 likes using the id_lt param
reactions = client.reactions()
.filter(LookupKind.ACTIVITY,
"ed2837a6-0a3b-4679-adc1-778a1704852d",
new Filter().idLessThan("e561de8f-00f1-11e4-b400-0cc47a024be0"),
"like").join();</reaction>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
var response *stream.FilterReactionResponse
var err error
// retrieve all kind of reactions for an activity
response, err = client.Reactions().Filter(stream.ByActivityID("ed2837a6-0a3b-4679-adc1-778a1704852d"))
// retrieve first 10 likes for an activity
response, err = client.Reactions().Filter(stream.ByActivityID("ed2837a6-0a3b-4679-adc1-778a1704852d").ByKind("like"), stream.WithLimit(10))
// retrieve the next 10 likes using the id_lt param
filterAttribute := stream.ByActivityID("ed2837a6-0a3b-4679-adc1-778a1704852d").ByKind("like")
pagination := stream.WithIDLT("e561de8f-00f1-11e4-b400-0cc47a024be0")
response, err = client.Reactions().Filter(filterAttribute, pagination)
1
2
3
4
5
6
7
8
9
10
11
12
// retrieve all kind of reactions for an activity
client.reactions(forActivityId: "ed2837a6-0a3b-4679-adc1-778a1704852d") { result in /* ... */ }
// retrieve first 10 likes for an activity
client.reactions(forActivityId: "ed2837a6-0a3b-4679-adc1-778a1704852d",
kindOf: "like",
pagination: .limit(10)) { result in /* ... */ }
// retrieve the next 10 likes using the id_lt param
client.reactions(forActivityId: "ed2837a6-0a3b-4679-adc1-778a1704852d",
kindOf: "like",
pagination: .lessThan("e561de8f-00f1-11e4-b400-0cc47a024be0")) { result in /* ... */ }
1
2
3
4
5
6
7
8
9
10
11
// retrieve all kind of reactions for an activity
var reactions = await client.Reactions.Filter(ReactionFiltering.Default, ReactionPagination.By.ActivityID("ed2837a6-0a3b-4679-adc1-778a1704852d"));
// retrieve first 10 likes for an activity
var response = await client.Reactions.Filter(ReactionFiltering.Default.WithLimit(10), ReactionPagination.By.ActivityID("ed2837a6-0a3b-4679-adc1-778a1704852d").Kind("like"));
// retrieve the next 10 likes using the id_lt param
var filter = ReactionFiltering.Default.WithFilter(FeedFilter.Where().IdLessThan("e561de8f-00f1-11e4-b400-0cc47a024be0"));
var pagination = ReactionPagination.By.ActivityID("ed2837a6-0a3b-4679-adc1-778a1704852d").Kind("like");
var response2 = await client.Reactions.Filter(filter, pagination);
Updating Reactions
Copied!Confused about "Updating Reactions"?
Let us know how we can improve our documentation:
Reactions can be updated by providing reaction ID parameter. Changes to reactions are propagated to all notified feeds; if the target_feeds
list is updated, notifications will be added and removed accordingly.
Parameters
Copied!Confused about "Parameters"?
Let us know how we can improve our documentation:
name | type | description | default | optional |
---|---|---|---|---|
reaction_id | string | The ID of the reaction | - | |
data | object | Reaction data | - | ✓ |
target_feeds | string | The list of feeds that should receive a copy of the reaction. | - | ✓ |
1
client.reactions.update(reactionId, {"text": "love it!"});
1
client.reactions.update(reaction_id, {"text": "love it!"});
1
client.reactions.update(reaction_id, data: {text: "I love it"})
1
$client->reactions()->update($reaction_id, ["text"=> "I love it"]);
1
2
3
4
client.reactions().update(Reaction.builder()
.id(reaction.getId())
.extraField("text", "love it!")
.build());
1
result, err := client.Reactions().Update(reactionID, map[string]interface{}{"text": "love it!"}, nil)
1
client.update(reactionId: reactionId, extraData: Comment(text: "love it!")) { result in /* ... */ }
1
2
3
4
5
var reactionData = new Dictionary<string, object="">()
{
{ "text", "love it!"}
};
await client.Reactions.Update(reactionId, reactionData);</string,>
Removing Reactions
Copied!Confused about "Removing Reactions"?
Let us know how we can improve our documentation:
Reactions are easy to remove. Simply pass in their ID, like so:
1
client.reactions.delete(reactionId);
1
client.reactions.delete(reaction_id)
1
client.reactions.delete(reaction_id)
1
client.reactions().delete(reaction.getId()).join();
1
err := client.Reactions().Delete(reactionID)
1
client.delete(reactionId: reactionId) { result in /* ... */ }
1
await client.Reactions.Delete(reactionId)