Is there a way to get CSV-formatted output via a REST call?

We have a 3rd-party app that can import data periodically from a URL pointing to a CSV file, so the aim is to provide it with a Civi URL (probably going to a custom api function) that returns selected data as if it were just a plain CSV file.

EDIT: Civi 4.6.10 currently on WP moving to Drupal

  • What CMS and Civi version are you using? Commented Jan 18, 2016 at 17:41

2 Answers 2


Not natively, you would need to write a custom extension to do the relatively simple task of converting array output from the api to csv output.

  • After converting to CSV, how would the extension send that format back to the client? Won't anything from the REST interface be XML or JSON? Would it make sense to add a "&csv=1" like "&json=1" to CRM_Utils_REST?
    – Aidan
    Commented Jan 19, 2016 at 9:36
  • My suggestion was for the extension to define a different path and not use the same rest url as core.
    – Coleman
    Commented Jan 19, 2016 at 16:38

In Drupal, you can do this using existing plugins and no custom code.

  • Build a Drupal View of your CiviCRM data (using Views module for Drupal + CiviCRM's Views CiviCRM module, part of the CiviCRM download for Drupal).
  • Use filters in the View to correctly show the data you want to export to external service.
  • Use Views Data Export to provide a CSV output format of this view.
  • Check the View display(s) have appropriate access restrictions (edit settings in View).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.