Search code examples
shopifyshopify-api-node

How can I specify the language when using shopify-api-node to list products from a site with multiple languages


I am trying to access the English product translations from a site that defaults to Italian.

/products/ = Italian
/en/products = English
/es/products/ = Spanish

The access token is for the Admin API and has access to the scopes read_products and read_product_listings

const ShopifyAPI = require('shopify-api-node');
const shopify = new ShopifyAPI({shopName, apiVersion, accessToken});

const data = await shopify.product.list()

Solution: Use GraphQL

const query = `{
  products(first:10,reverse:true){edges{node{
    id 
    translations(locale:"en"){key locale value}
  }}}
}`

const data = await shopify.graphql(query);

Solution

  • The Shopify GraphQL API offers up an endpoint you can use where you provide the resource ID you are interested in, ie) a product ID, and you can get back the translations assigned to it. I would therefore read the docs on translations and move on from there.