TikTok-Api icon indicating copy to clipboard operation
TikTok-Api copied to clipboard

[BUG] - Comments API is not returning all comments

Open matheusmessora opened this issue 1 year ago • 1 comments

Describe the bug

When using video.comments(), we are not receiving the whole list of comments per page.

The buggy code

On videos with low comments, you can verify that the API isn't returning the complete list of comments. Some videos ID to test: 7125870357306723590 (This has at the moment 5 comments, and I can only retrieve 3 of them) 7125075747554741510 (This has 80)

If you try the second ID, it has a total of 80 comments (including replies), but the first page response only returns 18 comments. The default value of count variable is 20. So 2 comments are missing.

Another problem, if you try to offset video.comments(offset=18) or use any other number, you still can't return comments besides the first 18.

import logging
from TikTokApi import TikTokApi


with TikTokApi(logging_level=logging.DEBUG) as api:
    tiktok_video_id = 7125075747554741510
    video = api.video(id=tiktok_video_id)

    comments = video.comments()
    count = 0

    for comment in comments:
        print(comment)
        count = count + 1

    print(count)

Expected behavior

Expected to return 20 comments for the first page of the request. Expected to return more 20 comments after using offset.

Error Trace (if any)

I was debugging the api_response object, and you can see on the printscreen that comments has 18 elements, while the total is 80 and cursor is 30. Captura de tela 2022-07-30 030916

Desktop (please complete the following information):

  • OS: Windows
  • TikTokApi Version : Successfully installed TikTokApi-5.2.2

matheusmessora avatar Jul 30 '22 06:07 matheusmessora

Hey, did you find any solution to this issue?

MuhammadUsman-DevOps avatar Sep 09 '22 08:09 MuhammadUsman-DevOps

fixed V6

davidteather avatar Aug 08 '23 22:08 davidteather