N
Novu2w ago
Soumith

Hi Team,

Is there any way to Get Messages of a subscriber ordered by latest messages? If I send limit as 50 to getMessages API, it is giving me top 50 in chronological order but I'm looking for latest 50 messages to display on the app. Please let me know if that is possible.
6 Replies
Ask Inkeep
Ask Inkeep2w ago
Hi @Soumith, I'm an AI assistant for Novu. While a team member reviews this question, I'll see if I can find relevant sources for your question. ----------------------------- While I generate an answer, here are some sources that might be helpful: * Get messages * Recipes * Backend SDK methods * Get in-app notification feed for a particular subscriber -----------------------------
Ask Inkeep
Ask Inkeep2w ago
Answer Hi there, To retrieve the latest 50 messages for a subscriber using the Novu API, you can use the getMessages API endpoint. Currently, the API retrieves messages in chronological order, and there isn't a direct parameter to fetch them in reverse chronological order (from the newest to the oldest). However, you can still achieve this by fetching the messages as you currently do and then reversing the order in your application logic after retrieval. This means you would programmatically sort the messages by their timestamp in descending order once you have fetched them. If you're fetching messages and finding that they're not in the expected order, you might want to double-check the timestamp data and ensure that your sorting logic is functioning correctly. For more details on fetching messages, you can refer to the official documentation here: Get messages (1) . Let me know if you need further assistance!
Soumith
Soumith2w ago
Thanks for the quick response, to fetch all notifications and reverse it programatically, I should know how many messages are there for that subscriber right? Is there any way I can skip the limit to get all messages? I see by default limit is 10.
Ask Inkeep
Ask Inkeep2w ago
Got it. Tagging @Support for additional help. Got it. Tagging @Support for additional help.
Pawan Jain
Pawan Jain2w ago
@Soumith There is small bug there, if you use any filter like channel or subscriberId, then it will return last created order
Soumith
Soumith4d ago
@Pawan Jain In that case, is it possible to get all notifications without a limit(default 10) on it for specific subscriber?