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
      "street_address":"#275, xyz",

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

1 Answer 1


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"),

enter image description here

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.