Working …
This value you provided is not a number. Please try again.
This value you provided is not an integer. Please try again.
The value entered is not a valid Vanderbilt Medical Record Number (i.e. 4- to 9-digit number, excluding leading zeros). Please try again.
The value you provided must be within the suggested range
The value you provided is outside the suggested range
This value is admissible, but you may wish to double check it.
The value entered must be a time value in the following format HH:MM within the range 00:00-23:59 (e.g., 04:32 or 23:19).
This field must be a 5 or 9 digit U.S. ZIP Code (like 94043). Please re-enter it now.
This field must be a 10 digit U.S. phone number (like 415 555 1212). Please re-enter it now.
This field must be a valid email address (like joe@user.com). Please re-enter it now.
The value you provided could not be validated because it does not follow the expected format. Please try again.
Required format:
REDCap Logo
Plugins, Hooks, & External Modules
Developer methods for
Plugins, Hooks, & External Modules
Hook functions

REDCap Developer Tools:
Documentation for Plugins, Hooks, & External Modules

REDCap Version 14.9.1
REDCap::getReport
(REDCap >= 8.4.1)
REDCap::getReport — Get a report in json, xml, csv, or array format.
Description
mixed REDCap::getReport ( int $report_id [, string $outputFormat = 'array' [, bool $exportAsLabels = FALSE [, bool $exportCsvHeadersAsLabels = FALSE ]]] )
Given a report id and output format, this method returns a report that has been defined in a project. The default format is Array, but JSON, CSV, and XML are also available.
Parameters
report_id
The id of the report to retrieve. The report_id is found for a given report in the far-right column of a project's "My Reports & Exports" page.
outputFormat
The output format of the report's data. Valid options: 'array', 'csv', 'json', and 'xml'. By default, 'array' is used.
exportAsLabels
Sets the format of the data returned. If FALSE, it returns the raw data. If TRUE, it returns the data as labels (e.g., "Male" instead of "0"). By default, FALSE is used. This parameter is ignored if return_format = "array" since "array" only returns raw values.
exportCsvHeadersAsLabels
Sets the format of the CSV headers returned (only applicable to 'csv' return formats). If FALSE, it returns the variable names as the headers. If TRUE, it returns the fields' Field Label text as the headers. By default, FALSE is used.
Return Values
A report in the requested output format.
Examples
Example #1:
Simple example to retrieve a report in JSON format.
$report = REDCap::getReport('42', 'json');
Example #2:
Simple example to retrieve a report in CSV format with labels in the data.
$report = REDCap::getReport('896', 'csv', true);
REDCap 14.9.1 - © 2024 Vanderbilt University