Hello
Everyone!
Ratnesh Kumar
Building mobile apps for Android & iOS devices.
(Mobikul Department)
Story of an
UNSUNG HERO
In this era of technology, we all are
connected around the world from
desktop to mobile devices to
laptops to browser.
But how does this happens?
How does data reach from one
device to another?
How do different devices interact
with each other ?
Behind all this, there is a hero that is
API.
Application
Programming
Interface
(API)
What is an API?
Api is simply exposing business
capabilities (web services) over
the internet.
OR
API consists of a set of rules
describing how one application
can interact with another, and the
mechanisms that allow such
interaction to happen.
XYZ Restaurant
**Logos and Trademarks are owned by
their respective owners
Ways to
Access Web
Services!
There are two ways to
access Web Services.
• Simple Object Access Protocol
(SOAP).
• Representational State Transfer
Protocol (REST).
SOAP
The Granddaddy of Web Services
Interfaces.
• XML based messaging protocol.
• Platform and Language
Independent.
• SOAP has built-in stateful
operations.
• SOAP is complex, yet well
formatted.
REST
The easy way to expose Web
Services. (REST + JSON)
• Uses HTTP to perform CRUD.
• Platform and Language
Independent.
• REST is naturally stateless.
• REST is easy to understand.
ABC Flight Website
**Logos and Trademarks are owned by
their respective owners
Flight Aggregator Application
**Logos and Trademarks are owned by
their respective owners
Benefits of
API
• Helps making money (ebay)
• Helps saving money (AWS)
• Helps building brand (Google
Map)
• Move to the CLOUD (shopify)
• Omni presence (Netflix)
Why we need
API?
We need to have a Web API if we
want to store and process our data
in server and let any other
application (web application, mobile
application, IoT devices etc.)
request and get data from that
server if needed.
Authenticati
on
• Basic access authentication.
• OAUTH authentication.
Basic access authentication
**Logos and Trademarks are owned by
their respective owners
OAUTH
**Logos and Trademarks are owned by
their respective owners
How to build
API in
Magento 1?
Magento supports both SOAP and
RESTful APIs’
Create SOAP
API in
Magento 1?
Required files to create SOAP apis’
• api.xml
(app/code/code_pool/namespace/module
_name/etc/api.xml)
• wsdl.xml
(app/code/code_pool/namespace/module
_name/etc/api.xml)
• Api functionality or business
logic
(app/code/code_pool/namespace/module
_name/Model/Api.php)
Create REST
API in
Magento 1?
Required files to create REST apis’
• api2.xml
(app/code/code_pool/namespace/module
_name/etc/api2.xml)
• Api functionality or business
logic
(app/code/code_pool/namespace/module
_name/Model/Api2/your_api_file.php)
Create API
in Magento2?
Required files to create apis’
• webapi.xml
(vendor/namespace/module_name/etc/w
ebapi.xml)
• Api functionality or business
logic
(vendor/namespace/module_name/Api/y
our_api_file.php)
webapi.xml
<route url="/V1/module_name" method="POST">
<service class="namespacemodule_nameApiyour_api_file_name" method="doSomething"/>
</route>
URL will be
your_domain/V1/module_name POST
Api functionality
public function doSomething () {
// your business logic
}
Thank You!
You may now ask questions

Magento Meetup New Delhi- API

  • 1.
  • 2.
    Ratnesh Kumar Building mobileapps for Android & iOS devices. (Mobikul Department)
  • 3.
    Story of an UNSUNGHERO In this era of technology, we all are connected around the world from desktop to mobile devices to laptops to browser. But how does this happens? How does data reach from one device to another? How do different devices interact with each other ? Behind all this, there is a hero that is API.
  • 4.
    Application Programming Interface (API) What is anAPI? Api is simply exposing business capabilities (web services) over the internet. OR API consists of a set of rules describing how one application can interact with another, and the mechanisms that allow such interaction to happen.
  • 5.
    XYZ Restaurant **Logos andTrademarks are owned by their respective owners
  • 6.
    Ways to Access Web Services! Thereare two ways to access Web Services. • Simple Object Access Protocol (SOAP). • Representational State Transfer Protocol (REST).
  • 7.
    SOAP The Granddaddy ofWeb Services Interfaces. • XML based messaging protocol. • Platform and Language Independent. • SOAP has built-in stateful operations. • SOAP is complex, yet well formatted.
  • 8.
    REST The easy wayto expose Web Services. (REST + JSON) • Uses HTTP to perform CRUD. • Platform and Language Independent. • REST is naturally stateless. • REST is easy to understand.
  • 9.
    ABC Flight Website **Logosand Trademarks are owned by their respective owners
  • 10.
    Flight Aggregator Application **Logosand Trademarks are owned by their respective owners
  • 11.
    Benefits of API • Helpsmaking money (ebay) • Helps saving money (AWS) • Helps building brand (Google Map) • Move to the CLOUD (shopify) • Omni presence (Netflix)
  • 12.
    Why we need API? Weneed to have a Web API if we want to store and process our data in server and let any other application (web application, mobile application, IoT devices etc.) request and get data from that server if needed.
  • 13.
    Authenticati on • Basic accessauthentication. • OAUTH authentication.
  • 14.
    Basic access authentication **Logosand Trademarks are owned by their respective owners
  • 15.
    OAUTH **Logos and Trademarksare owned by their respective owners
  • 16.
    How to build APIin Magento 1? Magento supports both SOAP and RESTful APIs’
  • 17.
    Create SOAP API in Magento1? Required files to create SOAP apis’ • api.xml (app/code/code_pool/namespace/module _name/etc/api.xml) • wsdl.xml (app/code/code_pool/namespace/module _name/etc/api.xml) • Api functionality or business logic (app/code/code_pool/namespace/module _name/Model/Api.php)
  • 18.
    Create REST API in Magento1? Required files to create REST apis’ • api2.xml (app/code/code_pool/namespace/module _name/etc/api2.xml) • Api functionality or business logic (app/code/code_pool/namespace/module _name/Model/Api2/your_api_file.php)
  • 19.
    Create API in Magento2? Requiredfiles to create apis’ • webapi.xml (vendor/namespace/module_name/etc/w ebapi.xml) • Api functionality or business logic (vendor/namespace/module_name/Api/y our_api_file.php)
  • 20.
    webapi.xml <route url="/V1/module_name" method="POST"> <serviceclass="namespacemodule_nameApiyour_api_file_name" method="doSomething"/> </route> URL will be your_domain/V1/module_name POST Api functionality public function doSomething () { // your business logic }
  • 21.
  • 22.
    You may nowask questions