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

Solved

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

doabledanny
Shopify Partner
13 0 6

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! 

 

doabledanny_0-1666290152421.png

 

Accepted Solution (1)

StevieW
Shopify Partner
12 1 6

This is an accepted solution.

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.

Want an easy way to open the Shopify Admin for Products, Pages, Collections and more? Use the FREE Shopify Admin Redirect chrome extension.

View solution in original post

Replies 5 (5)

StevieW
Shopify Partner
12 1 6

This is an accepted solution.

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.

Want an easy way to open the Shopify Admin for Products, Pages, Collections and more? Use the FREE Shopify Admin Redirect chrome extension.
doabledanny
Shopify Partner
13 0 6

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

ToloLift
Shopify Partner
1 0 4

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.

moin786ahamad
Shopify Partner
3 0 4

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

Thanks & Regards
Moin Ahamad
Salesforce Developer
ndrtek
Shopify Partner
13 0 14

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

 

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

 

G