Get daily email activity trend
curl --request GET \
--url http://localhost:2000/email-meter/stats/emails-trend/{startDate}/{endDate} \
--header 'Authorization: Bearer <token>'import requests
url = "http://localhost:2000/email-meter/stats/emails-trend/{startDate}/{endDate}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('http://localhost:2000/email-meter/stats/emails-trend/{startDate}/{endDate}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "2000",
CURLOPT_URL => "http://localhost:2000/email-meter/stats/emails-trend/{startDate}/{endDate}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://localhost:2000/email-meter/stats/emails-trend/{startDate}/{endDate}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("http://localhost:2000/email-meter/stats/emails-trend/{startDate}/{endDate}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:2000/email-meter/stats/emails-trend/{startDate}/{endDate}")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"message": "<string>",
"data": {
"series": [
{
"name": "Incoming",
"data": [
12,
18,
9,
25,
14,
22,
19
]
}
],
"labels": [
"2025-10-01",
"2025-10-02",
"2025-10-03",
"2025-10-04",
"2025-10-05",
"2025-10-06",
"2025-10-07"
]
}
}Email Statistics
Daily Email Activity Trend
Retrieves the trend of incoming and sent emails across the specified date range. - If no startDate or endDate is provided, the system defaults to the last 7 days (a week from today). - Each label in labels corresponds to a date in the range, and series contains counts of sent and received emails for each day.
GET
/
email-meter
/
stats
/
emails-trend
/
{startDate}
/
{endDate}
Get daily email activity trend
curl --request GET \
--url http://localhost:2000/email-meter/stats/emails-trend/{startDate}/{endDate} \
--header 'Authorization: Bearer <token>'import requests
url = "http://localhost:2000/email-meter/stats/emails-trend/{startDate}/{endDate}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('http://localhost:2000/email-meter/stats/emails-trend/{startDate}/{endDate}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "2000",
CURLOPT_URL => "http://localhost:2000/email-meter/stats/emails-trend/{startDate}/{endDate}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://localhost:2000/email-meter/stats/emails-trend/{startDate}/{endDate}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("http://localhost:2000/email-meter/stats/emails-trend/{startDate}/{endDate}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:2000/email-meter/stats/emails-trend/{startDate}/{endDate}")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"message": "<string>",
"data": {
"series": [
{
"name": "Incoming",
"data": [
12,
18,
9,
25,
14,
22,
19
]
}
],
"labels": [
"2025-10-01",
"2025-10-02",
"2025-10-03",
"2025-10-04",
"2025-10-05",
"2025-10-06",
"2025-10-07"
]
}
}Retrieves the trend of incoming and sent emails across the specified date range. Each label in
labels corresponds to a date in the range, and series contains counts of sent and received emails for each day.
Request
Headers
| Name | Type | Required | Description |
|---|---|---|---|
| Authorization | string | Yes | Bearer token |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| startDate | string | Yes | Start date of the range (ISO 8601). Defaults to 7 days before today |
| endDate | string | Yes | End date of the range (ISO 8601). Defaults to today |
Parameter Format
- Format:
YYYY-MM-DD(ISO 8601 date) - Timezone: UTC
- Default: Last 7 days if not provided
Response
200 OK - Successfully retrieved email activity trend
{
"message": "",
"data": {
"series": [
{
"name": "Incoming",
"data": [12, 18, 9, 25, 14, 22, 19]
},
{
"name": "Sent",
"data": [8, 15, 7, 20, 12, 18, 16]
}
],
"labels": [
"2025-10-01",
"2025-10-02",
"2025-10-03",
"2025-10-04",
"2025-10-05",
"2025-10-06",
"2025-10-07"
]
}
}
401 Unauthorized
{
"error": {
"code": "UNAUTHORIZED",
"message": "Missing or invalid token"
}
}
500 Internal Server Error
{
"error": {
"code": "SERVER_ERROR",
"message": "Internal server error"
}
}
Example
curl -X GET 'http://localhost:2000/email-meter/stats/emails-trend/2025-10-01/2025-10-07' \
-H 'Authorization: Bearer your-jwt-token'
Data Structure
Series Array
Each object in the series represents:| Field | Type | Description |
|---|---|---|
| name | string | Series name (“Incoming” or “Sent”) |
| data | array | Email counts corresponding to each date |
Labels Array
| Field | Type | Description |
|---|---|---|
| labels | array | Dates in YYYY-MM-DD format |
Data Alignment
series[0].data[i]corresponds tolabels[i]for Incoming emailsseries[1].data[i]corresponds tolabels[i]for Sent emails- All arrays have the same length
Use Cases
- Trend Analysis: Visualize email volume over time
- Capacity Planning: Identify peak email periods
- Performance Monitoring: Track daily email patterns
- Dashboard Visualization: Create line charts and graphs
- Seasonal Patterns: Identify weekly/monthly trends
Visualization Examples
Line Chart
// Example using Chart.js
const ctx = document.getElementById('emailTrend').getContext('2d');
new Chart(ctx, {
type: 'line',
data: {
labels: response.data.labels,
datasets: response.data.series
},
options: {
responsive: true,
scales: {
y: {
beginAtZero: true,
title: {
display: true,
text: 'Email Count'
}
}
}
}
});
Bar Chart
// Example for daily comparison
new Chart(ctx, {
type: 'bar',
data: {
labels: response.data.labels,
datasets: response.data.series
}
});
Analysis Metrics
Daily Totals
const dailyTotals = response.data.labels.map((label, index) => ({
date: label,
total: response.data.series[0].data[index] + response.data.series[1].data[index],
incoming: response.data.series[0].data[index],
sent: response.data.series[1].data[index]
}));
Trend Calculations
// Calculate moving average
const movingAverage = (data, period) => {
return data.map((_, index) => {
const start = Math.max(0, index - period + 1);
const subset = data.slice(start, index + 1);
return subset.reduce((a, b) => a + b, 0) / subset.length;
});
};
Best Practices
- Date Range: Use reasonable ranges (recommended: max 90 days)
- Caching: Cache trend data for dashboard performance
- Real-time Updates: Update trends periodically for live dashboards
- Empty Data: Handle days with zero emails gracefully
- Time Zones: Consider converting to local time zones for display
Performance Considerations
- Large Ranges: Longer date ranges may take more time to process
- Data Points: Each day represents a data point
- Caching: Results are cached for 15 minutes by default
- Memory Usage: Large datasets may impact client-side rendering
Related Endpoints
- Use
/email-meter/stats/hourly-trendsfor hourly breakdown - Use
/email-meter/stats/email-countsfor aggregate statistics - Use
/email-meter/stats/clients/incoming-trendsfor client-specific trends
Notes
- Data includes all email types (incoming, outgoing, internal)
- Weekends and holidays are included in the trend
- Zero-value days are included for complete timeline
- Data is calculated based on email timestamps in UTC
- Automated emails are included in counts unless filtered
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Start date of the range (ISO 8601). Defaults to 7 days before today if not provided.
End date of the range (ISO 8601). Defaults to today if not provided.
Was this page helpful?