cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a custom API to get all details of products including order and stock details

SOLVED

How to create a custom API to get all details of products including order and stock details

I want to create a custom API to get all of the information of a product including stock details and order details.

I checked the existing product APIs but to get all of the information, need to run at least 3 APIs "/V1/products", "/V1/stockItems" and "/V1/orders".

I want the responses of these 3 APIs into a single API.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to create a custom API to get all details of products including order and stock details

Hi @vartika_sharma,

 

I guess that you will need to build a custom endpoint but maybe is better to use the original ones and, base don the response, perform new calls.

If that isn't an option, as you can imagine, you could explore all those endpoints and try to call the methods inside your own and customized route.

If you need some guidance to satrt building your own API andpoint, maybe you can start here: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/service-contracts/service-to-web-service...

View solution in original post

3 REPLIES 3

Re: How to create a custom API to get all details of products including order and stock details

Hi @vartika_sharma,

 

I guess that you will need to build a custom endpoint but maybe is better to use the original ones and, base don the response, perform new calls.

If that isn't an option, as you can imagine, you could explore all those endpoints and try to call the methods inside your own and customized route.

If you need some guidance to satrt building your own API andpoint, maybe you can start here: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/service-contracts/service-to-web-service...

Re: How to create a custom API to get all details of products including order and stock details

According to your answer, I am trying to create a new API which calls the existing methods to get products data inside my custom method. But now I am facing another issue.

I wanted to accept multiple values of a parameter (comma separated)
eg. parameters

     key           value

     id              1,2,3

Could you please help me with this.

 

Re: How to create a custom API to get all details of products including order and stock details

Hi @vartika_sharma,

 

It seems the requirment starts to being complex faster.

Maybe you could check if the feature can be simplified to avoid an endpoint that could waste your resoruces.