Answers.Body: <p>Andrei and Flying answer seems good to me but if i look at civicrm api examples in the core code, you should be able to do this :</p>
  
  <pre><code>$result = civicrm_api3('Contact', 'get', array(   
    'return' =&gt; "id",   
    'filter.group_id' =&gt; array(0 =&gt; 1)
  ));
  </code></pre>
  
  <p>as found in : <a href="https://github.com/civicrm/civicrm-core/blob/master/api/v3/examples/Contact/GroupFilterUsingContactAPI.php" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/blob/master/api/v3/examples/Contact/GroupFilterUsingContactAPI.php</a></p>
  
  <p>EDIT 2019-05-31: the API  seems to have changed. Now it's :</p>
  
  <pre><code>$result = civicrm_api3('Contact', 'get', array(   
    'return' =&gt; "id",   
    'group' =&gt; [
      'IN' =&gt; [0 =&gt; 1]
    ],
  ));
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2015-10-19T20:37:55.953Z
Answers.LastActivityDate: 2019-05-31T18:37:23.243Z
Answers.LastEditDate: 2019-05-31T18:37:23.243Z
Answers.UserDisplayName: samuelsov
Answers.Body: <p>I think you should target the Group entity and chain it with Group Contact like this:</p>
  
  <pre><code>$result = civicrm_api3('Group', 'get', array( 
  'sequential' =&gt; 1,
  'name' =&gt; "Administrators",
  'api.GroupContact.get' =&gt; array('status' =&gt; "Added"),
  ));
  </code></pre>
  
  <p>The GroupContact will return the contact_id</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-19T20:27:21.997Z
Answers.LastActivityDate: 2015-10-19T20:27:21.997Z
Answers.UserDisplayName: Andrei
Answers.Body: <p>You should then use another entity; GroupContact. Remember to add the Status=Added</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-19T23:38:03.657Z
Answers.Text: This works like a charm, thanks!
       
  `$result = civicrm_api3('GroupContact', 'get', array(  
        'sequential' => 1,  
        'return' => "contact_id",  
        'group_id' => "Administrators",  
      )); `
Answers.UserDisplayName: yurg
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-19T20:04:47.900Z
Answers.LastActivityDate: 2015-10-19T20:04:47.900Z
Answers.UserDisplayName: Flying
Body: <p>While trying this request </p>
  
  <pre><code>$result = civicrm_api3('Contact', 'get', array(   
  'return' =&gt; "id",   
  'group' =&gt; "Administrators", ));
  </code></pre>
  
  <p>we've got </p>
  
  <pre><code>{
      "error_code": "no such field",
      "sql": "SELECT contact_a.id as contact_id, contact_a.is_deleted  as `contact_is_deleted`, `civicrm_group_contact-Administrators`.id as group_contact_id, `civicrm_group_contact-Administrators`.status as status  FROM civicrm_contact contact_a  LEFT JOIN civicrm_group_contact `civicrm_group_contact-Administrators` ON (contact_a.id = `civicrm_group_contact-Administrators`.contact_id AND `civicrm_group_contact-Administrators`.status IN (\"Added\"))   LEFT JOIN civicrm_group_contact_cache `civicrm_group_contact_cache_Administrators` ON contact_a.id = `civicrm_group_contact_cache_Administrators`.contact_id   WHERE  ( contact_a.is_deleted = '0' AND ( ( `civicrm_group_contact-Administrators`.group_id IN ( Administrators ) ) OR ( `civicrm_group_contact_cache_Administrators`.group_id IN (\"Administrators\") ) ) )  AND  ( 1 )  AND  ( 1 )   GROUP BY contact_a.id LIMIT 0, 25  [nativecode=1054 ** Unknown column 'Administrators' in 'where clause']",
  </code></pre>
  
  <p>whatever operator ( "=" , "Like", "In" ) is being used. </p>
  
  <p>All we wanted is Contact IDs, which should be passed to another API call. Of course, we can get data by Search in Group in browser and export all values, when read csv file and extract IDs, but it would be much prettier with pure API calls.      </p>
  
Tags: <api><contacts><groups>
Title: API Get Contacts which are members of a certain group
ThreadText: # API Get Contacts which are members of a certain group
  
  (Asked by: username_0 on 2015-10-19)
  
  While trying this request
  
  ```
  $result = civicrm_api3('Contact', 'get', array(   
  'return' => "id",   
  'group' => "Administrators", ));
  
  ```
  
  we've got
  
  ```
  {
      "error_code": "no such field",
      "sql": "SELECT contact_a.id as contact_id, contact_a.is_deleted  as `contact_is_deleted`, `civicrm_group_contact-Administrators`.id as group_contact_id, `civicrm_group_contact-Administrators`.status as status  FROM civicrm_contact contact_a  LEFT JOIN civicrm_group_contact `civicrm_group_contact-Administrators` ON (contact_a.id = `civicrm_group_contact-Administrators`.contact_id AND `civicrm_group_contact-Administrators`.status IN (\"Added\"))   LEFT JOIN civicrm_group_contact_cache `civicrm_group_contact_cache_Administrators` ON contact_a.id = `civicrm_group_contact_cache_Administrators`.contact_id   WHERE  ( contact_a.is_deleted = '0' AND ( ( `civicrm_group_contact-Administrators`.group_id IN ( Administrators ) ) OR ( `civicrm_group_contact_cache_Administrators`.group_id IN (\"Administrators\") ) ) )  AND  ( 1 )  AND  ( 1 )   GROUP BY contact_a.id LIMIT 0, 25  [nativecode=1054 ** Unknown column 'Administrators' in 'where clause']",
  
  ```
  
  whatever operator ( "=" , "Like", "In" ) is being used.
  
  All we wanted is Contact IDs, which should be passed to another API call. Of course, we can get data by Search in Group in browser and export all values, when read csv file and extract IDs, but it would be much prettier with pure API calls.
  
  **Tags:** api, contacts, groups
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_3 on 2015-10-19. Score: 4 | Accepted answer
  
  You should then use another entity; GroupContact. Remember to add the Status=Added
  
  > **Comments:**
  > **username_0**: This works like a charm, thanks!       `$result = civicrm_api3('GroupContact', 'get', array(         'sequential' => 1,         'return' => "contact_id",         'group_id' => "Administrators",       )); `  
  
  ---
  
  ### Answer by username_1 on 2015-10-19. Score: 3
  
  username_2 and username_3 answer seems good to me but if i look at civicrm api examples in the core code, you should be able to do this :
  
  ```
  $result = civicrm_api3('Contact', 'get', array(   
    'return' => "id",   
    'filter.group_id' => array(0 => 1)
  ));
  
  ```
  
  as found in : <https://github.com/civicrm/civicrm-core/blob/master/api/v3/examples/Contact/GroupFilterUsingContactAPI.php>
  
  EDIT 2019-05-31: the API seems to have changed. Now it's :
  
  ```
  $result = civicrm_api3('Contact', 'get', array(   
    'return' => "id",   
    'group' => [
      'IN' => [0 => 1]
    ],
  ));
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2015-10-19. Score: 3
  
  I think you should target the Group entity and chain it with Group Contact like this:
  
  ```
  $result = civicrm_api3('Group', 'get', array( 
  'sequential' => 1,
  'name' => "Administrators",
  'api.GroupContact.get' => array('status' => "Added"),
  ));
  
  ```
  
  The GroupContact will return the contact\_id
  
  
  ---
  
  