How to get all metafields despite if they have a value or not using Rest API

Topic summary

Core issue: Request to retrieve all product metafields via Shopify REST Admin API, including those without values. Currently, only metafields that have a value are returned; empty/unset metafields are omitted.

Example: Product has metafield1 = 4 and metafield2 = (no value). The API returns only metafield1; metafield2 is missing.

API context: User references the official Admin REST 2023-10 Metafield endpoints and sets OwnerResource to Product. No code snippets provided.

Recent update: A responder asked where the endpoints are being used (admin app vs storefront) to clarify the execution context, noting that the referenced endpoints are Admin API.

Status: Unresolved. Key open points:

  • Whether the REST Admin API can return metafields that lack values for a product.
  • Confirmation of the environment (admin app or storefront) to diagnose behavior and suggest alternatives.

No decisions or workarounds were provided yet.

Summarized with AI on December 23. AI used: gpt-5.

I am trying to retrieve all metafields when the OwnerResource is set to ‘Product’, but the API only returns metafields that have a value. Metafields without a value are not included in the response.

Example:

Product 1:

  • metafield1 = 4
  • metafield2

Using the REST API, only metafield1 is returned. Metafield2 is not returned in response because it does not have a value.

Can you have a look at this?

Can you explain where you use fetch API

I am using endpoints from shopify official documentation below.

Metafield (shopify.dev)

This is an admin API, and my question is: where do you use these endpoints, on the admin App or the storefront?