Skip to content

GetUserPosts#

Beta version

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

The method returns the posts of a user - the profile feed, the newest posts first.

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

Request#

To get the posts of a user, you have to execute a request at:

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

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

Request parameters#

Parameter Type Mandatory Description
chatId string Yes The numeric account identifier or a username with the @ prefix
count integer No How many posts to return. The default is 12 (one Instagram page), the maximum is 100
cursor string No The cursor of the next page from the cursor field of the previous response

Paginated output#

The response is a page of the output: the posts in posts, the cursor of the next page in cursor and the hasNextPage flag.

The first request is sent without cursor - the beginning of the output is returned. The next page is requested with the value of the cursor field from the previous response, passed without changes.

A cursor issued for another account or another method, as well as a modified cursor, is rejected by the method with the 400 error Validation failed. Details: 'cursor' must be a cursor from a previous response.

The end of the output is indicated by hasNextPage: false and an empty cursor.

Request body example#

The first page:

{
    "chatId": "49547665464"
}

By username:

{
    "chatId": "@green_api",
    "count": 24
}

The next page by the cursor:

{
    "chatId": "49547665464",
    "count": 12,
    "cursor": "eyJzIjoicG9zdHM6NDk1NDc2NjU0NjQiLCJjIjoiUVZGRVVtcHhkSFZ2Vm1sTmEyeGhYMGgwTUZvIiwiaSI6MH0"
}

Response#

Response parameters#

Field Type Description
posts array The posts. The format of an item is the same as the response of the GetPostInfo method
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 an item#

Field Type Description
postId string The post identifier
type string The type of the post: image, album, video or reel
caption string The caption of the post
timestamp integer The time of the publication in UNIX format (in seconds)
likeCount integer The number of likes
commentCount integer The number of comments
downloadUrl string The link to the file: the video for a feed video and a Reel, the first image for a photo and a carousel. It is valid for a limited time
urlFiles array The files of a carousel. Only for type = album. Fields of the array
urlsCount integer The number of files in a carousel. Only for type = album
postUrl string The permanent link to the post on the web
commentsDisabled boolean The comments to the post are closed

Response body example#

{
    "posts": [
        {
            "postId": "2907515653209522683",
            "type": "image",
            "caption": "a single image",
            "timestamp": 1788407884,
            "likeCount": 42,
            "commentCount": 7,
            "downloadUrl": "https://scontent.cdninstagram.com/v/photo.jpg",
            "postUrl": "https://www.instagram.com/p/ChZkhT4cQH7/",
            "commentsDisabled": false
        },
        {
            "postId": "2907515653209522684",
            "type": "reel",
            "caption": "a single Reel",
            "timestamp": 1788407884,
            "likeCount": 42,
            "commentCount": 7,
            "downloadUrl": "https://scontent.cdninstagram.com/v/video.mp4",
            "postUrl": "https://www.instagram.com/reel/ChZkhT4cQH8/",
            "commentsDisabled": false
        },
        {
            "postId": "2907515653209522685",
            "type": "album",
            "caption": "an album (several images or videos)",
            "timestamp": 1788407884,
            "likeCount": 42,
            "commentCount": 7,
            "downloadUrl": "https://scontent.cdninstagram.com/v/photo.jpg",
            "urlFiles": [
                {"type": "image", "downloadUrl": "https://scontent.cdninstagram.com/v/photo.jpg"},
                {"type": "video", "downloadUrl": "https://scontent.cdninstagram.com/v/video.mp4"},
                {"type": "image", "downloadUrl": "https://scontent.cdninstagram.com/v/photo2.jpg"}
            ],
            "urlsCount": 3,
            "postUrl": "https://www.instagram.com/p/ChZkhT4cQH9/",
            "commentsDisabled": false
        }
    ],
    "cursor": "eyJzIjoicG9zdHM6NDk1NDc2NjU0NjQiLCJjIjoiUVZGRVVtcHhkSFZ2Vm1sTmEyeGhYMGgwTUZvIiwiaSI6MH0",
    "hasNextPage": true
}

There are no posts or the output has ended:

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

GetUserPosts 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:
'count' must be less than or equal to 100
The count value is from 101 to 1000
400 Validation failed. Details:
'count' must be less than or equal to 1000
The count value is greater than 1000
400 account is private The profile is private: the posts are not available
400 user not found There is no account with this username or identifier

Request examples#

import requests

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

payload = {"chatId": "@green_api", "count": 24}
headers = {'Content-Type': 'application/json'}

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

print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/getUserPosts/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{"chatId": "@green_api", "count": 24}'