List and Get Reactions

Learn to use Slack's API calls to list and get reactions for a specific message.

Let’s look at the following endpoints in this lesson:

  1. reactions.list: This endpoint lists reactions made by a user.
  2. reactions.get: This endpoint gets reactions for an item.

List of reactions

We access the https://slack.com/api/reactions.list endpoint to get a list of reactions. Using this endpoint, we can list all the reactions made by a user or an application.

Request parameters

Some important query parameters for the reactions.list endpoint are as follows:

Parameter

Type

Category

Description

token

token

required

Authentication tokens carry the required scopes that govern the usage of different Slack applications and APIs. We usually pass these tokens as an HTTP Authorization header or as a POST parameter.

cursor

string

optional

This parameter is a string of characters used to "point" to the next "page" of data. We paginate through collections of data by setting the cursor parameter to a next_cursor attribute returned by a previous request's response_metadata.

limit

integer

optional

This is the maximum number of items to return. 

user

string

optional

This shows us the reactions made by this user. It defaults to the authorized user.

Let’s call the reactions.list endpoint. Click the “Run” button to receive the list of reactions we’ve used.

Press + to interact
import fetch from "node-fetch";
const url = new URL("https://slack.com/api/reactions.list");
const headerParameters = {
Authorization: "Bearer {{TOKEN}}",
"Content-Type": "application/json; charset=UTF-8",
};
const options = {
method: "GET",
headers: headerParameters,
};
async function listReactions() {
try {
const response = await fetch(url, options);
printResponse(response);
} catch (error) {
printError(error);
}
}
listReactions();

On line 17, we call the reactions.list endpoint to get a list of all the reactions that were used.

Response fields

A successful response includes an items list containing the details of every item (files, messages, etc.) on which the authed user has reacted.

Note: Visit this lesson to view the details of the different objects such as file and message.

Get a reaction

To get a reaction, we access the https://slack.com/api/reactions.get endpoint.

Request parameters

Here are some important query parameters for the reactions.get endpoint:

Parameter

Type

Category

Description

token

token

required

Authentication tokens carry the required scopes that govern the usage of different Slack applications and APIs. We usually pass these tokens as an HTTP Authorization header or as a POST parameter.

channel

string

optional

This is the channel where the message to get reactions was posted.

timestamp

string

optional

This is the timestamp of the message for which we have to get reactions.

Let’s call the reactions.get endpoint. Click the “Run” button to get all the reactions to a specific message.

Press + to interact
import fetch from "node-fetch";
const url = new URL("https://slack.com/api/reactions.get");
const headerParameters = {
Authorization: "Bearer {{TOKEN}}",
"Content-Type": "application/json; charset=UTF-8",
};
const queryParameters = new URLSearchParams({
channel: "{{CHANNEL_ID}}",
timestamp: "{{TS}}",
});
const options = {
method: "POST",
headers: headerParameters,
};
async function getReactions() {
try {
url.search = queryParameters;
const response = await fetch(url, options);
printResponse(response);
} catch (error) {
printError(error);
}
}
getReactions();

In the code above:

  • Lines 10–13: We specify the channel and the timestamp of the message whose reactions we want to get.
  • Lines 22–23: We provide the query parameters and call the reactions.get endpoint.

Response fields

The response from this endpoint includes the list of all reactions added to the input message.

Note: Visit this lesson to view the details of the message object.