Emails Total Count For Folders

Hi,
I have read the v3 documentation. In v3, we do not get the total records count. In the screenshot below (which is of the email inbox using v2), we show the count of emails in each folder, such as 0, 10, 15, etc. For v3, should we show the count with folders or not? If yes, then how can we get total count of email?

Another question is: if this functionality is not supported by v3, can we show the unread count for the “Inbox” folder for only the selected page? For instance, if we have set pagination to 20, can we display the count of unread emails within these 20 records, as the response indicates which emails are unread? Can we show this unread count in the Inbox left folder?

Hello @Emmad_Altaf Let me take a look later today and will get back to you. Please keep in mind that we’re on a company holiday today so response might come tomorrow or Wednesday.

1 Like

Alright @Emmad_Altaf got a lengthy response from the platform team :partying_face:

  1. If you only needs to get all messages from one thread, you can use Return all Messages endpoint and pass the thread_id query parameter: Nylas v3 Email, Calendar, and Contacts API docs | Nylas Docs
    1. If you only needs to get the number of messages from one thread, you can use Return a thread endpoint. There is a field called message_ids in the response. The number of messages is the size of message_ids array: Nylas v3 Email, Calendar, and Contacts API docs | Nylas Docs
    1. We do not support expanding message bodies for Return all threads, because the pagination will become very complex. We will have to paginate both the messages in each thread, and the thread list itself.
    1. However, there is a way to get around this problem. You can call Return all Threads first. For each thread returned, then expand the messages by making another Return all messages call.

Hope this helps :sunglasses:

Thank you @Blag for detailed response. I need clarity for threads total count? Can we get total count of threads in an inbox? And next question is that should we show threads count in “left action: INBOX folder” as shown in above screenshot e.g “INBOX (20)”. If yes then how can we show this count because we are not getting threads count in v3.

Hey @Emmad_Altaf I think I mixed up your questions as my answer seems to solve the other one…sorry about that :frowning:

I don’t think we have any direct way of knowing how many threads are in a inbox…you might need to get all threads and count them…

Hi @Blag ,
We can get all threads but we have set pagination which limits us to show only 20/50/100/200 etc records per page. In response we are getting a property “unRead” threads So we can calculate count of only these unRead threads from that set page whose limit is set 20/50/100/200 etc. But could not count total threads or total unRead threads from all inbox. I want to know if it is poosible to count total threads from an inbox and can we also calculate total unRead count for whole inbox so that it should not consider set page limit. I mean if there are 1700 threaads in an inbox then I want to know the count that there are total 1700 threads from whole inbox and there are 900 unRead threads out of these 1700.