In this article I am going to explain to you from the scratch, so even if you don't have any idea about Magento 2 REST API then also you can easily call the REST API and send the request and receive the request.
Magento 2 series has already provided REST APIs for most of the Modules so you don't need to create REST API you can just call those APIs and get the data on a third-party service to send the request from the third-party websites.
But, you can also create a dynamic REST API which is known as custom APIs development in Magento 2. By using custom APIs you can also get the data post the data save the data etc.
What is Swager in Magento 2?
A swagger is an open-source tool. That simplifies APIs in Magento 2 for the development that helps users or developers with the Swagger open source and professional toolset.
How to Call Swagger in Magento 2
There is one library that is swagger that helps you to get all the default Magento 2 REST APIs. You just have to enter the domain name and then type swagger and then press enter. You will get a list of the available APIs in Magento 2.
Test Magento 2 REST API on Swagger
When you will press enter after your domain URL in formate like https://www.your-domain.com/swagger/ then the generated Swagger documentation provides the capability to test REST requests.
So just hit try out button and then test your required REST APIs.
You will get the relevant information regarding APIs. when you need to retrieve the data then you need a customer access token also.
How To Call Magento 2 REST API With Example
Here giving you the one example to call REST API in Magento 2. I have created a customer access token by using the following default REST API.
Step 1: Call REST API using Postman
In the above screenshot, you can see I have to call Magento 2 Apis by Using Postman. A postman is a tool is an application that provides facilities to test any kind of API. Here you can send requests by using Apis to any server and receive the response.
Step 2: How To Call REST APIs in GraphQL
This is the GraphQL method, here you can get the same result by using GraphQL in Magento 2.