Call-back icon  Sales: Call 800.374.8146 (N America)|757.278.0920 (International)

Magento

Open Source eCommerce Evolved

Introduction

Last modified by Ruslan Voitenko on Fri, September 5, 2008 12:41
Source|Old Revisions  

Supported types

SOAP

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

Example:

  1. $client = new SoapClient('http://youmagentohost/api/?wsdl');
  2. // If soap isn't default use this link instead
  3. // http://youmagentohost/api/soap/?wsdl
  4.  
  5. // If somestuff requires api authentification,
  6. // we should get session token
  7. $session = $client->login('apiUser', 'apiKey');
  8.  
  9. $result = $client->call($session, 'somestuff.method');
  10. $result = $client->call($session, 'somestuff.method', 'arg1');
  11. $result = $client->call($session, 'somestuff.method', array('arg1', 'arg2', 'arg3'));
  12. $result = $client->multiCall($session, array(
  13.      array('somestuff.method'),
  14.      array('somestuff.method', 'arg1'),
  15.      array('somestuff.method', array('arg1', 'arg2'))
  16. ));
  17.  
  18.  
  19. // If you don't need the session anymore
  20. $client->endSession($session);

XML-RPC

Xml rpc is available at http://youmagentohost/api/xmlrpc/

Example:

  1. $client = new Zend_XmlRpc_Client('http://youmagentohost/api/xmlrpc/');
  2.  
  3. // If somestuff requires api authentification,
  4. // we should get session token
  5. $session = $client->call('login', array('apiUser', 'apiKey'));
  6.  
  7. $client->call('call', array($session, 'somestuff.method', array('arg1', 'arg2', 'arg3')));
  8. $client->call('call', array($session, 'somestuff.method', 'arg1'));
  9. $client->call('call', array($session, 'somestuff.method'));
  10. $client->call('multiCall', array($session,
  11.      array(
  12.         array('somestuff.method', 'arg1'),
  13.         array('somestuff.method', array('arg1', 'arg2')),
  14.         array('somestuff.method')
  15.      )
  16. ));
  17.  
  18. // If you don't need the session anymore
  19. $client->call('endSession', array($session));

Basic API methods

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) return list of the resource fault messages, if this resource is allowed in current session. array

Global API Faults

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.

Magento Core API

The list of available Magento Core API calls can be found here

Create your own API

The tutorial on how to create custom API for your own modules or to add more API calls in core modules is available here.




 

Popular Wiki Tags  |  View all

 observer   model   clienti magazin   pdf   video   image   upload   CRM   vtiger   diagram   schema   CGI   registration   pages   attribute 

Professional Services from the Magento Team

Professional Installation from the Magento Team

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs
Sales: Call 800.374.8146 (North America) 757.278.0920 (International)
© Copyright 2008 Varien. Magento is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
33691 users|405 users currently online|74671 forum posts