SendGrid API | 获取广告系列统计信息

I've been looking for a way to get SendGrid reports but only for specific campaigns. I can see the stats on the Campaigns page of the SendGrid dashboard, but I can't find an API endpoint to get that data.

I was able to retrieve the Global and Overview stats with no problem, but in this case, is not helpful for me. I need per-campaign stats. Is there a way to get those reports through the API?

I solved my situation by creating unique (ID-like) categories for each campaign. This way, I can use the Category Stats API Endpoint. It's not a semantically correct usage of categories, but this is the only way I found to achieve this.

Update July 2017:

I also achieved this goal + much more by using SendGrid Subusers and the on-behalf-of: subuser_<username> header (search on behalf of subuser in the left searchbox). This header allows you to create requests using the parent account on behalf the subuser.

Campaign level stats are not available via the official Sendgrid API, at least not that I could find.

However, there are a couple of undocumented URLs you can use to get campaign level stats:

https://sendgrid.com/marketing_campaigns/campaigns/CAMPAIGN_ID/stats.csv

^ this returns data in CSV format

https://sendgrid.com/marketing_campaigns/campaigns/CAMPAIGN_ID/stats.json

^ this returns data in JSON format

Note that these are the endpoints used by the Sendgrid web client, and so require authentication via Cookie token.

To obtain a token you can use the https://api.sendgrid.com/v3/public/tokens endpoint, and send your username and password in the payload.

Then you can send that token as a Cookie along with your requests to the above Sendgrid web client endpoints. Note, you must use cookie name mako_auth_token.