Magento 1 vs Magento 2 - Is Magento 2 faster for building Marketplace Store
08 - Bill Curtis - Dancing with the Magento 2 Web APIs · DevelopersParadise 2016 / Opatija /...
Transcript of 08 - Bill Curtis - Dancing with the Magento 2 Web APIs · DevelopersParadise 2016 / Opatija /...
Sample Title
DevelopersParadise2016 / Opatija / Croatia
Dancing with the Magento 2 APIsA guided tour of the API dance floor
DevelopersParadise2016 / Opatija / Croatia
Bill CurtisCTO - Sweet Tooth
DevelopersParadise2016 / Opatija / Croatia
DevelopersParadise2016 / Opatija / Croatia
DevelopersParadise2016 / Opatija / Croatia
DevelopersParadise2016 / Opatija / Croatia
DevelopersParadise2016 / Opatija / Croatia
Overview
• Use cases for using the Magento 2 API
• How to make API calls
• Extending the API
• Tooling & Resources
DevelopersParadise2016 / Opatija / Croatia
Use casesWhat is the Magento API used for?
DevelopersParadise2016 / Opatija / Croatia
Extensions (PHP)
AppsERPPOSCRM
MAGENTO API
API Requests
DevelopersParadise2016 / Opatija / Croatia
How to make Magento 2 API calls
• SOAP vs REST
• XML vs JSON
• Overview of CRUD actions
• Search
• Authentication
DevelopersParadise2016 / Opatija / Croatia
SOAP vs REST
DevelopersParadise2016 / Opatija / Croatia
XML vs JSON
DevelopersParadise2016 / Opatija / Croatia
REST + JSON ♥
DevelopersParadise2016 / Opatija / Croatia
Anatomy of the API request
DevelopersParadise2016 / Opatija / Croatia
Anatomy of the API request
DevelopersParadise2016 / Opatija / Croatia
Anatomy of the API request
DevelopersParadise2016 / Opatija / Croatia
Anatomy of the API request
DevelopersParadise2016 / Opatija / Croatia
Anatomy of the API request
DevelopersParadise2016 / Opatija / Croatia
Anatomy of the API request
DevelopersParadise2016 / Opatija / Croatia
Anatomy of the API request
DevelopersParadise2016 / Opatija / Croatia
Create Read Update Delete
REST APIs support CRUD operations
DevelopersParadise2016 / Opatija / Croatia
Delete customer DELETE V1/customers/1
Create customer POST V1/customers {…}
Read customer GET V1/customers/1
Update customer PUT V1/customers/1 {…}
DevelopersParadise2016 / Opatija / Croatia
CRUD - Create a customer
POST /rest/V1/customers
REQUEST RESPONSE
DevelopersParadise2016 / Opatija / Croatia
CRUD - Read a customer
GET /rest/V1/customers/6
REQUEST RESPONSE
DevelopersParadise2016 / Opatija / Croatia
CRUD - Update a customer
PUT /rest/V1/customers/6
REQUEST RESPONSE
DevelopersParadise2016 / Opatija / Croatia
CRUD - Delete a customer
DELETE /rest/V1/customers/6
REQUEST RESPONSE
DevelopersParadise2016 / Opatija / Croatia
REST is an architectural style
DevelopersParadise2016 / Opatija / Croatia
http://devdocs.magento.com/guides/v2.0/rest/list.html
DevelopersParadise2016 / Opatija / Croatia
DevelopersParadise2016 / Opatija / Croatia
What about customer search?
DevelopersParadise2016 / Opatija / Croatia
Search customers GET V1/customers/search
DevelopersParadise2016 / Opatija / Croatia
GET /V1/cmsPage/searchGET /V1/cmsBlock/searchGET /V1/customerGroups/searchGET /V1/customers/searchGET /V1/carts/searchGET /V1/salesRules/searchGET /V1/coupons/searchGET /V1/taxRates/searchGET /V1/taxRules/searchGET /V1/taxClasses/search
GET /V1/productsGET /V1/categories
?
DevelopersParadise2016 / Opatija / Croatia
Search customers
GET /V1/customers/search
REQUEST RESPONSE
DevelopersParadise2016 / Opatija / Croatia
Search customers
GET /V1/customers/search?searchCriteria=
REQUEST RESPONSE
DevelopersParadise2016 / Opatija / Croatia
?searchCriteria=
The most powerful query param in the world
DevelopersParadise2016 / Opatija / Croatia
Search criteria
DevelopersParadise2016 / Opatija / Croatia
Search criteria
DevelopersParadise2016 / Opatija / Croatia
Search criteria
DevelopersParadise2016 / Opatija / Croatia
Search criteria
DevelopersParadise2016 / Opatija / Croatia
Search for an email within a store id
DevelopersParadise2016 / Opatija / Croatia
Search for an email within a store id
DevelopersParadise2016 / Opatija / Croatia
Search within store id
DevelopersParadise2016 / Opatija / Croatia
Search for a customer in store 1
AND
DevelopersParadise2016 / Opatija / Croatia
Search for a yellow OR red product created this year
DevelopersParadise2016 / Opatija / Croatia
Search for a yellow OR red product created this year
DevelopersParadise2016 / Opatija / Croatia
Search for a yellow OR red product created this year
OR
DevelopersParadise2016 / Opatija / Croatia
Search for product
DevelopersParadise2016 / Opatija / Croatia
Search for product
AND
DevelopersParadise2016 / Opatija / Croatia
?searchCriteria=
DevelopersParadise2016 / Opatija / Croatia
DevelopersParadise2016 / Opatija / Croatia
DevelopersParadise2016 / Opatija / Croatia
Customer Search
REQUEST RESPONSE
DevelopersParadise2016 / Opatija / Croatia
Authentication How do we get this token?
DevelopersParadise2016 / Opatija / Croatia
1. Username & Password
2. OAuth 1.0a
3. Session
3 ways to authenticate
DevelopersParadise2016 / Opatija / Croatia
1. Username & Password
2. OAuth 1.0a
3. Session
1st party apps / integrations
DevelopersParadise2016 / Opatija / Croatia
Username & Password Authentication
POST /rest/V1/integration/admin/token
REQUEST RESPONSE
POST /rest/V1/integration/customer/token
DevelopersParadise2016 / Opatija / Croatia
PUT /V1/customers/meGET /V1/customers/mePUT /V1/customers/me/activatePUT /V1/customers/me/password
POST /V1/carts/mineGET /V1/carts/mine
GET /V1/carts/mine/itemsPOST /V1/carts/mine/itemsPUT /V1/carts/mine/items/:itemIdDELETE /V1/carts/mine/items/:itemId
Customer API Access
DevelopersParadise2016 / Opatija / Croatia
1. Username & Password
2. OAuth 1.0a
3. Session 3rd party apps / integrations
DevelopersParadise2016 / Opatija / Croatia
DevelopersParadise2016 / Opatija / Croatia
DevelopersParadise2016 / Opatija / Croatia
DevelopersParadise2016 / Opatija / Croatia
DevelopersParadise2016 / Opatija / Croatia
DevelopersParadise2016 / Opatija / Croatia
DevelopersParadise2016 / Opatija / Croatia
1. Username & Password
2. OAuth 1.0a
3. Session
In browser
DevelopersParadise2016 / Opatija / Croatia
DevelopersParadise2016 / Opatija / Croatia
Extending the Magento APIetc/webapi.xml
DevelopersParadise2016 / Opatija / Croatia
etc/webapi.xml
DevelopersParadise2016 / Opatija / Croatia
etc/webapi.xml
DevelopersParadise2016 / Opatija / Croatia
etc/webapi.xml
DevelopersParadise2016 / Opatija / Croatia
etc/webapi.xml
DevelopersParadise2016 / Opatija / Croatia
Magento 2.0.4 Release - March 31 2016
DevelopersParadise2016 / Opatija / Croatia
DevelopersParadise2016 / Opatija / Croatia
Development resources
DevelopersParadise2016 / Opatija / Croatia
DevelopersParadise2016 / Opatija / Croatia
http://<magento_host>/rest/default/schema
DevelopersParadise2016 / Opatija / Croatia
http://devdocs.magento.com/swagger/
DevelopersParadise2016 / Opatija / Croatia
DevelopersParadise2016 / Opatija / Croatia
DevelopersParadise2016 / Opatija / Croatia
http://devdocs.magento.com/guides/v2.0/rest/list.html
DevelopersParadise2016 / Opatija / Croatia
https://luckymarmot.com/paw
DevelopersParadise2016 / Opatija / Croatia
https://www.getpostman.com/
DevelopersParadise2016 / Opatija / Croatia
DevelopersParadise2016 / Opatija / Croatia
Thank You!