Skip to content

Records Export

asaweero edited this page Aug 22, 2017 · 7 revisions

Returns a set of records from a project.

Note about export rights: Please be aware that Data Export user rights will be applied to this API request. For example, if you have 'No Access' data export rights in the project, then the API data export will fail and return an error. And if you have 'De-Identified' or 'Remove all tagged Identifier fields' data export rights, then some data fields might be removed and filtered out of the data set returned from the API. To make sure that no data is unnecessarily filtered out of your API request, you should have 'Full Data Set' export rights in the project.

Optional Parameters

  • records: an array of record IDs to pull. If omitted, all records will be pulled.
  • fields: an array of field names to pull. If omitted, all fields are pulled.
  • forms: an array of form names you wish to pull records for (spaces replaced with underscores). If omitted, all records are pulled.
  • events: an array of event names to pull records for (for longitudinal projects)
  • type: 'flat' to get all values for each record in one object, or 'eav' to get each field separately
  • rawOrLabel: choose how to receive the options of multiple choice fields. Either 'raw' for raw coded values (default) or 'label' for labels
  • rawOrLabelHeaders: This is included as part of the REDCap API, but is currently unused by redcap.js as it pertains only to csv return types.
  • exportCheckboxLabel: If exporting in 'flat' format with labels, this determines the format of checkbox field values.
  • exportSurveyFields: Set to 'true' to export the survey identifier and survey timestamp fields, or 'false' (default) to not export them.
  • exportDataAccessGroups: Set to 'true' to export the 'redcap_data_access_group' field when data access groups are utilized in the project or 'false' (default) to not export. If the API key being used belongs to a data access group, this parameter is forced to 'false' regardless
  • filterLogic: A string of logic text that will filter the data to be exported. For example, [age] > 30 will only export records where the age field is greater than 30.

Return Value

  • Return the project's Data.

Method Usage

var params = {
  type: 'flat'
}

redcap.records.export (params, function(err, res) {
      // error containts oprtional errors
      if (err) {
          // handle error
      }
      else {
          // res is return value
          console.log (res);
      }
}