Get a list of unique product types rest api

Highlighted
Shopify Partner
150 2 21

I have an issue where a client has 17k products, to get a list of product types from this is extensive. Currently, I have to get all the products with the filter product type. This method just takes too long. What I wanted to know is there a filter I can request unique results?

 

An example call used : products.json?fields=product_type&limit=250&page=1&published_status=published

 

And if yes, can we do the same for checking the count?

 

ie: products/count.json

 

Thanks for the help.

Google Shopping Specialist - Data Feed Managment Tool
0 Likes
Shopify Staff
Shopify Staff
298 32 59

Hey Emmanuel,

 

There currently isn't a REST endpoint where this is possible, so you would have to conduct this filtering client side.

 

Edit: However, this is currently possible using the Shop object on our GraphQL API, as shown in these docs

 

{ shop { productTypes } }

I don't understand what you mean by "do the same thing for checking the count". The `admin/products/counts.json` endpoint currently returns the count of total products on the shop. Are you looking to filter this result by product type as well?

2 Likes
Shopify Partner
150 2 21

Hello Zameer, thank you kindly for the reply.

 

As you mentioned, I am currently doing this client side. Just wanted to reduce the call requests and returns :)

 

Interesting, I was looking into the GraphQL API, but stopped when I saw a few developers finding the rate limit hampering the effectiveness when it comes to large shops.

Most of my clients have small shops, but I have a dozen clients with large products and or variant lists (totaling 100k+ (mainly due to variants) ). And finding the limitations would be a downgrade from the REST API. However I have to say, I did not test it.

 

If you have any comments to this, that would be great.

 

With regards to checking the count. I meant if it was possible to send a request to the REST API for unique product types, to then also be able to count these unique product types so that the call loop can be created. IE: pagination.

 

But you have answered my question when you said this is not possible.

 

I am very interested in the GraphQL, just the limitations are a bit worrying at the moment.

 

Kind regards, Emmanuel.

Google Shopping Specialist - Data Feed Managment Tool
0 Likes
Shopify Staff
Shopify Staff
298 32 59

Hey @Emmanuel_Flossi,

 

GraphQL can be significantly more performant than REST in many use-cases, I would encourage you to give it a try. 

 

This doc describes it in details, but since the breakdown is based on the cost of a query and not simply the quantity of calls being made, you're able to only request the object properties relevant to you. This greatly improves the efficiency of your API calls and maximizes your call rate.

0 Likes
Shopify Partner
150 2 21

Thank you Zameer, I will do some test myself :)

Google Shopping Specialist - Data Feed Managment Tool
0 Likes