Skip to content

GetComments#

Beta version

The functionality is in beta. Features may change and may also work unstably.

The method returns the comments of a post, the newest first - in the order Instagram returns them.

The method uses the limits on the number of requests per second.

Request#

To get the comments of a post, you have to execute a request at:

POST
{{apiUrl}}/waInstance{{idInstance}}/getComments/{{apiTokenInstance}}

For apiUrl, idInstance and apiTokenInstance request parameters, refer to the Before you start section.

Request parameters#

Parameter Type Mandatory Description
postId string Yes The post identifier
parentCommentId string No The root comment: with it the method returns the replies in its branch.
count integer No How many comments to return. The default is 20 (one Instagram page), the maximum is 200
cursor string No The cursor of the next page from the cursor field of the previous response

Request body example#

Get the comments of a post:#

{
    "postId": "2907515653209522683"
}

Get the next page of the comments of a post:#

{
    "postId": "2907515653209522683",
    "count": 20,
    "cursor": "eyJzIjoiY29tbWVudHM6MjkwNzUxNTY1MzIwOTUyMjY4MyIsImMiOiIxNzkxMjM0NTY3ODkwMTI0MCIsImkiOjB9"
}

Get the replies to a comment:#

{
    "postId": "2907515653209522683",
    "parentCommentId": "17912345678901234"
}

Response#

Response parameters#

Field Type Description
comments array The comments - the fields of an item
cursor string The cursor of the next page. An empty string means there are no more pages
hasNextPage boolean Whether there is a next page

Fields of the comments array#

Field Type Description
type string The type of the comment. incoming for an incoming comment, outgoing - for a comment of the account
commentId string The identifier of the comment
timestamp integer The time of the comment in UNIX format (in seconds)
typeComment string The kind of the comment. textComment for a text comment, imageComment - for a comment with a GIF
textComment string The text of the comment.
Only for typeComment = textComment
caption string The caption to the GIF, may be empty.
Only for typeComment = imageComment
kind string The subtype of the comment: comment - an ordinary comment, reply - a reply in a branch, mention - a comment mentioning the account
downloadUrl string The link to the GIF; it leads to Giphy.
Only for typeComment = imageComment
fileName string The name of the GIF file with the extension.
Only for typeComment = imageComment
mimeType string The MIME type of the file, always image/gif.
Only for typeComment = imageComment
jpegThumbnail string Always an empty string.
Only for typeComment = imageComment
senderId string The numeric identifier of the author of the comment.
Only for type = incoming
senderName string The name of the author of the comment from the Instagram profile. If there is no name in the profile - the username without @.
Only for type = incoming
senderUsername string The username of the author of the comment in the @username form.
Only for type = incoming
likeCount integer The number of likes of the comment
replyCount integer The number of replies in the branch of the comment

Response body example#

An array of comments:#

{
    "comments": [
        {
            "type": "incoming",
            "commentId": "17912345678905555",
            "timestamp": 1788407884,
            "typeComment": "textComment",
            "textComment": "An example of a text comment",
            "kind": "comment",
            "senderId": "49547665464",
            "senderName": "GREEN-API",
            "senderUsername": "@green_api",
            "likeCount": 3,
            "replyCount": 0
        },
        {
            "type": "incoming",
            "commentId": "17912345678906666",
            "timestamp": 1788407884,
            "typeComment": "imageComment",
            "caption": "How do you like it?",
            "kind": "comment",
            "downloadUrl": "https://media1.giphy.com/media/v1.Y2lkPTQ2Yzg2Zjc3/3o7TKSjRrfIPjeiVyM/giphy.gif",
            "fileName": "3o7TKSjRrfIPjeiVyM.gif",
            "mimeType": "image/gif",
            "jpegThumbnail": "",
            "senderId": "25025320",
            "senderName": "Instagram",
            "senderUsername": "@instagram",
            "likeCount": 6,
            "replyCount": 2
        }
    ],
    "cursor": "eyJzIjoiY29tbWVudHM6MjkwNzUxNTY1MzIwOTUyMjY4MyIsImMiOiIxNzkxMjM0NTY3ODkwMTI0MCIsImkiOjB9",
    "hasNextPage": true
}

An outgoing comment:#

{
    "comments": [
        {
            "type": "outgoing",
            "commentId": "17912345678901234",
            "timestamp": 1788407884,
            "typeComment": "textComment",
            "textComment": "Thank you all!",
            "kind": "comment",
            "likeCount": 3,
            "replyCount": 0
        }
    ],
    "cursor": "",
    "hasNextPage": false
}

There are no comments or the output has ended:#

{
    "comments": [],
    "cursor": "",
    "hasNextPage": false
}

GetComments errors#

For a list of errors common to all methods, refer to the Common errors section

HTTP code Error ID Description
400 Bad Request
Validation failed
Validation error
400 Validation failed. Details:
'cursor' must be a cursor from a previous response
The cursor is damaged or was issued for another output
400 Validation failed. Details:
'parentCommentId' with value 'abc' fails to match the required pattern: /^\d+$/
The identifier of the comment whose replies are requested must consist of digits
400 Validation failed. Details:
'count' must be less than or equal to 200
The count value is from 201 to 1000
400 Validation failed. Details:
'count' must be less than or equal to 1000
The count value is greater than 1000

Request examples#

import requests

url = "{{apiUrl}}/waInstance{{idInstance}}/getComments/{{apiTokenInstance}}"

payload = {"postId": "2907515653209522683", "count": 20}
headers = {'Content-Type': 'application/json'}

response = requests.post(url, json=payload, headers=headers)

print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/getComments/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{"postId": "2907515653209522683", "count": 20}'