Answers.Body: <p>This is possible in the "trunk" version of CiviCRM, and will be available in CiviCRM 4.7.15, releasing January 4, 2017.  Earlier versions of CiviCRM don't have a StateProvince API.</p>
  
  <p>Using the "Join" feature of the API, you can pull in fields from related tables.  See my screenshot for how I would construct an address pulling in actual state/province names (and/or state abbreviations) as well as country:</p>
  
  <pre><code>    $result = civicrm_api3('Address', 'get', array(
    'sequential' =&gt; 1,
    'return' =&gt; array("street_address", "supplemental_address_1", "supplemental_address_2", "city", "state_province_id.name", "state_province_id.abbreviation", "country_id.name"),
  ));
  </code></pre>
  
  <p><a href="https://i.sstatic.net/NBBu9.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/NBBu9.png" alt="enter image description here"></a></p>
  
  <p>Before 4.7.0, API joins didn't exist - and before 4.7.15 there was no <a href="https://issues.civicrm.org/jira/browse/CRM-19688" rel="nofollow noreferrer">StateProvince API</a>.  So in the past, developers would either implement their own StateProvince API or use a hybrid of API and BAO calls.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-12-20T05:56:42.630Z
Answers.LastActivityDate: 2016-12-20T05:56:42.630Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>When am getting some entity using API, it's returning id reference only not the actual value.</p>
  
  <p><strong>eg:</strong>
  $result = civicrm_api3('Address', 'get', array(
        'sequential' => 1,
        'conatct_id' => 10
      ));
  Output:</p>
  
  <pre><code>enter preformatted text here
  {
     "is_error":0,
     "version":3,
     "count":1,
     "id":6601,
     "values":[{
        "id":"6601",
        "contact_id":"1",
        "location_type_id":"1",
        "is_primary":"1",
        "is_billing":"0",
        "street_address":"#275, xyz",
        "city":"abcd",
        "state_province_id":"9300",
        "postal_code":"560082",
        "country_id":"1101",
        "geo_code_1":"12.7930129",
        "geo_code_2":"77.5051501",
        "manual_geo_code":"0"
     }]
  }
  </code></pre>
  
  <p>In this example, state_province_id,country_id is returned. Is it possible to get state name and country name in the result?</p>
  
  <p>Thanks in advance</p>
  
Tags: <api><addresses>
Title: Get actual value instead of ID in Address API for Country and State/Province
ThreadText: # Get actual value instead of ID in Address API for Country and State/Province
  
  (Asked by: username_0 on 2016-12-20)
  
  When am getting some entity using API, it's returning id reference only not the actual value.
  eg:
  $result = civicrm_api3('Address', 'get', array(
        'sequential' => 1,
        'conatct_id' => 10
      ));
  Output:
  enter preformatted text here
  {
     "is_error":0,
     "version":3,
     "count":1,
     "id":6601,
     "values":[{
        "id":"6601",
        "contact_id":"1",
        "location_type_id":"1",
        "is_primary":"1",
        "is_billing":"0",
        "street_address":"#275, xyz",
        "city":"abcd",
        "state_province_id":"9300",
        "postal_code":"560082",
        "country_id":"1101",
        "geo_code_1":"12.7930129",
        "geo_code_2":"77.5051501",
        "manual_geo_code":"0"
     }]
  }
  
  In this example, state_province_id,country_id is returned. Is it possible to get state name and country name in the result?
  Thanks in advance
  
  **Tags:** api, addresses
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-12-20. Score: 3
  
  This is possible in the "trunk" version of CiviCRM, and will be available in CiviCRM 4.7.15, releasing January 4, 2017.  Earlier versions of CiviCRM don't have a StateProvince API.
  Using the "Join" feature of the API, you can pull in fields from related tables.  See my screenshot for how I would construct an address pulling in actual state/province names (and/or state abbreviations) as well as country:
      $result = civicrm_api3('Address', 'get', array(
    'sequential' => 1,
    'return' => array("street_address", "supplemental_address_1", "supplemental_address_2", "city", "state_province_id.name", "state_province_id.abbreviation", "country_id.name"),
  ));
  
  
  Before 4.7.0, API joins didn't exist - and before 4.7.15 there was no StateProvince API.  So in the past, developers would either implement their own StateProvince API or use a hybrid of API and BAO calls.
  
  
  ---
  
  