How to retrieve all contacts belonging to a smart group
As of version 4.6, you can use the API Explorer (top menu: Support > Developer > API Explorer) to get code, examples and docs.  You can use the entities and actions to find the right combination to get the info you're looking for. (You can use any number of actions, but it is a live API tool so if you e.g. update an entity, it will change values in the database).

In this case, go to the Explorer then click the tab for Examples.  Choose the entity: Contact and then example: GroupFilterUsingContactAPI.  That generates this code (taken from the Drupal Demo at dmaster.demo.civicrm.org, but the API explorer is not CMS dependent): 

&lt;?php
/**
 * Test Generated example demonstrating the Contact.get API.
 *
 * Get all from group and display contacts.
 *
 * @return array
 *   API result array
 */
function contact_get_example() {
  $params = array(
    'filter.group_id' =&gt; array(
      '0' =&gt; 1,
      '1' =&gt; 26,
    ),
    'contact_type' =&gt; 'Individual',
  );

  try{
    $result = civicrm_api3('Contact', 'get', $params);
  }
  catch (CiviCRM_API3_Exception $e) {
    // Handle error here.
    $errorMessage = $e-&gt;getMessage();
    $errorCode = $e-&gt;getErrorCode();
    $errorData = $e-&gt;getExtraParams();
    return array(
      'error' =&gt; $errorMessage,
      'error_code' =&gt; $errorCode,
      'error_data' =&gt; $errorData,
    );
  }

  return $result;
}

/**
 * Function returns array of result expected from previous function.
 *
 * @return array
 *   API result array
 */
function contact_get_expectedresult() {

  $expectedResult = array(
    'is_error' =&gt; 0,
    'version' =&gt; 3,
    'count' =&gt; 1,
    'id' =&gt; 1,
    'values' =&gt; array(
      '1' =&gt; array(
        'contact_id' =&gt; '1',
        'contact_type' =&gt; 'Individual',
        'contact_sub_type' =&gt; '',
        'sort_name' =&gt; 'man2@yahoo.com',
        'display_name' =&gt; 'man2@yahoo.com',
        'do_not_email' =&gt; 0,
        'do_not_phone' =&gt; 0,
        'do_not_mail' =&gt; 0,
        'do_not_sms' =&gt; 0,
        'do_not_trade' =&gt; 0,
        'is_opt_out' =&gt; 0,
        'legal_identifier' =&gt; '',
        'external_identifier' =&gt; '',
        'nick_name' =&gt; '',
        'legal_name' =&gt; '',
        'image_URL' =&gt; '',
        'preferred_communication_method' =&gt; '',
        'preferred_language' =&gt; 'en_US',
        'preferred_mail_format' =&gt; 'Both',
        'first_name' =&gt; '',
        'middle_name' =&gt; '',
        'last_name' =&gt; '',
        'prefix_id' =&gt; '',
        'suffix_id' =&gt; '',
        'formal_title' =&gt; '',
        'communication_style_id' =&gt; '',
        'job_title' =&gt; '',
        'gender_id' =&gt; '',
        'birth_date' =&gt; '',
        'is_deceased' =&gt; 0,
        'deceased_date' =&gt; '',
        'household_name' =&gt; '',
        'organization_name' =&gt; '',
        'sic_code' =&gt; '',
        'contact_is_deleted' =&gt; 0,
        'current_employer' =&gt; '',
        'address_id' =&gt; '2',
        'street_address' =&gt; '1 my road',
        'supplemental_address_1' =&gt; '',
        'supplemental_address_2' =&gt; '',
        'city' =&gt; '',
        'postal_code_suffix' =&gt; '',
        'postal_code' =&gt; '',
        'geo_code_1' =&gt; '',
        'geo_code_2' =&gt; '',
        'state_province_id' =&gt; '',
        'country_id' =&gt; '',
        'phone_id' =&gt; '',
        'phone_type_id' =&gt; '',
        'phone' =&gt; '',
        'email_id' =&gt; '1',
        'email' =&gt; 'man2@yahoo.com',
        'on_hold' =&gt; 0,
        'im_id' =&gt; '',
        'provider_id' =&gt; '',
        'im' =&gt; '',
        'worldregion_id' =&gt; '',
        'world_region' =&gt; '',
        'individual_prefix' =&gt; '',
        'individual_suffix' =&gt; '',
        'communication_style' =&gt; '',
        'gender' =&gt; '',
        'state_province_name' =&gt; '',
        'state_province' =&gt; '',
        'country' =&gt; '',
        'id' =&gt; '1',
      ),
    ),
  );

  return $expectedResult;
}

/*
* This example has been generated from the API test suite.
* The test that created it is called "testGetGroupIDFromContact"
* and can be found at:
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
*
* You can see the outcome of the API tests at
* https://test.civicrm.org/job/CiviCRM-master-git/
*
* To Learn about the API read
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
*
* Browse the api on your own site with the api explorer
* http://MYSITE.ORG/path/to/civicrm/api
*
* Read more about testing here
* http://wiki.civicrm.org/confluence/display/CRM/Testing
*
* API Standards documentation:
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
*/