Skip to main content
Published: December 29 2005, 4:03:00 PMUpdated: July 27 2022, 12:32:38 AM

How to retrieve the WatchCount() info from GetSellerEvents or GetItem API calls

To retrieve WatchCount property in an item node, one needs to call set IncludeWatchCount property to specifies whether to return the value when making GetSellerEvents or GetItem request. The count can be retrieved through the raw api calls only since the setter is not available on the correspondent wrapper class .

NOTE. 1. WatchCount is only returned with DetailLevel ReturnAll.
2. You must be the seller of the item to retrieve the watch count via GetItem call.

The code sample for getting watchcount from GetItem request is listed below:

ApiCall api = new ApiCall(apiContext);
ItemIDType itemID = new ItemIDType("xxxxxxx");
DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] {
DetailLevelCodeType.ReturnAll,
};
api.setDetailLevel(detailLevels);

GetItemRequestType request = new GetItemRequestType();
request.setItemID(itemID);
request.setIncludeWatchCount(new Boolean("true"));
GetItemResponseType resp = (GetItemResponseType)api.executeByApiName("GetItem",request);
ItemType item = resp.getItem();
String watchCt = item.getWatchCount());

How well did this answer your question?
Answers others found helpful

Got thoughts? Click the feedback button – your insights help us improve!