ContributionsMost RecentMost LikesSolutionsPython SDK - JSON Hi All, Apologies if this is a simple question, however I cannot find any documentation that can assist. My goal here is to have severity 3 alerts in a JSON file, however I am unable to convert this list ‘alerts’ to JSON and I cannot find any documentation in the SDK v3 that could address this. # create an instance of the API class api_instance = logicmonitor_sdk.LMApi(logicmonitor_sdk.ApiClient(configuration)) id = 138 # Integer | size = 1000 # Integer | (optional) offset = 0 # Integer | (optional) filter = f'severity:3,cleared:true,startEpoch>:{startEpoch},endEpoch<:{endEpoch}' # String | (optional) #Loop shiznit alerts = [] end_found = False while not end_found: current = api_instance.get_alert_list_by_device_group_id(id, size=size, offset=offset, filter=filter).items alerts += current offset += len(current) end_found = len(current) != size #Print and encode result to json. This allows you to use this variable later in an API Put. with open('./customer/json/cleared_sev3_alerts.json', 'w') as content_output_json: result_encoded = json.JSONEncoder(sort_keys=False, indent =4).encode(alerts) content_output_json.write(str(alerts)) content_output_json.close() print(len(alerts)) Whenever I try to encode this I get the following alert. TypeError: Object of type Alert is not JSON serializable Doing a jsonDump gives us the same output and I’ve scoured stackoverflow for a way to fix this, but no luck. Does anyone know how I can get around this? Thank you so much SolvedRe: Alerts API - Size Limit You’d use the size query parameter along with the offset. Size is how many items to fetch, offset is which item (by index) to start with. So, you’d need to loop through making multiple API calls and aggregating the results into a single list/dict. Each iteration would increment the offset by the size: Call 1: Items 0-999 size=1000&offset=0 Call 2: Items 1000-1999: size=1000&offset=1000 Call 3: Items 2000-2999: size=1000&offset=2000 Call 4: Items 3000-3475: size=1000&offset=3000 On call 4, you’d notice that the number of returned items is less than the size (475<1000) so you’d know you’d reached the end. In Python, I do it like this: items = [] last_item_found = False query_size=1000 while not last_item_found: current_call_result = <your method to fetch the items from the api, I use the sdk> fetched_items = current_call_result.items items += fetched_items last_item_found = len(fetched_items) < query_size for item in items: print(item) Thank you so much. That makes a lot of sense. I appreciate the answer Alerts API - Size Limit Hi Everyone, I am running into a size limit issue in my pursuit of creating a quarterly report for a customer. What I am trying to do is narrow down my filter to have any cleared alert that is a severity 4 that was closed during that quarter. My issue is two-fold. I am not sure of the syntax that would only show alerts that cleared during that quarter (I am trying to do the equivalent of ‘between’ in python IF statements) and the size limit of 1000 is limiting because I cannot get a count of cleared alerts. I couldn’t find anything regarding pagination that can be used. I have also attempted to do the F12 then network button trick, but there is nothing that stands out there or anything that I can identify. And I have tried looking at other questions and couldn’t find anything relating this. This is my query: ?size=1000&filter=severity:4,cleared:true,startEpoch>:{startEpoch}&filter=severity:4,cleared:true,endEpoch<:{endEpoch} Any guidance would be greatly appreciated. Solved