How do I get metafields for multiple resources at once with REST Admin API

I am trying to retrieve metafields for multiple products via this REST Admin API call: https://shopify.dev/docs/api/admin-rest/2024-01/resources/metafield#get-metafields
However I can’t seem to figure out how to send multiple metafield[owner_id]s in a single request. The reference documention states the following:

Retrieve a list of metafields by using query parameters> Retrieves a list of metafields that belong to a resource by using query parameters.> > Parameters> api_version: string - required> metafield[owner_id] ≤ 100 (Filter by the resource ID on which the metafield is attached to.)> metafield[owner_resource] ≤ 100 (Filter by the resource name on which the metafield is attached to.)

The above is clearly specifying that it is possible to request up to 100 different resource ID’s in a single request (the “≤ 100” part). Unfortunately there is no example of how to do it and I can’t find any other examples.

My first attempt was using commas to separate multiple ID’s, like so:

x.myshopify.com/admin/api/2023-10/metafields.json?metafield[owner_id]=ID1,ID2&metafield[owner_resource]=product

This pattern is used elsewhere in the API, but does not work here. It simply responds with a 400 error stating “expected String to be a id”. (Note: I did us actual product ID’s and not just the ID1,ID2). I also tried modifying this by also adding another product to metafield[owner_resource] since I figured maybe they needed to line up pairwise with the ID’s, like so:

x.myshopify.com/admin/api/2023-10/metafields.json?metafield[owner_id]=ID1,ID2&metafield[owner_resource]=product,product

Still that didn’t work. I tried different kinds of separators (+,|,&) for separing the ID’s, but nothing worked. I tried repeating the query parameter for each ID, like so:

x.myshopify.com/admin/api/2023-10/metafields.json?metafield[owner_id]=ID1&metafield[owner_id]=ID2&metafield[owner_resource]=product

However nothing seems to work for me.

I’d appreciate if anyone can help me with this or if they can tell me if the reference documentation is just incorrect when it says “≤ 100” metafield owner id’s can be sent. Thank you in advance!

The “≤ 100” in the documentation likely refers to the maximum number of metafields you can retrieve in a single request, not necessarily the ability to specify multiple owner_ids

Try just a single owner_id.

Yeah it works for single inputs, I knew already. But my question was specifically on getting metafields for multiple resources at once.

I doubt that it refers to how many metafields are returned. This would be inconsistent with how all the other paginated endpoints are documented where the number of results can be set with the limit parameter (although not documented in the API reference, this endpoint does in fact accept the limit parameter as described here: https://shopify.dev/docs/api/usage/pagination-rest).
Also it just doesn’t make sense to put how many results would be returned under parameters unless its documenting a parameter that defines how many results are returned.

No. You are completely misunderstanding what limit does.

When you make a request to an endpoint that supports paginated results, you can set the number of results to return per page using the limit parameter. If you don't specify a limit, then the endpoint will use its default page limit. You can also set other parameters in this request to narrow down your results.

Limit deals specifically with pagination. The is just informing you that you are limited to 100 meta fields that are retrieved. This is to prevent people from slowing down Shopify’s platform with super large unnecessary requests.

No, I don’t think I am misunderstanding (I am already using the limit parameter in many places) and what you just wrote doesn’t conflict with what I wrote.

The reason I brought up the limit parameter is to say that your suggestion that the API reference writing metafield[owner_id] ≤ 100 might simply be specifying how many metafields will (maximally) be returned in a request would conflict with how this behaviour is documented elsewhere. In other endpoints they use the limit parameter to show that you will maximally get 50 results in a request - but you can get up to 250 if you adjust the limit parameter. My point was: wouldn’t they just document it in this same way if it worked like you theorized? Anyway, as I wrote before this limit param also work on the endpoint in question where it can be set to 101 and it still works just fine returning 101 metafields - solidifying that 100 isn’t the upper limit of items that can be returned as you suggested. But setting it to 251 will return an error of “Limit exceeds maximum limit of 250”.

@ShopifyDevSup you around? Lol

@ShopifyDevSup sorry to ping you again.

I would really appreciate if you could take a look at this endpoint and tell me if you think it is supposed to return metafields for multiple resources in a single call, and if so how the request needs to look like.