I'm using an older version of CiviCRM (4.6) with Drupal 7 on Linux and until now I've not really used the command line stuff for CiviCRM, only for Drupal.

But I now need to do exports & imports of contacts etc to & from CiviCRM and so I've installed Drush & got it working. I've tried doing an export with the export.php script with Drush and can manipulate the search results to some degree. But for some reason if only exports the first 26 rows ... is the a parameter that I should be using to get the full rowcount?

Also, where is the best place to get a more detailed list of examples, list of possible parameters, usage notes etc?

Any pointers appreciated, thanks!


1 Answer 1


There are a few things that can help you out:

  • Most importantly, the API Explorer (Support menu » Developer » API Explorer). It will build your drush command for you through a GUI.
  • You can see there that adding an option with "limit=0" will return all records.
  • There's documentation built into the API explorer, but there's also API documentation in the Developer's Guide.
  • One major caveat! drush and export.php don't really handle JSON inputs well - which you need to pass options. Instead, use cv.
  • cv is like drush, but for CiviCRM. This can take arguments similar to export.php but can also get JSON as an input, for instance:
 echo '{"options": {"limit":0}, "first_name": "Juliann"}' | cv api Contact.get --in=json --out=csv 

To use cv with the API explorer for simple commands, just use the recommended cv command. However, if the command includes JSON, use the format above, and grab the exact JSON from the JavaScript example API Explorer generates.

  • Many thanks Jon - I'll try these suggestions and let you know how I get on.
    – Neil
    Jun 29, 2019 at 6:51

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.