How do you get a Product's Category using the GraphQL or Rest API?

I can get the Product Type using the GraphQL API from Product.productType, but I can’t find any documentation on how to get the Product Category. Could someone guide me in the right direction? Thanks!

This should help

https://shopify.dev/api/admin-graphql/2022-10/objects/ProductCategory

Go in via

{
  product(id: "") {
    productCategory {
      productTaxonomyNode {
        ...
      }
    }
  }
}

Also, this is only available on the 2022-10 (and later) api.

1 Like

Thank you! If anyone is getting null returned from this, be sure to click the tick icon on Product Category to actually accept it.

This is available for GraphQL. Can you please help me with the REST API mechanism to get the product category

4 Likes

But it’s not available via the Storefront GraphQL API?!

I need to pass the category into useServerAnalytics in my Hydrogen app.

G

Hi,

I would need to retrieve the product category with the Products endpoint using the REST API.

Is this planned to be added anytime soon?

Thank you.

4 Likes