Magento API Usage

hungryhorsecabinSoftware and s/w Development

Dec 14, 2013 (3 years and 7 months ago)

112 views

Magento
API

Lindy Kao
Technical Manager


Gives you ability to manage customers, categories, products,
sales and checkout process


When to use
Magento
API?


You want to integrate with third party application

Magento
API


Why use
Magento
API?


More stable than underlying code


Less code implementation


Tons of examples and documentation around API
Supported  Types  in  
Magento




XML-­‐RPC  


SOAP  
 


REST:  released  in  the  latest  CE  1.7  
67%
33%
Magento API Usage
SOAP
XML-RPC



Remote Procedure Call protocol


Use XML to encode its call


Operates over HTTP


Magento
XML-RPC entry point


http://youmagentohost/api/xmlrpc/



Example Code:
XML-RPC



Simple Object Access Protocol


Accessible through WSDL


More advanced than XML-RPC


Magento
SOAP


Default Protocol


Entry point to interact


http://magento.apia/api/?wsdl



http://mymagentohost/api/soap/?wsdl



2 Version of SOAP: v1 and v2

SOAP



Methods


V1 use methods
call
and
multiCall



Example:
$result = $client->call($
sessionId
, '
sales_order.list
', $
params
);



V2 use separate methods for each action


Example:

$result = $client->
salesOrderList
($
sessionId
, $
params
);



Customizing API:


V1 won’t involve changing WSDL


V2 involve changing to WSDL via wsdl.xml



WS-I compliance


Supported in V2


Easily auto generate clients classes in JAVA or .NET

Magento
SOAP V1 and V2
65%
35%
Magento SOAP API Usage
SOAP V2
SOAP V1



Representational State Transfer


Operates over HTTP utilizing PUT, GET, POST and
DELETE operators


Data exchange in XML or JSON


Magento
REST API


RESTful
API


Better Performance


Use 3 legged
OAuth
1.0a protocol


REF number 5849


OAuth
use token mechanism and users do not
need to reveal their credentials

REST


Simple  Products  


AcAon:  Create/Retrieve/Update/Delete  


URI:  
http://magentohost/api/rest/products
 


Inventories  


AcAon:  Update/Retrieve    


URI:  
http://magentohost/api/rest/stockitems
 


Sales  Orders  


AcAon:  Retrieve  


URI:  
http://magentohost/api/rest/orders
 


Customers  


AcAon:  Create/Retrieve/Update/Delete  


URI:  
http://magentohost/api/rest/customers
 

Supported functionalities in
Magento
REST
Future  plans  for  API




Additional functional coverage for REST and SOAP/XML-
RPC


Shopping cart price rule (coupon) management


Creates a complete configurable product


Etc



Improved Documentation


Add SOAP v2 example code


REST API documentation


Performance


Identify performance bottlenecks


Add load testing in the API development life cycle


Testing


Unit and Integration testing
Demo




Create  a  simple  product  using  
soapUI
 


Create  a  customer  address  as  a  Customer  user  using  REST  Client  
 


Retrieve  product  lisAng  as  a  Guest  using  REST  Client  
Questions,
Suggestions,
Feedbacks