Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
Hi,
We stored some metafield data (ID: 20549960138948) for one of the merchants https://ruglove-co-uk.myshopify.com. Through Postman, we can get the metafield data through the GET request https://ruglove-co-uk.myshopify.com/admin/api/2021-07/metafields/20549960138948.json but when we change the request to https://ruglove-co-uk.myshopify.com/admin/api/2021-07/metafields.json, the stored data is not returned from the body. Do you know what might be going on here? We're able to get our metafield data for other test stores using the above requests.
Solved! Go to the solution
This is an accepted solution.
My guess: you have lots of metafields on the product and you are either
This is an accepted solution.
My guess: you have lots of metafields on the product and you are either
Is the metafield pagination documented anywhere? I can't find it in the REST API doc
Hey @Zona thanks for posting a question on the forums! As @Jason mentioned above, you can paginate your requests to the REST API using the response headers on your request.
Specifically, you want to iterate over the pages of your request. There, you'll see some URL parameters that you can use like "limit" and "page_info" – I wouldn't suggest increasing the limit because you'll risk timing out your requests. Instead, use the page_info parameter to go to the next page of metafields until you've found the right one.
You can also filter the metafields that you request using the following URL parameters:
For example, you can get shop metafields with the namespace "Shopify" that were created on or after January 1st, 2021, with the following URL:
`/admin/api/2021-07/metafields.json?limit=50&namespace=Shopify&created_at_min=2021-01-01`
To learn more visit the Shopify Help Center or the Community Blog.
@stratify Hello Stratify, I'd like to ask a question.
You can also filter the metafields that you request using the following URL parameters:
For example, you can get shop metafields with the namespace "Shopify" that were created on or after January 1st, 2021, with the following URL:
`/admin/api/2021-07/metafields.json?limit=50&namespace=Shopify&created_at_min=2021-01-01`
Is it able to filter "Shop" type by using namespace and key?
I couldn't filter the metafields by URL parameters.
Also, I'm using "/admin/api/2021-07".
This is my code.
import Shopify from '@shopify/shopify-api';
const client = new Shopify.Clients.Rest('your-development-store.myshopify.com', accessToken);
const res = await client.get({
path: 'metafields',
query: {"metafield%5Bnamespace%5D":"grobal","metafield%5Bkey%5D":"test"},
});
console.log("getSettingsFromApi res: ");
console.dir(res, { depth: null });
Reference
Hi @ken001 – can I suggest posting a new question if you're still having issues? It helps everyone in the Community when we have one question per thread.
For future reference, we can filter Shop-level metafields via the API. That's actually how Product Image metafields are accessed:
/admin/metafields.json?metafield[owner_id]=#{id}&metafield[owner_resource]=product_image
Be sure to double check that you're querying the right details, including shop URL, access token, and URL parameters. For example, your code is querying for the namespace "grobal" when you probably want "global" – hope that helps! If not, feel free to tag me on a new question.
To learn more visit the Shopify Help Center or the Community Blog.
can I suggest posting a new question if you're still having issues?
No, I don't have any issue.
Thank you for your suggestion.
hello everyone i just need in admin api for metafields i am using as documented but got an error
Hi @Zeesh the original issue has been resolved. Please create a new issue on the Community Forums.
You're more likely to get an answer if you provide more context on your question. Be sure to provide text examples instead of screenshots, and feel free to tag me in the new post and I'll do my best to help 🙂
To learn more visit the Shopify Help Center or the Community Blog.