Hi Buddy,

So you have Magento 2 but want to explore its new RESTful APIs – a web API. Don’t go anywhere but stay at this post because it’s a “getting started” guide for you which introduces topics such as authentication.If you want deeper knowledge about Magento APIs, please follow our blog. We will provide it in later posts.

Resource for you: Magento extensions / Magento 2 extensions 

Here we go :).

What are the Magento web APIs?

The Magento web API framework provides integrators and developers the means to use web services that communicate with the Magento system. Key features include:

  • Support for both REST (Representational State Transfer) and SOAP (Simple Object Access Protocol). In Magento 2, the web API coverage is the same for both REST and SOAP.
  • Three types of authentication:
    • Third-party applications authenticate with OAuth 1.0a.
    • Mobile applications authenticate using tokens.
    • Administrators and customers are authenticated with login credentials.
  • All accounts and integrations are assigned resources that they have access to. The API framework checks that any call has authorization to perform the request.
  • Any Magento or third-party service can be configured as a web API with a few lines of xml.
  • To configure a web API, you define XML elements and attributes in a webapi.xml configuration file. If a service is not defined in a configuration file, it will not be exposed at all.
  • The framework is based on the CRUD (create, read, update, delete) & search model. The system does not currently support web hooks.
  • The framework supports field filtering of web api responses to conserve mobile bandwidth.
  • Integration style web API’s enable a sinlge web API call to run multiple services at once for a more efficient integration. An example of this behavior can be see in the Catalog where one web API call can create a product; if your payload includes the inventory object and media object then the framework will also create the product’s inventory & media in that one API call.

What can I do with the Magento web APIs?

The APIs can used to perform a wide array of tasks. For example:

  • Create a shopping app. This can be a traditional app that a user downloads on a mobile device. You could also create an app that an employee uses on a showroom floor to help customers make purchases.
  • Integrate with CRM (Customer Relationship Management) or ERP (Enterprise Resource Planning) back-end systems, such as Salesforce or Xero.
  • Integrate with a CMS (Content Management System). At present, content tagging is not supported.
  • Create JavaScript widgets in the Magento storefront or on the Admin panel. The widget makes AJAX calls to access services.

How do I get started?

You must register a web service on Magento Admin. Use the following general steps to set up Magento to enable web services.

  1. If you are using token-based authentication, create a web services user on Magento Admin by selecting System > All Users > Add New User. (If you are using session-based or OAuth authentication, you do not need to create the new user in the Admin.)
  2. Create a new integration on Magento Admin. To create an integration, click System > Integration > Add New Integration. Be sure to restrict which resources the integration can access.
  3. Use a REST or SOAP client to configure authentication.

Hope you have a sweet start with Web APIs. Feel free to share this guide with your friends if you find it useful.

On the next blog post we’ll have a look at Magento 2 Rest APIs listing! So, stay tuned 🙂

———

Other developers are challenging themselves with Magento test tool, beat them now earn rewards!

I’m gonna beat them!

Author

Why Magestore? We believe in building a meaningful & long-term relationship with you.

2 Comments

  1. same can be found @http://devdocs.magento.com/guides/v2.0/get-started/bk-get-started-api.html

  2. gaurav gupta Reply

    Hi,
    I am magento cum php developer,I am new to magento2.0, I got assigned a new project, in which client want to develop a portal in which all frontend will be governed by wordpress and backend in magento2.0

    1. We need for the day-to-day management of content pages to be easily handled by our Content Editors, who do not have development backgrounds.
    a. WordPress is the CMS of choice for simplistic, easy use by administrators
    b. All CMS pages should be handled completely by WordPress
    2. Magento should exist solely as a back-end service. It should have nothing to do with rendering the front-end at any point in the user experience
    a. The Magento admin interface will be controlled by Magento
    i. For store, product, etc. management
    b. All Magento data, inclusive of catalog/products, inventory, customer data, quotes, checkout process, etc., should be utilized from within WordPress by way of the Magento 2 REST API
    i. http://devdocs.magento.com/guides/v2.0/get-started/bk-get-started-api.html
    ii. http://devdocs.magento.com/guides/v2.0/rest/bk-rest.html
    iii. http://devdocs.magento.com/guides/v2.0/rest/list.html
    iv.
    c. We expect all data acquired via the Magento 2 REST API to be served as JSON objects and ingested by WordPress for styling and display to the end user.
    d. This allows for WordPress caching to be easily implemented as these very API calls themselves are cacheable as REST objects

    I didn’t find any step by step tutorial to implementing the magento2.0 rest Api, from integration to token exchange and authorisation and get the result on wordpress end,

    I only want help to the following,

    My wordpress install in root like /demo
    magento install in shop /demo/shop

    I want to create the integration in such a way that in the wordpress(demo folder) i want to access all magento2.0 Api

    like if I make a request from wordpress then got the response from magento2.0(shop folder both are on same server)

    My problem is to create an integration,
    I have created one but get only consumer key and consumer secret,
    On the wordpress end Hit the magento2.0 api by php curl. got token but after getting token iam not able to get the response of another api by using that tocken. Iam confused in by use of token and further.

    It will be great help for me if i can understand
    integration step by step,
    hit the api with proper paramaters,
    how token create and exchange,
    how to hit another api of magento2.0 by using the generated token.

Write A Comment