@@ -31,7 +31,7 @@ def request(self, method, data):
3131 if response ["status" ] == "done" :
3232 if method in ["instagram/media/get_shortcode_by_id" , "instagram/media/get_id_by_shortcode" ]:
3333 return response
34-
34+
3535 if (
3636 response ["response" ]["status_code" ] == 200
3737 and response ["response" ]["content_type" ] == "application/json"
@@ -393,22 +393,32 @@ def get_media_likes_by_id(self, media_id):
393393 """
394394 return self .request ("instagram/media/get_likes_by_id" , {"id" : media_id })
395395
396- def get_media_comments (self , media_id , can_support_threading = True , min_id = None ):
396+ def get_media_comments (
397+ self , media_id , can_support_threading = True , min_id = None , order = None
398+ ):
397399 """
398400 Retrieve media comments by media id.
399401
400402 Args:
401403 media_id (int): Media id
402404 can_support_threading (bool): Set `False` if you want chronological order
403405 min_id (str): Use for pagination
406+ order (int): Comments order: 0 - popular (default), 1 - most recent, 2 - verified. Requires `can_support_threading` to be `True`
404407
405408 You can use the `min_id` parameter to paginate through comments (take from the `next_min_id` field of the response).
406409
407410 For more information, see documentation: https://docs.rocketapi.io/api/instagram/media/get_comments
408411 """
412+ if order is not None :
413+ if not can_support_threading :
414+ raise ValueError ("order requires can_support_threading to be True" )
415+ if order not in (0 , 1 , 2 ):
416+ raise ValueError ("order must be 0, 1 or 2" )
409417 payload = {"id" : media_id , "can_support_threading" : can_support_threading }
410418 if min_id is not None :
411419 payload ["min_id" ] = min_id
420+ if order is not None :
421+ payload ["order" ] = order
412422 return self .request ("instagram/media/get_comments" , payload )
413423
414424 def get_media_shortcode_by_id (self , media_id ):
0 commit comments