What is Magento 2 API?
Magento 2 web API framework offers developers and integrators the ability to use web services that communicate with the Magento 2 system. Magento 2 web API comes with a bunch of features such as:
1. REST and SOAP are supported, and they both have the same web API coverage
2. Support three types of authentication:
- OAuth 1.0a: for third-party applications authentication
- Tokens: for mobile applications authentication
- Login credentials: for admins and customers authentication
3. The resources to which all integrations and accounts have access to are assigned. To perform the request, the API framework checks to make sure that any call has authorization
4. Ability to configure any Magento 2 or third-party service as a web API with a few lines of XML. You will need to define XML elements and attributes in a webapi.xml to configure a web API. Otherwise, the service won't be exposed
5. The system does not currently support webhooks, since the framework is based on the search model and the CRUD (create, read, update, delete)
6. Field filtering of web API responses is supported by the framework to conserve mobile bandwidth
7. A single web API call can be enabled by running multiple services at once for more efficient integration
Why Using Magento API?
Magento 2 API can be used to perform a wide array of tasks, such as:
1. Building a shopping app. Eg. A traditional app that users can download on a mobile device, or an app used for other purposes
2. Integrating with CRM or ERP backend systems, eg. Xero, Salesforce, etc
3. Integrate with other CMS. At present, content tagging is not supported
4. Building JS widgets in Magento 2 frontend or backend to access services via AJAX calls
How To Get Started With Magento APIs?
To start using web API in Magento 2, you need to create a web service in Magento 2 backend.
Here are the general steps to enable web services in Magento 2 backend:
Create a web services user
a) For token-based authentication:
- Login to Magento 2 backend,
- goto System > Permission > All Users > Add New User
- create a web services user
b) For session-based or OAuth authentication, you do not need to create a new user in the backend.
2. Create a new integration
- goto System > Extensions > Integration
- click Add New Integration
Make sure to select the resources the integration can access.
3. Use a REST or SOAP client to configure authentication.
We hope you find this Magento 2 API article helpful. Feel free to leave your comment below or share this article.