Here’s a way to get all unsubscribed in your account ever;
I’m having trouble with the fact it starts blocking me after a few “bad requests” trying to remove a contact that’s not in the list, but oh well. This is progress.
def get_all_unsubscribed(): import mailjet api = mailjet.Api() list_ids = [x['id'] for x in api.lists.all()['lists']] unsubscribed = [] for list_id in list_ids: total_accounted_for = 0 total_count = api.lists.Contacts(id=list_id, status='unsub')['total_cnt'] while total_accounted_for < total_count: if total_accounted_for: result = api.lists.Contacts(id=list_id, status='unsub', start=total_accounted_for) else: result = api.lists.Contacts(id=list_id, status='unsub') print 'found ... results ', len(result['result']) if not result['result']: print 'found end... @ ', total_accounted_for, total_count break for u in result['result']: unsubscribed.append(u) total_accounted_for += len(result['result']) return unsubscribed