# User Activity

Tracking user activity when users perform actions on posts or comments. The API tracks the following actions:

* **Reactions to the post**
* **Comments to the post**
* **Reactions to the comment**
* **Replies to the comment**
* **Remove reactions or comments**

{% hint style="info" %}
User Activity is currently in Private Beta. Please submit your request to the [**social.plus Help Center**](https://socialplus.atlassian.net/servicedesk/customer/portals) to enable this feature. It will take approximately 5 business days to process your request.
{% endhint %}

#### API Reference

## Retrieve activities of user's actions

<mark style="color:blue;">`GET`</mark> `https://beta.amity.services/user-activities`

#### Query Parameters

| Name              | Type   | Description                                                                               |
| ----------------- | ------ | ----------------------------------------------------------------------------------------- |
| limit             | Number | Specify the maximum number of responses you would like to retrieve, with a limit of 50.   |
| createdAt         | String | (Pagination purpose) createdAt will be provided by **start** key in the response.         |
| networkId\_userId | String | (Pagination purpose) networkId\_userId will be provided by **start** key in the response. |

#### Headers

| Name                                            | Type   | Description                                                                 |
| ----------------------------------------------- | ------ | --------------------------------------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | <p>Bearer {accessToken}</p><p>(accessToken is retrieved from Amity SDK)</p> |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "data": [
        {
            "createdAt": "string",
            "networkId_userId": "string",
            "targetId": "postA",
            "targetType": "post",
            "objectId": "commentX",
            "objectType" : "comment",
            "parentType" : "post",
            "parentId" : "postA"
        },
        {
            "createdAt": "string",
            "networkId_userId": "string",
            "targetId": "postA",
            "targetType": "post",
            "objectId": "reactionX",
            "objectType" : "reaction_like",
            "parentType" : "post",
            "parentId" : "postA"
        },
        {
            "createdAt": "string",
            "networkId_userId": "string",
            "targetId": "commentX",
            "targetType": "comment",
            "objectId": "commentY",
            "objectType" : "comment",
            "parentType" : "post",
            "parentId" : "postA"
        },
        {
            "createdAt": "string",
            "networkId_userId": "string",
            "targetId": "commentX",
            "targetType": "comment",
            "objectId": "reactionY",
            "objectType" : "reaction_like",
            "parentType" : "post",
            "parentId" : "postA"
        },
        ...
    ],
    "start": {
        "createdAt": "string",
        "networkId_userId": "string"
    }
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```json
{
    "errorType": "Unauthorized",
    "httpStatus": 401,
    "message": "Authorization header must be included"
}
```

```json
{
    "errorType": "Unauthorized",
    "httpStatus": 401,
    "message": "Authorization header must be bearer token"
}
```

```json
{
    "errorType": "Unauthorized",
    "httpStatus": 401,
    "message": "Access token is invalid."
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```json
{
    "errorType": "Bad Request",
    "httpStatus": 400,
    "message": "limit should be between 1 and 50"
}
```

{% endtab %}
{% endtabs %}

#### Example curl

```powershell
curl --location --request GET 'https://beta.amity.services/user-activities?
networkId_userId=<networkId_userId>&createdAt=<createdAt>&limit=10' \
--header 'Authorization: Bearer <ACCESSTOKEN>'
```

### Scenario

The following table shows the supported scenarios and user actions that are recorded in the User Activity Record

<table><thead><tr><th width="279">Scenario</th><th width="147">Target</th><th width="183">Object</th><th>Parent</th></tr></thead><tbody><tr><td>User reacted to Post A</td><td>Post A</td><td>reaction_&#x3C;type></td><td>Post A</td></tr><tr><td>User commented to Post A</td><td>Post A</td><td>comment</td><td>Post A</td></tr><tr><td>User reacted to Comment A under Post A</td><td>Comment A</td><td>reaction_&#x3C;type></td><td>Post A</td></tr><tr><td>User reacted to Comment B under Post B</td><td>Comment B</td><td>reaction_&#x3C;type></td><td>Post B</td></tr><tr><td>User commented to Comment B under Post B</td><td>Comment B</td><td>comment</td><td>Post B</td></tr></tbody></table>
