Skip to content

Post identifier#

Beta version

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

The post identifier (postId) is the marker of an Instagram post (a post, a carousel, a Reel).

It is assigned by the system when the post is created.

The field accepts three interchangeable forms of notation:

Form Example
Numeric identifier 2907515653209522683
Short code ChZkhT4cQH7
Post link https://www.instagram.com/p/ChZkhT4cQH7/

The standard identifier and the short code#

The short code in the link is the same numeric identifier written in the base64 format with a URL-safe alphabet. That is why one is unambiguously converted into the other, and no extra request is needed for the conversion:

2907515653209522683  <->  ChZkhT4cQH7

In its own responses Instagram sometimes returns the identifier as a "post_owner" pair, for example 3977953643059237032_38322407954. Such a value is accepted as a numeric identifier as well - the part before the _ character is used.

How to get the identifier#

The post identifier can be obtained:

  1. In the response of the publishing methods SendPostByUrl, SendReelByUrl and SendAlbumPostByUrl

    The post identifier is specified in the "postId" field
    Example of a response:

    {
        "postId": "2907515653209522683"
    }
    

  2. By the method of getting the posts of a user GetUserPosts

    The post identifier is specified in the "postId" field of every item of the posts array
    Example of an item of the output:

    {
        "postId": "2907515653209522683",
        "type": "image",
        "caption": "The caption of the post",
        "timestamp": 1788407884,
        "likeCount": 42,
        "commentCount": 7,
        "downloadUrl": "https://scontent.cdninstagram.com/v/photo.jpg",
        "postUrl": "https://www.instagram.com/p/ChZkhT4cQH7/",
        "commentsDisabled": false
    }
    

  3. By the method of getting the data of a post GetPostInfo - if you know the link to the post or its short code

    The post identifier is specified in the "postId" field
    Example of a response to the {"postId": "https://www.instagram.com/p/ChZkhT4cQH7/"} request:

    {
        "postId": "2907515653209522683",
        "type": "image",
        "caption": "The caption of the post",
        "timestamp": 1788407884,
        "likeCount": 42,
        "commentCount": 7,
        "downloadUrl": "https://scontent.cdninstagram.com/v/photo.jpg",
        "postUrl": "https://www.instagram.com/p/ChZkhT4cQH7/",
        "commentsDisabled": false
    }
    

  4. When handling the notifications about comments

    The post identifier is specified in the postData.postId field, and the link to the post - in the postData.postUrl field
    Example of a part of a notification:

    {
        "postData": {
            "chatId": "74857974059",
            "chatUsername": "@green_api_eng",
            "postId": "2907515653209522683",
            "postUrl": "https://www.instagram.com/p/ChZkhT4cQH7/"
        }
    }
    

  5. From the link to the post

    The short code in the link is the same post, so the link can be passed to the methods as is:

    https://www.instagram.com/p/ChZkhT4cQH7/  ->  ChZkhT4cQH7  ->  2907515653209522683
    

The comment identifier#

A comment is addressed by a separate identifier commentId - it is not related to the postId of the post.

The comment identifier can be obtained:

  1. In the response of the SendComment method

    The comment identifier is specified in the "commentId" field
    Example of a response:

    {
        "commentId": "17912345678901234"
    }
    

  2. By the method of getting the comments of a post GetComments

    The comment identifier is specified in the "commentId" field of every item of the comments array
    Example of an item of the output:

    {
        "type": "incoming",
        "commentId": "17912345678901234",
        "typeComment": "textComment",
        "textComment": "An example of a text comment",
        "timestamp": 1788407884,
        "likeCount": 3,
        "replyCount": 0
    }
    

  3. When handling the notifications about comments

    The comment identifier is specified in the "commentId" field, and the identifier of the comment a reply is left to - in the commentData.parentCommentId field
    Example of a part of a notification:

    {
        "commentId": "17912345678901234",
        "commentData": {
            "typeComment": "textComment",
            "parentCommentId": "",
            "textCommentData": {
                "text": "An example of a text comment"
            }
        }
    }