Magento 2 API – Get All Store IDs, Names, and Codes

Hello, Magento peeps!

In my last blog post on Magento 2 API, I provided complete tutorial to get admin token through API. In case you missed it, you can catch it at: Magento 2 API – Get Admin Token. In this blog post, I will show you how you can get all store ids, names, and codes through Magento 2 API.

Being a robust, powerful and customizable eCommerce platform, Magento 2 facilitates the developers to use the platform from anywhere through its APIs. The APIs make can be used to exchange data seamlessly between the applications.

If you are having multiple store-views in your Magento 2 store, and want to display specific store-views, you may require to get all the store IDs, names, and codes. It can be easily done by calling Magento 2 API – Get All Store IDs, Names, and Codes.

Here is the complete tutorial to get all store ids, names, and codes through Magento 2 APIs.

How to Get All Store IDs, Names, and Codes Using Magento 2 API?

In order to get all store IDs, names, and codes in Magento 2 through API, we’ll perform a GET call to /V1/store/storeGroups endpoint. From the v2.4 onwards, Magento restricts the anonymous access to many of the APIs for security purposes and this is one of them. Therefore, we need to pass the authorization token to get all store IDs, names, and codes through Magento 2 API.

Here is the complete Magento 2 API call to get all store IDs, names, and codes.

  • Method: GET
  • URL: store_url/rest/V1/store/storeGroups
  • Authorization Type: Bearer Token
  • Token:<admin token>

Magento 2 API - Get All Store ID, Names, and Codes

Response:

On calling the above request, you’ll get all the store IDs, names, and codes in Magento 2 in the following format:

That’s it! This is how you can get all store IDs, names, and codes in Magento 2 through the API.

Conclusion

If you are developing a Magento 2 app, there can be instances when you require to fetch all store IDs to work on a specific store view. You can use perform an API call to Magento 2 by passing the authentication token to get IDs, names, and codes of all the storeviews.

In case you still have any queries or doubts regarding it, feel free to comment. I would be happy to help you. 💫

Also, do not forget to share this Magento 2 API tutorial with your developer friends through social media! 🔗

Thanks for reading. 😊

◄ Magento 2 API – Get Admin TokenMagento 2 API – Get CMS Page Content ►

4.8
(based on 5 Reviews)
Magento 2 API – Get All Store IDs, Names, and CodesAuthor Magento Badge

Jignesh Parmar

An expert in his field, Jignesh is the team leader at Meetanshi and a certified Magento developer. His passion for Magento has inspired others in the team too. Apart from work, he is a cricket lover.

Leave a Reply

Your email address will not be published.