Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
Hi All,
Sorry if this has already been asked and answered, I did have a search and couldn't find anything of real help. Ok, so here's my problem. We've got 3 Shops that we keep synced using some scripts etc that pull a full product list using the API. This is working fine and has been for over a year now. It's even working using the new method of paganation. The problem we currently face is that each product has several metafields for extra information about the products. Now, up until now we've always just gone through the list making a request for each products metafields. The problem is we now have over 1200 products and when pulling that much from the API Shopify are hitting us with a 430 Error "This page is temporarily unavailable because a device from your location is sending large amounts of web requests. Visitors from other locations can still view the page." So my question is, does anybody know if there is a way of requesting More than one products metafields at a time something like https://ourshop.myshopify.com/admin/api/2020-01/products/product1,product2,product3/metafields.json type of thing?
Thanks in advance for you time and help
Hey,
we normally work with limits and offsets, since the limit for the request it 250, you will request always using limit=250 and then in the next request using the last ID you got in the response to do a request with the parameter since_id and again with a 250 limit.
Let me know if that helps! If you need, we could have a deeper look as well. Just write us at info@webmefy.com.
Sorry, I think you might have misunderstood what I was asking. I know about the limit option in both the products and the metafields, but that just sets how many products are in the return or how many of the metafields associated with that product. What we really need is a way of requesting all the metafields belonging to say products 1 through 50 so we'd get something like response = [product_1 :{metafields}, product_2:{metafields}...] type of thing instead of having to request each products metafields in turn. I have a feeling this might be how the graph_ql works, but I think I must be being a little thick as I'm really struggling to get my head round it, hence reaching out for help.
Thanks
I see... I don't think there is a way to do that without going product by product. I will ask our team and check with them if they know of other options.
Yea, product by product is how we're doing it at the moment, but we've now got over 1200 products and unfortunately, even with sleeps here there and everywhere to stop it happening the API still thinks we're spamming them so if you can find anything that may help it would be brilliant .
Thanks Again
Hello there,
Have you considered using the Admin GraphQL API? It's possible that it'll reduce the number of calls you have to make to synchronize product and product metafields' data.
{ products(first: 50) { edges { node { # product data here metafields(first: 50) { edges { node { # metafield data here } } } } } } }
To learn more visit the Shopify Help Center or the Community Blog.
That sounds like what I'm looking for, is there a howto anywhere you can point me towards please?
Of course, no problem.
Also, you do not need to change your code wholesale. You can start using the GraphQL API for this specific feature, while other parts of your app can still use the REST API until you have the time and resources to make the switch.
To learn more visit the Shopify Help Center or the Community Blog.