Created
September 16, 2021 22:12
-
-
Save zoernert/be2f014dc412f80c4002f4a7ceb98761 to your computer and use it in GitHub Desktop.
Retrieve Sendgrid Statistics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const sendgridAPIKey = 'YOUR_SENDGRID_API_KEY'; | |
| const fromDate = new Date(new Date().getTime() - (7*87600000)).toISOString().split('T')[0]; // last 7 days | |
| const axios = require("axios"); | |
| // Retrieve Statistics from Sendgrid | |
| const sendgridStatsResponds = await axios.get("https://sendgrid.com/v3/stats?start_date="+fromDate,{ | |
| headers: { | |
| 'content-type': 'application/json', | |
| 'Authorization': 'Bearer '+sendgridAPIKey | |
| } | |
| }); | |
| const mailStats = sendgridStatsResponds.data; | |
| console.log(mailStats); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment