Gigya Job Openings

comments.getUserComments JS

Skip to end of metadata
Go to start of metadata


The method retrieves the comments made by the logged in user.


Note: This method is also supported in our REST API. If you wish to execute this method from your server, please refer to

REST API > comments.getUserComments.




The following table lists the available parameters:

A reference to a callback function. Gigya calls the specified function along with the results of the API method when the API method completes.
The callback function should be defined with the following signature: functionName(Response).
The "Response Object Data Members" table below provides specification of the data that is passed to the callback function.
categoryIDstringThe identifier of the comments category by which to filter the retrieved comments.

The identifier of the comments stream by which to filter the retrieved comments.

*  If using a streamID you must also supply a categoryID, otherwise it will be ignored.

A developer-created object that is passed back unchanged to the application as one of the fields in the response object.
includeRepliesBooleanIndicates whether to include comment replies in the response.
includeStreamInfoBooleanThis parameter specifies whether to include a stream information object in the response. The default is 'false' . When set to 'true' the response to the method will include the StreamInfo object.
includeUIDBooleanIndicates whether the UID of the commenter will be included in the returned object per comment. The default value is 'false'.
limitintegerThe maximum number of comments to retrieve. The default value is 10.
sortstringThe comments may be sorted in one of the following orders:
  • "dateDesc" - (default) The first comment is the latest one. The comments are sorted by the timestamp of the root comment.
  • "votesDesc" - The first comment is the one that has the highest votes. The comments are sorted by the overall votes value (positive votes minus negative votes) of the root comment in each thread.
startstringDefines what should be the starting point of the comments to retrieve. The purpose of this parameter is pagination of the comments. Use the limit parameter to define how many comments per page. For the first page don't set the start parameter. The response includes a next field, which is a pointer to the starting point of the next page. Set the start parameter with the value of the next field received in the response of the previous getUserComments request.
tagstringThe tag by which to filter the retrieved comments.


Response Object Data Members

errorCode integer The result code of the operation. Code '0' indicates success, any other number indicates failure. For a complete list of error codes, see the Response Codes and Errors table.
errorMessage string A short textual description of an error associated with the errorCode for logging purposes.
callId string Unique identifier of the transaction, for debugging purposes.
context object The context object passed by the application as a parameter to the API method, or null if no context object has been passed.
commentsArray of
Comment objects
An array listing the comments. Each comment is represented by a JSON Comment object. In addition to the regular fields of the Comment object, the following fields are returned in the response of this method:
  • categoryID - the category ID of the retrieved comment
  • streamID -  the stream ID of the retrieved comment
commentCountintegerThe number of returned comments.
nextstringA pointer to the starting point of the next comments page. The purpose of this field is pagination of the comments. Use this field as the value of the 'start' parameter of the next getUserComments request, thus retrieving the next comments and avoid retrieving the same comments again.
hasMoreBooleanSpecifies whether there are more comments that were not returned within this response.


Code Sample

function printResponse(response) {  
    if ( response.errorCode == 0 ) {             
        if ( null!=response.comments && response.comments.length>0) {        
            var msg = "The first 3 comments are:\n\n";   
            for (var index in response.comments) {     
                msg += "Comment " + index + ": " + response.comments[0].commentText;
                msg += "\n  Written by: " + response.comments[0] + "\n\n";
        else {
            alert('No comments were returned');
    else {
        alert('Error :' + response.errorMessage);

var params = {
    streamID: "abc",
    limit: 3



  • This sample is not meant to be fully functional code. For brevity's sake, only the code required for demonstrating the API call itself is presented.
  • To run the code on your own domain, add your Gigya API key to the gigya.js URL. A Gigya API key can be obtained on the Site Dashboard page on Gigya's website. Please make sure that the domain from which you are loading the page is the same domain name that you used for generating the API key.
  • In some cases it is necessary to connect/login the user to a provider ? prior to calling the API method. You can learn more in the Social Login guide.