Answers.Body: <p>This is going to require a second api call, first to retrieve a list of relationships for the 2nd contact, use a php loop to turn the list of relations into an array, and then you can add that to the original api call like</p>
  
  <p><code>'id' =&gt; array('IN', $related_contact_ids)</code></p>
  
  <p>PS. I'm not sure if the contact api3 supports this syntax.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-14T20:27:38.877Z
Answers.LastActivityDate: 2016-09-14T20:27:38.877Z
Answers.UserDisplayName: Coleman
Body: <p>Is there a way to search by relationship in the Contact.get API call?</p>
  
  <p>Eg: give me all the contacts that are individuals, in group 9 and have a relationship type 8 (optionally specifying direction and/or the other contact) ?</p>
  
  <p>I'm modifying existing code that builds a variety of filters into a Contact.get call and I want to add relationships to that.</p>
  
  <p>The new join feature in 4.7 looks hopeful except that it is not advertised for Contacts in the API explorer.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-09-14T20:21:17.533Z
Comments.Text: Correct, the Contact api unfortunately uses a legacy query builder that prevents it from supporting joins.
Comments.UserDisplayName: Coleman
Tags: <api><relationships>
Title: How can I search by relationship in Contact.get?
ThreadText: # How can I search by relationship in Contact.get?
  
  (Asked by: username_0 on 2016-09-12)
  
  Is there a way to search by relationship in the Contact.get API call?
  
  Eg: give me all the contacts that are individuals, in group 9 and have a relationship type 8 (optionally specifying direction and/or the other contact) ?
  
  I'm modifying existing code that builds a variety of filters into a Contact.get call and I want to add relationships to that.
  
  The new join feature in 4.7 looks hopeful except that it is not advertised for Contacts in the API explorer.
  
  **Tags:** api, relationships
  
  > **Comments:**
  > **username_1**: Correct, the Contact api unfortunately uses a legacy query builder that prevents it from supporting joins.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-09-14. Score: 1 | Accepted answer
  
  This is going to require a second api call, first to retrieve a list of relationships for the 2nd contact, use a php loop to turn the list of relations into an array, and then you can add that to the original api call like
  
  `'id' => array('IN', $related_contact_ids)`
  
  PS. I'm not sure if the contact api3 supports this syntax.
  
  
  ---
  
  