# Reactions

## Adding Reactions

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

| name                    | type   | description                                                                       | default | optional |
| ----------------------- | ------ | --------------------------------------------------------------------------------- | ------- | -------- |
| kind                    | string | The type of reaction (eg. like, comment, ...)                                     | -       |          |
| activity_id             | string | The ID of the activity the reaction refers to                                     | -       |          |
| 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                          | -       | ✓        |
| user_id                 | string | Id of the user adding the reaction if not own user. **Required for server side.** | -       | ✓        |

```csharp label="C#"
// add a like reaction to the activity with id activityId
var like = await client.Reactions.AddAsync("like", activityId);

// adds a comment reaction to the activity with id activityId
var comment = await client.Reactions.AddAsync("comment", activityId, "bob");
```

Here's a complete example:

```csharp label="C#"
// first let's read current user's timeline feed and pick one activity
var response = await client.Feed("timeline", "bob").GetActivitiesAsync();
var activity = response.FirstOrDefault();

// then let's add a like reaction to that activity
await client.Reactions.AddAsync("like", activity.Id, "bob");
```

>
> **Info:** The size of a reaction can not exceed 10kB
>

## Retrieving Reactions

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

| 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 (Max. 25)                                        | 10      | ✓        |
| id_gte             | string  | Retrieve reactions created after the one 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                              | -       | ✓        |
| with_own_children  | boolean | Enable returning the children reactions when filtering reactions by parent ID        | -       | ✓        |

>
> **Info:** If you want to filter reactions by `activity_id` or `reaction_id` <strong>and</strong> `user_id` you need to use the parameter `filter_user_id` instead of the `user_id` parameter described above.
>

```csharp label="C#"
// retrieve all kind of reactions for an activity
var reactions = await client.Reactions.FilterAsync(ReactionFiltering.Default, ReactionPagination.By.ActivityID("ed2837a6-0a3b-4679-adc1-778a1704852d"));

// retrieve first 10 likes for an activity
var response = await client.Reactions.FilterAsync(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.FilterAsync(filter, pagination);
```

## Retrieving Reactions by ID

```js label="JavaScript"
await client.reactions.get(reactionId);
```

## Updating Reactions

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

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

```csharp label="C#"
var reactionData = new Dictionary<string, object="">()
{
  { "text", "love it!"}
};
await client.Reactions.UpdateAsync(reactionId, reactionData);
```

## Removing Reactions

Reactions are easy to remove. Simply pass in their ID, like so:

```csharp label="C#"
await client.Reactions.DeleteAsync(reactionId)
```

## Soft delete and restore

>
> **Info:** This feature is currently supported only selected SDKs. If you need support for other SDKs, please contact support.
>

Reactions can be soft deleted and restored by ID:

```csharp label="C#"
await client.Reactions.DeleteAsync(reactionId, soft: true);
await client.Reactions.RestoreSoftDeletedAsync(reactionId);
```

---

For the most recent version of this documentation, visit [https://getstream.io/activity-feeds/docs/dotnet-csharp/v2/reactions-introduction/](https://getstream.io/activity-feeds/docs/dotnet-csharp/v2/reactions-introduction/).