Magento 2 API – Get All Available Currencies
End-to-end Magento integration
Integrate any app or service. Consult our API development experts.
Hello, Magento peeps!
My last blog post on Magento 2 API was all about getting customer access token. In case you missed it, you can read it here at Magento 2 API – Get Customer Token. In this blog post, I will show you how to get all available currencies in Magento 2 using API.
Suppose you are developing a third-party app on Magento 2, you may require to fetch the list of all the available currencies in the store to display them to the customers on the storefront. If there are multiple currencies in the store, you may also require to allow the customers to select their preferred currency for shopping. Allowing such a feature on the app can greatly improve the shopping experience of the customer with the store. Developers can use the Magento 2 API to fetch all the available currencies.
Let’s begin with the Magento 2 API – Get all Available Currencies.
How to Get All Available Currencies Using Rest API in Magento 2?
Available currencies in Magento 2 can be fetched by calling a GET request to the V1/directory/currency endpoint. The request will return all the available currencies in Magento 2 in the body. More details regarding the same are provided below.
Method: GET
URL: store_url/rest/V1/directory/currency
Response:
The request will return the store’s base currency along with other currencies and their exchange rates in the following format:
1 2 3 4 5 6 7 8 |
{ "base_currency_code":"USD", "base_currency_symbol":"$", "default_display_currency_code":"USD", "default_display_currency_symbol":"$", "available_currency_codes":["USD"], "exchange_rates":[{"currency_to":"USD","rate":1}] } |
That’s it! This is how you can get all currency data such as code, rate, and symbol in Magento 2 using rest API.
Conclusion
Facilitating the customers to shop using their preferred currency is important while selling globally. Magento 2 provides a rest API endpoint to get all the available currencies in the store along with their code, symbols, and conversion rates. I hope this blog post will help you to get all available currencies in Magento 2 using rest API. In case you still have any queries or doubts regarding the provided solution, feel free to comment. I would be happy to help you. 😊
Also, do not forget to share this helpful guide with your Magento friends via social media. 😀
Thanks for reading! 🍀
◄ Magento 2 API – SearchCriteriaMagento 2 API – Create New Customer ►
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.
Prev
How to Create Coupon Codes in Magento 2
How to Sell on Instagram Without a Website [Brief Strategy]
Next