Question
How can the Twilio API be used to get overall statistics for all channels and messages with given time ranges?
One example of this statistic is: What is the total message count for all channels today?
Bruteforce method (Non-ideal)
Get all channel
s for a Twilio service. Get all messages
for each channel. Check the timestamp of these messages.
The bruteforce method mentioned above is not scalable. Is there a more efficient way this could be done?
Twilio developer evangelist here.
To get that information from the API, you're right you will need to loop through your channels and fetch the messages.
An alternative is to register for the onMessageSent
webhook and aggregate the messages in your own database.
Hope this helps.