Answers.Body: <p>If you want to stay with the API you can filter in php:</p>
  
  <pre><code>$result = civicrm_api3('Contact', 'get', array(
    'sequential' =&gt; 1,
    'return' =&gt; array("id", "external_identifier"),
    'external_identifier' =&gt; array('IS NOT NULL' =&gt; 1),
    'options' =&gt; array('limit' =&gt; 0),
  ));
  $ids = array();
  foreach ($result['values'] as $contact) {
    if ($contact['id'] == $contact['external_identifier']) {
      $ids[] = $contact['id'];
    }
  }
  print_r($ids);
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-10T22:07:42.320Z
Answers.LastActivityDate: 2018-05-10T22:07:42.320Z
Answers.UserDisplayName: Aidan
Answers.Body: <p>Will this possible in API? - I am not sure</p>
  
  <p>But </p>
  
  <p>A simple SQL should be quicker - if you have access to Database </p>
  
  <p><strong>Else:</strong></p>
  
  <p>you can get a list quicker using CiviCRM Report </p>
  
  <p><strong>Reports -> Contact Report -> Constituent Summary</strong> </p>
  
  <p>select column: contact ID and External ID to be displayed </p>
  
  <p>Export into a CSV and then make a compare in csv</p>
  
  <p>I guess this helps !!!!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-10T11:48:40.603Z
Answers.LastActivityDate: 2018-05-10T11:48:40.603Z
Answers.UserDisplayName: Ramesh - ARTECH Consultancy
Answers.Body: <p>If you are familiair with SQL I would use a custom query for that. What exactly do you want to do with the result? </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-10T19:10:53.233Z
Answers.LastActivityDate: 2018-05-10T19:10:53.233Z
Answers.UserDisplayName: Jaap Jansma - CiviCooP
Answers.Body: <p>It's very simple and faster to get the result using sql query. You can try using chain api but i am not if it will filter out the result.</p>
  
  <pre><code>  $params = [
      'api.contact.get' =&gt; ['external_identifier' =&gt; '$value.id'],
      'return' =&gt; 'api.contact.get'
    ];
    $result = civicrm_api3('Contact', 'get', $params);
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-10T19:51:54.347Z
Answers.LastActivityDate: 2018-05-10T19:51:54.347Z
Answers.UserDisplayName: Pradeep Nayak
Answers.Body: <p>It's not directly possible in the manner you indicate.</p>
  
  <p>You would need to get a list of all contact's external IDs then loop through using the API to return contacts who's ID matches their external ID. The direct SQL route or report route given by @Ramesh would be quicker for a one-off task.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-10T17:27:37.027Z
Answers.LastActivityDate: 2018-05-10T19:03:58.720Z
Answers.LastEditDate: 2018-05-10T19:03:58.720Z
Answers.UserDisplayName: HomoTechsual
Body: <p>I want to get all contacts who have "CiviCRM Id = External Id"</p>
  
  <p>This API call doesn't work because, id is expecting a numeric value</p>
  
  <pre><code>$result = civicrm_api3('Contact', 'get', array(
    'sequential' =&gt; 1,
     'id' =&gt; "external_identifier",
  ));
  </code></pre>
  
  <p>Any way to accomplish this using API?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-07-26T09:19:49.527Z
Comments.Text: This basically was a generic question (with a specific example) about if the API is able to use another Entitiy's fields as part of condition, rather than constant values. Looks like is not possible.. maybe with API v4.0 ?!
Comments.UserDisplayName: luciano_s
Tags: <api>
Title: Is it possible to Contact.get where civicrm_id = external_identifier, using API?
ThreadText: # Is it possible to Contact.get where civicrm_id = external_identifier, using API?
  
  (Asked by: username_0 on 2018-05-10)
  
  I want to get all contacts who have "CiviCRM Id = External Id"
  This API call doesn't work because, id is expecting a numeric value
  $result = civicrm_api3('Contact', 'get', array(
    'sequential' => 1,
     'id' => "external_identifier",
  ));
  
  Any way to accomplish this using API?
  
  **Tags:** api
  
  > **Comments:**
  > **username_0**: This basically was a generic question (with a specific example) about if the API is able to use another Entitiy's fields as part of condition, rather than constant values. Looks like is not possible.. maybe with API v4.0 ?!  
  
  ---
  
  ## 5 answers
  
  ### Answer by username_1 on 2018-05-10. Score: 2
  
  If you want to stay with the API you can filter in php:
  $result = civicrm_api3('Contact', 'get', array(
    'sequential' => 1,
    'return' => array("id", "external_identifier"),
    'external_identifier' => array('IS NOT NULL' => 1),
    'options' => array('limit' => 0),
  ));
  $ids = array();
  foreach ($result['values'] as $contact) {
    if ($contact['id'] == $contact['external_identifier']) {
      $ids[] = $contact['id'];
    }
  }
  print_r($ids);
  
  
  ---
  
  ### Answer by username_2 on 2018-05-10. Score: 0
  
  Will this possible in API? - I am not sure
  
  But
  
  A simple SQL should be quicker - if you have access to Database
  
  **Else:**
  
  you can get a list quicker using CiviCRM Report
  
  **Reports -> Contact Report -> Constituent Summary**
  
  select column: contact ID and External ID to be displayed
  
  Export into a CSV and then make a compare in csv
  
  I guess this helps !!!!
  
  
  ---
  
  ### Answer by username_3 on 2018-05-10. Score: 0
  
  If you are familiair with SQL I would use a custom query for that. What exactly do you want to do with the result?
  
  
  ---
  
  ### Answer by username_4 on 2018-05-10. Score: 0
  
  It's very simple and faster to get the result using sql query. You can try using chain api but i am not if it will filter out the result.
    $params = [
      'api.contact.get' => ['external_identifier' => '$value.id'],
      'return' => 'api.contact.get'
    ];
    $result = civicrm_api3('Contact', 'get', $params);
  
  
  ---
  
  ### Answer by username_5 on 2018-05-10. Score: 0
  
  It's not directly possible in the manner you indicate.
  
  You would need to get a list of all contact's external IDs then loop through using the API to return contacts who's ID matches their external ID. The direct SQL route or report route given by @Ramesh would be quicker for a one-off task.
  
  
  ---
  
  