Magento API Introduction

The Magento SOAP v1 API provides you with the ability to manage your eCommerce stores by providing calls for working with resources such as customers, categories, products, and sales orders. It also allows you to manage shopping carts and inventory.

A SOAP v2 API version has been available since Magento 1.3, and a WS-I compliant version has been available since Magento 1.6.

Supported Types

The Magento API supports SOAP and XML-RPC, where SOAP is the default protocol.


To connect to Magento SOAP web services, load the WSDL into your SOAP client from either of these URLs:


where magentohost is the domain for your Magento host.

As of v1.3, you may also use the following URL to access the Magento API v2, which has been added to improve compatibility with Java and .NET:

The following PHP example shows how to make SOAP calls to the Magento API v1:

PHP Code:
$client = new SoapClient('http://magentohost/soap/api/?wsdl');

// If somestuff requires api authentification,
// then get a session token
$session $client->login('apiUser''apiKey');

$result $client->call($session'somestuff.method');
$result $client->call($session'somestuff.method''arg1');
$result $client->call($session'somestuff.method', array('arg1''arg2''arg3'));
$result $client->multiCall($session, array(
'somestuff.method', array('arg1''arg2'))

// If you don't need the session anymore


To use XML-RPC, load the following URL into your XML-RPC client:

where magentohost is the domain for your Magento host.

The following PHP example shows how to make XML-RPC calls:

PHP Code:
$client = new Zend_XmlRpc_Client('http://magentohost/api/xmlrpc/');

// If somestuff requires api authentification,
// we should get session token
$session $client->call('login', array('apiUser''apiKey'));

$client->call('call', array($session'somestuff.method', array('arg1''arg2''arg3')));
$client->call('call', array($session'somestuff.method''arg1'));
$client->call('call', array($session'somestuff.method'));
$client->call('multiCall', array($session,
'somestuff.method', array('arg1''arg2')),

// If you don't need the session anymore
$client->call('endSession', array($session)); 
The XML-RPC only supports the version 1 of the Magento API.

API Methods

The following table contains the API methods that can be called from your SOAP or XML-RPC client on the Magento v1 API.

Name:  magento api tutorials for beginners.png
Views: 351
Size:  17.4 KB

Note: For call and multiCall, if no session is specified, you can call only resources that are not protected by ACL.

Note: For multiCall, if the “break” option is specified, multiCall breaks on first error.

The Magento SOAP API v2 does not support the call() and multiCall() methods, and instead provides a separate method for each API resource.

Global API Faults

The following table contains fault codes that apply to all SOAP/XML-RPC API calls.

Name:  magento api tutorials for beginners 2.png
Views: 354
Size:  4.6 KB

SOAP API Version v2

Since Magento 1.3, version v2 of the SOAP API has also been available. The main difference between v1 and v2 is that instead of using methods call and multiCall, it has separate methods for each action.

For example, consider the following PHP code using SOAP v1.

PHP Code:
$params = array(array(
$result $client->call($sessionId'sales_order.list'$params); 
With SOAP v2, the following code would be equivalent.

PHP Code:
$params = array('filter' => array(
'key' => 'status''value' => 'pending'),
'key' => 'customer_is_guest''value' => '1')
$result $client->salesOrderList($sessionId$params); 
Note that the WSDL for SOAP v1 and SOAP v2 are different. Note that in SOAP v1, customizing the API did not involve changing the WSDL. In SOAP v2, changes to the WSDL are required.

You can configure the SOAP v2 API to be WS-I compliant in the system configuration menu. To do this, set Services > Magento Core API > WS-I Compliance to Yes.

Note that the WSDL for the SOAP v2 API is different when in WS-I compliant mode.

Using the WS-I compliant SOAP v2 API WSDL, it is easy to automatically generate client classes for Java, .NET, and other languages using standard libraries.

Source: Magento Official

View more threads in the same category: