Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Region API

Allows you to export the list of regions from Magento

Module: Mage_Directory

Resource: directory_region

Aliases:

  • region
Method:
  • directory_region.list (SOAP V1)
  • directoryRegionList (SOAP V2)

Retrieve the list of regions in the specified country.

Aliases:

  • region.list

Arguments:

TypeNameDescription
stringsessionIdSession ID
stringcountryCountry code in ISO2 or ISO3

Returns:

TypeNameDescription
arraydirectoryRegionEntityArrayAn array of directoryRegionEntity

The directoryRegionEntity content is as follows:

TypeNameDescription
stringregion_idID of the region
stringcodeRegion code
stringnameName of the region

Faults:

Fault CodeFault Message
101Country not exists.

Examples

Request Example SOAP V1
$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');
$regions = $proxy->call($sessionId, 'region.list', 'US');

var_dump($regions); // Region list for USA.
Request Example SOAP V2
$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl'); 
$sessionId = $proxy->login('apiUser', 'apiKey'); 

$result = $proxy->directoryRegionList($sessionId,'US');
var_dump($result);
Request Example SOAP V2 (WS-I Compliance Mode)
$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl'); 

$sessionId = $proxy->login((object)array('username' => 'apiUser', 'apiKey' => 'apiKey')); 
 
$result = $proxy->directoryRegionList((object)array('sessionId' => $sessionId->result, 'country' => 'US'));   
var_dump($result->result);
Response Example SOAP V1
array
  0 =>
    array
      'region_id' => string '1' (length=1)
      'code' => string 'AL' (length=2)
      'name' => string 'Alabama' (length=7)
  1 =>
    array
      'region_id' => string '2' (length=1)
      'code' => string 'AK' (length=2)
      'name' => string 'Alaska' (length=6)
  2 =>
    array
      'region_id' => string '3' (length=1)
      'code' => string 'AS' (length=2)
      'name' => string 'American Samoa' (length=14)
  3 =>
    array
      'region_id' => string '4' (length=1)
      'code' => string 'AZ' (length=2)
      'name' => string 'Arizona' (length=7)