How to Match Shopify's Exchange Rates and Retrieve Products with Country-Specific Pricing via GraphQL

Hello,

I would like to know how I can retrieve the exact same exchange rates that Shopify uses for currency conversion across different countries. Is there a way to access or replicate these rates through the Shopify API?

Additionally, I am using the Storefront GraphQL API and would like to fetch products based on a specific country code. My goal is to have the returned product prices reflect the converted amounts using the same exchange rates Shopify applies.

Is this achievable through the API, and if so, what would be the best approach to ensure consistency with Shopify’s pricing logic?

Thank you in advance for your guidance.

Best regards,
Toan

Hi, I think Shopify does not provide direct access to the exact exchange rates it uses via any of its APIs.

However, there’s a useful workaround that can help you replicate the effective exchange rate on the storefront side:

  1. Create a shop-level metafield of type money (e.g., custom.exchange_base) and assign it a static value of 1.00.
  2. When queried via Storefront API in a specific customer context (i.e., with a different country or currency), Shopify will return the converted value of that metafield according to the active exchange rate.

For example, if the shop currency is PLN and a user from the US is browsing, querying the custom.exchange_base metafield will return the equivalent of 1 PLN in USD - effectively giving you the exchange rate.

2 Likes

Hi Toan, you shouldn’t need to worry about the FX rate that is being used, you only need to worry about the resolved value for each country. If you’re using the Storefront API, inContext directive gives you this: Storefront API reference

If you still think you need to know what the FX rate is, I’d love to know more about the use case, but this is not something we expose.

1 Like

A word of caution for anyone finding this thread: this “money”-typed metafield approach has some potential drawbacks, the biggest of which is that a market may be configured to round prices after converting their currency. Using a value of 1 for the metafield reveals this problem; for example, I set up a “money” metafield with a value of 1 USD, then when I viewed the metafield’s value on a store using EUR, the value was showing as 0.95, whilst the actual exchange rate (confirmed by checking window.Shopify.currency) was ~0.87. It took me quite some time to find out the the 0.95 was a result of having the “Round up to the nearest €0.95 EUR” option enabled in the market’s configuration; after disabling this, I started to see the expected value. If you’re building a general solution for stores that you don’t control the market configuration for, it’s highly likely that you’ll encounter this issue.

1 Like

Hi @coleatkinson. I discovered this thread looking for a way to retrieve the exchange rate used by Shopify. Our use case is to be able to convert the monetary value of rewards that customers can purchase using loyalty points through our app into the customer’s local currency. Since these values live outside the store, they aren’t available for conversion via the Storefront API, and consequently we need the Shopify exchange rate. Whilst this is available on the storefront via the global window.Shopify.currency object, we also need it across other surfaces, such as on customer account UI extensions, checkout UI extensions etc. So, if there were a reliable way to obtain the exchange rate for a particular market, which can be used consistently across multiple surfaces, it’d be really helpful. Thanks!

1 Like

Good point. I’ve verified it, and you are correct. Hopefully, Shopify will soon release a native way to retrieve these values when creating an app, just like @AndyPye wrote.

Clearly, using metafields as a workaround doesn’t always work perfectly. :sweat_smile:

EDIT: It would be great to be able to grab prices per specific market as well!

1 Like

Agreed :+1: I did find something of a workaround using the metafield trick – using a value much larger than 1 for the metafield then dividing the value after conversion makes any rounding issues much less significant (e.g. using a value of 1_000_000 USD then dividing the metafield’s value by 1_000_000after it’s been converted), but this is still very much a workaround, and presumably also introduces issues when converting from/to very low-value currencies. In the end we decided that this approach is too unreliable and too much of a hack to be worth pursuing :person_shrugging:

1 Like

@coleatkinson apologies for resurrecting what’s marked as a “solved” problem, but as the comments following the “solution” highlight, it doesn’t actually solve anything, and the only workaround that seems to be available is unreliable. I’m bumping this again because the need for the exchange rate has just come up for me again in a different context to the one that led me here before, and I’m also far from the first person to flag the necessity to expose the exchange rate in a reliable manner (e.g. it was reported over two years ago), so any help here would be appreciated! :folded_hands: