How do I get more than 25 records from the API?
To return more than 25 results you need to add options.limit to your api call:

$params = array(
  'version' =&gt; 3,
  'sequential' =&gt; 1,
  'membership_type' =&gt; 1,
    'options' =&gt; array(
    'limit' =&gt; 100,
   ),
);
$result = civicrm_api('Membership', 'get', $params);




For the second part, we want to be able to retrieve say 5,000 records. We can't really set rowCount to 5,000 because depending on the size of data, we run the risk of timing out.

The solution here is to page the results using a parameter 'options.offset':

$params = array(
  'version' =&gt; 3,
  'sequential' =&gt; 1,
  'membership_type' =&gt; 1,
  'options' =&gt; array(
    'limit' =&gt; 100,
    'offset' =&gt; 100 // offset value is equal to the number of results to skip
  ),
);


For this to work, we decide on what our ideal page size is let's say 100. We set options.limit to 100, and then we increment offset by our page size (100) on each call, until we no longer get results.

How do we know when we're done? Check the value of count in the returned result. When the returned count is less than the page size, stop.

  $memberships = array();
  // Initialise our pagesize and offset
  $page_size = 100;
  $offset = 0;
  // Start out loop
  do {
    // Call the api
    $results = civicrm_api(
      'Membership',
      'get',
      array(
        'version'         =&gt; 3,
        'sequential'      =&gt; 1,
        'membership_type' =&gt; $membership_type,
        'options'         =&gt; array(
          'limit'  =&gt; $page_size,
          'offset' =&gt; $offset
        )
      )
    );

    // do something with the results if we didn't error
    if ($results['is_error'] == 0) {
      foreach ($results['values'] as $value) {
        $memberships[] = $value;
      }
    }

    // Increment the offset by the page size
    $offset = $offset + $page_size;

  } while ($results['count'] &gt;= $page_size); // Check if we still need to fetch results