Answers.Body: <p>Normally you could handle this with an <a href="https://docs.civicrm.org/dev/en/master/api/joins/" rel="nofollow noreferrer">API Join</a> rather than an <a href="https://docs.civicrm.org/dev/en/master/api/chaining/" rel="nofollow noreferrer">API Chain</a> but unfortunately the Participant API is one of the <a href="https://civicrm.stackexchange.com/questions/17928/under-what-circumstances-is-api-joining-available">four quirky entities</a> that don't support this.</p>
  
  <p><a href="https://github.com/civicrm/api4/" rel="nofollow noreferrer">APIv4</a> is under heavy development right now, and one of the primary goals is to standardize these four entities to eliminate this limitation of APIv3.  You may want to test APIv4 to see if it meets your needs yet.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-27T17:29:32.510Z
Answers.LastActivityDate: 2017-07-27T17:29:32.510Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>I am trying to use api3 to get all participants to an event of a certain type. In SQL I would use an inner join for this, using api chaining I do:</p>
  
  <pre><code>  $result = civicrm_api3('Participant', 'get', array(
    'sequential' =&gt; 1,
    'api.Event.get' =&gt; array('event_type_id' =&gt; $type_id),
  ));
  </code></pre>
  
  <p>However this results in all event participants, to every type of event, being returned. The ones who haven't participated in an event of the type get no events tacked to them. Is there a way in the API to filter these participants out?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-27T14:15:37.730Z
Comments.Text: Are you trying to get all participants of 1 event, or all participants for any event of a certain type?
Comments.UserDisplayName: ErikH - CiviCooP
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-27T14:16:23.610Z
Comments.Text: all participants for events of a certain type
Comments.UserDisplayName: joost
Tags: <api>
Title: inner join using api3 chaining
ThreadText: # inner join using api3 chaining
  
  (Asked by: username_0 on 2017-07-27)
  
  I am trying to use api3 to get all participants to an event of a certain type. In SQL I would use an inner join for this, using api chaining I do:
    $result = civicrm_api3('Participant', 'get', array(
    'sequential' => 1,
    'api.Event.get' => array('event_type_id' => $type_id),
  ));
  
  However this results in all event participants, to every type of event, being returned. The ones who haven't participated in an event of the type get no events tacked to them. Is there a way in the API to filter these participants out?
  
  **Tags:** api
  
  > **Comments:**
  > **username_1**: Are you trying to get all participants of 1 event, or all participants for any event of a certain type?  
  > **username_0**: all participants for events of a certain type  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-07-27. Score: 1 | Accepted answer
  
  Normally you could handle this with an [API Join](https://docs.civicrm.org/dev/en/master/api/joins/) rather than an [API Chain](https://docs.civicrm.org/dev/en/master/api/chaining/) but unfortunately the Participant API is one of the [four quirky entities](https://civicrm.stackexchange.com/questions/17928/under-what-circumstances-is-api-joining-available) that don't support this.
  
  [APIv4](https://github.com/civicrm/api4/) is under heavy development right now, and one of the primary goals is to standardize these four entities to eliminate this limitation of APIv3. You may want to test APIv4 to see if it meets your needs yet.
  
  
  ---
  
  