Answers.Body: <p>As per comments you can use <code>cv ev</code> instead of <code>cv api</code> to avoid having to figure out the cli syntax for limit.</p>
  <p><code>cv ev '$r = civicrm_api3(&quot;Contact&quot;, &quot;get&quot;, [&quot;options&quot; =&gt; [&quot;limit&quot; =&gt; 0]]); $fpr = fopen(&quot;./res.csv&quot;, &quot;w&quot;); foreach ($r[&quot;values&quot;] as $rk=&gt;$rv) {fputcsv($fpr, $rv);} fclose($fpr); echo &quot;done&quot;;'</code></p>
  <p>It also occurs to me that core's export.php could probably be updated to default to <code>&quot;options&quot; =&gt; [&quot;limit&quot; =&gt; 0]</code>. Why would anyone ever not want that? At <a href="https://github.com/civicrm/civicrm-core/blob/888e65374f208e6d79ff8adc68d0adfa05575277/bin/cli.class.php#L53" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/blob/888e65374f208e6d79ff8adc68d0adfa05575277/bin/cli.class.php#L53</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-07T10:44:28.293Z
Answers.Text: ... or preferably APIv4
Answers.UserDisplayName: Aidan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-06T20:11:29.710Z
Answers.LastActivityDate: 2024-02-06T20:11:29.710Z
Answers.UserDisplayName: Demerit
Body: <p>Both methods seems to have a restriction on a number of contacts processed (25?)</p>
  <ul>
  <li>cv api Contact.get options={&quot;limit&quot;:0}</li>
  <li>php export.php  -e Contact &gt; ~/ex.csv</li>
  </ul>
  <p>I remember doing some php equilibristics back in the years to get the result and wondering if, maybe, there is hidden parameter ( like &quot;--all&quot; or something ) to get ALL contacts out from the db in 2024?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-02-06T12:30:00.833Z
Comments.Text: When using the api you need to add "limit=0" in order to get all records - otherwise you only get the first 25
Comments.UserDisplayName: Fabian
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-02-06T16:06:03.260Z
Comments.Text: @Fabian Right, I did exactly this in the "cv api Contact.get options={"limit":0}" call - no luck, hence the question.
Comments.UserDisplayName: yurg
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-02-06T16:15:04.703Z
Comments.Text: I don't know the right syntax for the cli options, but you could try using `cv ev` instead of `cv api` so that you don't have to fight with it, e.g. `cv ev '$r = civicrm_api3("Contact", "get", ["options" => ["limit" => 0]]); print_r($r["values"]);'` (You can play with looping and fputcsv() on the values if you want a csv.)
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-02-06T19:30:31.743Z
Comments.Text: @Demerit Thank you, the comment deserves to be the answer. The full code would be something like cv ev '$r = civicrm_api3("Contact", "get", ["options" => ["limit" => 0]]); $fpr = fopen("./res.csv", "w"); foreach ($r["values"] as $rk=>$rv) {fputcsv($fpr, $rv);} fclose($fpr); print_r("done");'
Comments.UserDisplayName: yurg
Tags: <import>
Title: How to export a large contacts number via cv or bin/csv/export.php
ThreadText: # How to export a large contacts number via cv or bin/csv/export.php
  
  (Asked by: username_0 on 2024-02-05)
  
  Both methods seems to have a restriction on a number of contacts processed (25?)
  
  * cv api Contact.get options={"limit":0}
  * php export.php -e Contact > ~/ex.csv
  
  I remember doing some php equilibristics back in the years to get the result and wondering if, maybe, there is hidden parameter ( like "--all" or something ) to get ALL contacts out from the db in 2024?
  
  **Tags:** import
  
  > **Comments:**
  > **username_1**: When using the api you need to add "limit=0" in order to get all records - otherwise you only get the first 25  
  > **username_0**: @username_1 Right, I did exactly this in the "cv api Contact.get options={"limit":0}" call - no luck, hence the question.  
  > **username_2**: I don't know the right syntax for the cli options, but you could try using `cv ev` instead of `cv api` so that you don't have to fight with it, e.g. `cv ev '$r = civicrm_api3("Contact", "get", ["options" => ["limit" => 0]]); print_r($r["values"]);'` (You can play with looping and fputcsv() on the values if you want a csv.)  
  > **username_0**: @username_2 Thank you, the comment deserves to be the answer. The full code would be something like cv ev '$r = civicrm_api3("Contact", "get", ["options" => ["limit" => 0]]); $fpr = fopen("./res.csv", "w"); foreach ($r["values"] as $rk=>$rv) {fputcsv($fpr, $rv);} fclose($fpr); print_r("done");'  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2024-02-06. Score: 1 | Accepted answer
  
  As per comments you can use `cv ev` instead of `cv api` to avoid having to figure out the cli syntax for limit.
  
  `cv ev '$r = civicrm_api3("Contact", "get", ["options" => ["limit" => 0]]); $fpr = fopen("./res.csv", "w"); foreach ($r["values"] as $rk=>$rv) {fputcsv($fpr, $rv);} fclose($fpr); echo "done";'`
  
  It also occurs to me that core's export.php could probably be updated to default to `"options" => ["limit" => 0]`. Why would anyone ever not want that? At <https://github.com/civicrm/civicrm-core/blob/888e65374f208e6d79ff8adc68d0adfa05575277/bin/cli.class.php#L53>
  
  > **Comments:**
  > **username_3**: ... or preferably APIv4  
  
  ---
  
  