Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [4.5.0] - 2025-03-06
- Add StatsApi with get, byDomains, byCategories, byEmailServiceProviders, byDate endpoints
Comment on lines +1 to +2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix the 4.5.0 release date.

4.5.0 is listed as 2025-03-06, but the next entry below is 4.4.0 on 2025-12-08. That chronology can't be correct, so this should be updated to the actual 2026 release date before publishing.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CHANGELOG.md` around lines 1 - 2, Update the release header "## [4.5.0] -
2025-03-06" in CHANGELOG.md to the correct 2026 release date (replace
"2025-03-06" with the actual 2026 date for the 4.5.0 release) so the chronology
with "## [4.4.0] - 2025-12-08" is correct.


## [4.4.0] - 2025-12-08
- Add ES module support by specifying import path in package.json by @narekhovhannisyan in https://github.com/mailtrap/mailtrap-nodejs/pull/112
- Bump new minor version as previous changes were pretty huge and shouldn't be released under patch version
Expand Down
98 changes: 98 additions & 0 deletions examples/general/stats.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { MailtrapClient } from "mailtrap"

const TOKEN = "<YOUR-TOKEN-HERE>";
const TEST_INBOX_ID = "<YOUR-TEST-INBOX-ID-HERE>"
const ACCOUNT_ID = 123456

const client = new MailtrapClient({ token: TOKEN, testInboxId: TEST_INBOX_ID, accountId: ACCOUNT_ID });

const statsClient = client.general.stats

const testGetStats = async () => {
try {
const result = await statsClient.get({
start_date: "2026-01-01",
end_date: "2026-01-31",
})
console.log("Stats:", JSON.stringify(result, null, 2))
} catch (error) {
console.error(error)
}
}

const testGetStatsWithFilters = async () => {
try {
const result = await statsClient.get({
start_date: "2026-01-01",
end_date: "2026-01-31",
sending_domain_ids: [1, 2],
sending_streams: ["transactional"],
categories: ["Transactional", "Marketing"],
email_service_providers: ["Gmail", "Yahoo"],
})
console.log("Filtered stats:", JSON.stringify(result, null, 2))
} catch (error) {
console.error(error)
}
}

const testGetStatsByDomains = async () => {
try {
const result = await statsClient.byDomains({
start_date: "2026-01-01",
end_date: "2026-01-31",
})
console.log("Stats by domains:", JSON.stringify(result, null, 2))
} catch (error) {
console.error(error)
}
}

const testGetStatsByCategories = async () => {
try {
const result = await statsClient.byCategories({
start_date: "2026-01-01",
end_date: "2026-01-31",
})
console.log("Stats by categories:", JSON.stringify(result, null, 2))
} catch (error) {
console.error(error)
}
}

const testGetStatsByEmailServiceProviders = async () => {
try {
const result = await statsClient.byEmailServiceProviders({
start_date: "2026-01-01",
end_date: "2026-01-31",
})
console.log("Stats by email service providers:", JSON.stringify(result, null, 2))
} catch (error) {
console.error(error)
}
}

const testGetStatsByDate = async () => {
try {
const result = await statsClient.byDate({
start_date: "2026-01-01",
end_date: "2026-01-31",
})
console.log("Stats by date:", JSON.stringify(result, null, 2))
} catch (error) {
console.error(error)
}
}

(async () => {
try {
await testGetStats()
await testGetStatsWithFilters()
await testGetStatsByDomains()
await testGetStatsByCategories()
await testGetStatsByEmailServiceProviders()
await testGetStatsByDate()
} catch (error) {
console.error("Error running stats examples:", error)
}
})()
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mailtrap",
"description": "Official mailtrap.io API client",
"version": "4.4.0",
"version": "4.5.0",
"author": "Railsware Products Studio LLC",
"dependencies": {
"axios": ">=0.27"
Expand Down
Loading
Loading