Answers.Body: <p>You can use the 'group' filter on the Contact api to get members of parent groups.  </p>
  
  <pre><code>$result = civicrm_api3('Contact', 'get', array(
    'sequential' =&gt; 1,
    'group' =&gt; XX,
    'options' =&gt; array('limit' =&gt; 0),
  ));
  </code></pre>
  
  <p>where XX is the id of the parent group (A).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-20T17:50:25.980Z
Answers.Text: Unfortunately, that causes the error Uncaught CiviCRM_API3_Exception: [no such field: DB Error: no such field.
Answers.UserDisplayName: DMCoding
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-20T23:12:43.380Z
Answers.Text: Are you using the id or the name?  It's working for me with the numeric id, but the name produces an error.
Answers.UserDisplayName: Aidan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-20T15:20:14.173Z
Answers.LastActivityDate: 2017-10-20T15:20:14.173Z
Answers.UserDisplayName: Aidan
Answers.Body: <p>The query worked fine for me, i am using name of group instead of id. Example:</p>
  
  <pre><code>$result = civicrm_api3('Contact', 'get', array(
    'sequential' =&gt; 1,
    'group' =&gt; "Advisory Board",
    'options' =&gt; array('limit' =&gt; 0),
  ));
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-18T19:35:31.477Z
Answers.LastActivityDate: 2018-01-18T19:35:31.477Z
Answers.UserDisplayName: Hassan Farooq
Body: <p>I have a child groups C and B, each with 20 different contacts in them. Both child groups are in parent group A. I need to find all contacts in all children of A since C and B might be removed later or new children added to A. But A will not change. However, Group A is not <em>itself</em> populated. As a result, the CiviCRM API returns 0 results. Is there handy API method which will help me out?</p>
  
  <p>API Command:</p>
  
  <pre><code> $result = civicrm_api3('GroupContact', 'get', array(
    'sequential' =&gt; 1,
    'group_id' =&gt; "Donors_74",
  ));
  </code></pre>
  
  <p>Actual results from the API explorer:</p>
  
  <pre><code>{
  "is_error": 0,
  "version": 3,
  "count": 0,
  "values": [
  
      ]
  }
  </code></pre>
  
  <p>Expected result: 1676</p>
  
  <p><a href="https://i.sstatic.net/bAwdx.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/bAwdx.png" alt="enter image description here"></a></p>
  
  <p>We are using CiviCRM 4.7.25.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-20T15:09:28.610Z
Comments.Text: What API command are you running that is returning 0 results?
Comments.UserDisplayName: Aidan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-20T15:17:35.457Z
Comments.Text: I have updated my question with the API command
Comments.UserDisplayName: DMCoding
Tags: <contacts><api><groups>
Title: How to get contacts in children of a parent group using the API
ThreadText: # How to get contacts in children of a parent group using the API
  
  (Asked by: username_0 on 2017-10-20)
  
  I have a child groups C and B, each with 20 different contacts in them. Both child groups are in parent group A. I need to find all contacts in all children of A since C and B might be removed later or new children added to A. But A will not change. However, Group A is not *itself* populated. As a result, the CiviCRM API returns 0 results. Is there handy API method which will help me out?
  
  API Command:
  
  ```
   $result = civicrm_api3('GroupContact', 'get', array(
    'sequential' => 1,
    'group_id' => "Donors_74",
  ));
  
  ```
  
  Actual results from the API explorer:
  
  ```
  {
  "is_error": 0,
  "version": 3,
  "count": 0,
  "values": [
  
      ]
  }
  
  ```
  
  Expected result: 1676
  
  [![enter image description here](https://i.sstatic.net/bAwdx.png)](https://i.sstatic.net/bAwdx.png)
  
  We are using CiviCRM 4.7.25.
  
  **Tags:** contacts, api, groups
  
  > **Comments:**
  > **username_1**: What API command are you running that is returning 0 results?  
  > **username_0**: I have updated my question with the API command  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2017-10-20. Score: 1
  
  You can use the 'group' filter on the Contact api to get members of parent groups.
  
  ```
  $result = civicrm_api3('Contact', 'get', array(
    'sequential' => 1,
    'group' => XX,
    'options' => array('limit' => 0),
  ));
  
  ```
  
  where XX is the id of the parent group (A).
  
  > **Comments:**
  > **username_0**: Unfortunately, that causes the error Uncaught CiviCRM_API3_Exception: [no such field: DB Error: no such field.  
  > **username_1**: Are you using the id or the name?  It's working for me with the numeric id, but the name produces an error.  
  
  ---
  
  ### Answer by username_2 on 2018-01-18. Score: 0
  
  The query worked fine for me, i am using name of group instead of id. Example:
  
  ```
  $result = civicrm_api3('Contact', 'get', array(
    'sequential' => 1,
    'group' => "Advisory Board",
    'options' => array('limit' => 0),
  ));
  
  ```
  
  
  ---
  
  