If you can use version 2 of the Rest API, then the endpoint looks something like this:
domain.com/wp-json/wp/v2/comments?post=1&per_page=2
where the post parameter is the identifier of the message for which you are receiving comments, and per_page is how much is shown. If you need a list of all comments and limit them, then:
domain.com/wp-json/wp/v2/comments?per_page=2
You can also add a page parameter to display a different number of calculated comment values:
domain.com/wp-json/wp/v2/comments?post=1&per_page=2&page=3
which will return the 5th and 6th comments (page 3 of the comments when there are 2 per page) for the message with identifier 1
source share