Answers.Body: <p>I think you're looking for the <code>ReportTemplate.getrows</code> API call.  You can see examples of its use in the API explorer's built-in help (also available <a href="https://github.com/civicrm/civicrm-core/blob/master/api/v3/examples/ReportTemplate/Getrows.php" rel="nofollow noreferrer">on Github</a>).  More examples exist in the <a href="https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ReportTemplateTest.php" rel="nofollow noreferrer">tests folder</a>, since the most common use of this API is to create tests for reports.</p>
  
  <p>UPDATE: As @demerit points out, this answer isn't really correct - but it CAN be :)  All(?) of the info on this mailing report is also available from the "Mailing Summary" report (for the stats) and the "Mailing Detail" report (if you need drilled-down data on click-throughs etc.).  So I recommend Demerit's answer if you're writing an extension, but my answer if you need to collect this data over REST.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-17T03:17:44.307Z
Answers.Text: I don't know if this phrase has ever been said before but "Jon this answer might be wrong?". The mailing report here isn't a CiviReport it's a (CRM_XXX_)Page. Yes there are various mailing reports you can get from ReportTemplate.getrows but I don't think the one in question.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-18T14:37:39.533Z
Answers.Text: @Demerit Good points.  I updated my answer to improve it.
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-16T20:21:39.853Z
Answers.LastActivityDate: 2019-04-18T14:37:05.477Z
Answers.LastEditDate: 2019-04-18T14:37:05.477Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>You might have to do something like this:
  <a href="https://github.com/civicrm/civicrm-core/blob/master/CRM/Mailing/Page/Report.php#L107-L110" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/blob/master/CRM/Mailing/Page/Report.php#L107-L110</a></p>
  
  <p>For the $this variable, you can probably use a dummy, e.g.
  <code>
  $page = new CRM_Mailing_Page_Report();
  $page-&gt;_mailing_id = 388; // or whatever number
  $report = CRM_Mailing_BAO_Mailing::report($page-&gt;_mailing_id);
  CRM_Mailing_BAO_Mailing::getMailingContent($report, $page);
  </code></p>
  
  <p>Lower down it assigns $report to the smarty template, and you can see how it's used at <a href="https://github.com/civicrm/civicrm-core/blob/master/templates/CRM/Mailing/Page/Report.tpl" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/blob/master/templates/CRM/Mailing/Page/Report.tpl</a>, so you should be able to do the same thing in php, accessing the member elements of $report.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-16T16:54:10.223Z
Answers.Text: I'm not entirely sure how that would work.
  
  Is it possible to achieve what you describe in the API explorer?
Answers.UserDisplayName: user77510
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-16T17:08:33.757Z
Answers.Text: I'm not completely sure that you CAN'T do it from the api, but the functionality seems partly tied to the page. I've updated answer a bit.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-16T15:17:08.297Z
Answers.LastActivityDate: 2019-04-16T17:08:10.760Z
Answers.LastEditDate: 2019-04-16T17:08:10.760Z
Answers.UserDisplayName: Demerit
Body: <p>I'm trying to get Report data about a Sent email through the API. I can see the report at:</p>
  
  <p><code>www.example.com/civicrm/mailing/report?mid=388&amp;reset=1</code></p>
  
  <p>And I can get data corresponding to the email from the API explorer as follows:</p>
  
  <p><a href="https://i.sstatic.net/yMVm8.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/yMVm8.png" alt="API explorer get civiMail"></a></p>
  
  <p>But I can't seem to access the civiMail report with the API. I have tried a few options but can't seem to find it. Any tips?</p>
  
Tags: <civimail><api><reports>
Title: Get civiMail report by API
ThreadText: # Get civiMail report by API
  
  (Asked by: username_0 on 2019-04-16)
  
  I'm trying to get Report data about a Sent email through the API. I can see the report at:
  
  `www.example.com/civicrm/mailing/report?mid=388&reset=1`
  
  And I can get data corresponding to the email from the API explorer as follows:
  
  [![API explorer get civiMail](https://i.sstatic.net/yMVm8.png)](https://i.sstatic.net/yMVm8.png)
  
  But I can't seem to access the civiMail report with the API. I have tried a few options but can't seem to find it. Any tips?
  
  **Tags:** civimail, api, reports
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-04-16. Score: 2
  
  I think you're looking for the `ReportTemplate.getrows` API call. You can see examples of its use in the API explorer's built-in help (also available [on Github](https://github.com/civicrm/civicrm-core/blob/master/api/v3/examples/ReportTemplate/Getrows.php)). More examples exist in the [tests folder](https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ReportTemplateTest.php), since the most common use of this API is to create tests for reports.
  
  UPDATE: As @demerit points out, this answer isn't really correct - but it CAN be :) All(?) of the info on this mailing report is also available from the "Mailing Summary" report (for the stats) and the "Mailing Detail" report (if you need drilled-down data on click-throughs etc.). So I recommend username_2's answer if you're writing an extension, but my answer if you need to collect this data over REST.
  
  > **Comments:**
  > **username_2**: I don't know if this phrase has ever been said before but "Jon this answer might be wrong?". The mailing report here isn't a CiviReport it's a (CRM_XXX_)Page. Yes there are various mailing reports you can get from ReportTemplate.getrows but I don't think the one in question.  
  > **username_1**: @username_2 Good points.  I updated my answer to improve it.  
  
  ---
  
  ### Answer by username_2 on 2019-04-16. Score: 1
  
  You might have to do something like this:
  <https://github.com/civicrm/civicrm-core/blob/master/CRM/Mailing/Page/Report.php#L107-L110>
  
  For the $this variable, you can probably use a dummy, e.g.
  `$page = new CRM_Mailing_Page_Report();
  $page->_mailing_id = 388; // or whatever number
  $report = CRM_Mailing_BAO_Mailing::report($page->_mailing_id);
  CRM_Mailing_BAO_Mailing::getMailingContent($report, $page);`
  
  Lower down it assigns $report to the smarty template, and you can see how it's used at <https://github.com/civicrm/civicrm-core/blob/master/templates/CRM/Mailing/Page/Report.tpl>, so you should be able to do the same thing in php, accessing the member elements of $report.
  
  > **Comments:**
  > **username_0**: I'm not entirely sure how that would work.  Is it possible to achieve what you describe in the API explorer?  
  > **username_2**: I'm not completely sure that you CAN'T do it from the api, but the functionality seems partly tied to the page. I've updated answer a bit.  
  
  ---
  
  