This is an old revision of the document!
SOAP adapter is default adapter for webservices. If you want to connect to Magento SOAP webservices you should load WSDL from this link (http://youmagentohost/api/?wsdl or http://youmagentohost/api/soap/?wsdl) in your SoapClient
As of v1.3 you may also use http://yourmagentohost/api/v2_soap?wsdl=1 which has been added to improve compatbility with Java and .NET.
Example:
$client = new SoapClient('http://youmagentohost/api/?wsdl');
// If soap isn't default use this link instead
// http://youmagentohost/api/soap/?wsdl
// If somestuff requires api authentification,
// we should get 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(
array('somestuff.method'),
array('somestuff.method', 'arg1'),
array('somestuff.method', array('arg1', 'arg2'))
));
// If you don't need the session anymore
$client->endSession($session);
Xml rpc is available at http://youmagentohost/api/xmlrpc/
Example:
$client = new Zend_XmlRpc_Client('http://youmagentohost/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,
array(
array('somestuff.method', 'arg1'),
array('somestuff.method', array('arg1', 'arg2')),
array('somestuff.method')
)
));
// If you don't need the session anymore
$client->call('endSession', array($session));
| Method | Description | Return Value |
| startSession() | start API session and return sessionId | string |
| endSession(sessionId) | end API session | boolean |
| login(apiUser, apiKey) | start API session, return sessionId and authorize apiUser | string |
| call(sessionId, resourcePath,array arguments) | call api resource that is allowed in current session (if no session is specified, you can call only resources that are not protected by ACL) | mixed |
| multiCall(sessionId, array calls,array options) | call api resource’s methods that are allowed for current session (if no session is specified, you can call only resources that are not protected by ACL). If “break” option is specified, multicall breaks on first error | array |
| resources(sessionId) | return list of available API resources and methods allowed for current session. | array |
| globalFaults(sessionId) | return list of fault messages and their codes, that do not depend on any resource. | array |
| resourceFaults(sessionId, resourceName) | return list of the specified resource fault messages, if this resource is allowed in current session. | array |
| Fault Code | Fault Message |
| 0 | Unknown Error |
| 1 | Internal Error. Please see log for details. |
| 2 | Access denied. |
| 3 | Invalid api path. |
| 4 | Resource path is not callable. |
The list of available Magento Core API calls can be found here
The tutorial on how to create custom API for your own modules or to add more API calls in core modules is available here.