How can I fetch metafield data of specific resources?

Hi,

I want to fetch data of metafields associated with a specific resource i.e collections, companies, company location, blog posts and markets. For this purpose, I first need to fetch their own data in order to get the ID which will be passed in metafield endpoint.

First question here is, when i hit this url in my browser admin/api/2023-07/collections.json it displays some data related to collection but when i hit it by code the response i get is

{“errors”:“Not Found”}. This is how I am hitting the endpoint

$client->get(‘/admin/api/2023-07/collections.json’);
Secondly, what is the endpoint to fetch companies, company location, blog posts and markets data.
What is the difference between location and company location.

Hi,

I don’t think a list of store collections can be fetched using the REST api (at least not anymore). You might be better off using the Graphql api instead.

Your query would look something like this:

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$query = <<