Anchor to product
product
query
Returns a Product resource by ID.
Anchor to Possible returnsPossible returns
- Anchor to ProductProduct•
The
Product
object lets you manage products in a merchant’s store.Products are the goods and services that merchants offer to customers. They can include various details such as title, description, price, images, and options such as size or color. You can use product variants to create or update different versions of the same product. You can also add or update product media. Products can be organized by grouping them into a collection.
Learn more about working with Shopify's product model, including limitations and considerations.
Was this section helpful?
- Get a metafield attached to a product
- Get a product using the QueryRoot.node field and a GraphQL fragment
- Get all a product's fields and connections
- Get metafields attached to a product
- Get pinned metafield definitions associated with a product
- Get the price range for a product for buyers from Canada
- Get the title, description and online store URL of a product
- Get the total count of inventory in stock of a product
- Loading translations and localizations of a product's title and description
- Query a product and display its variants
- Query whether a product is published in a given country
- Receive a count of all Product Images
- Receive a list of all Product Images
- Retrieve a single product
- Retrieve a specific product listing that is published to your app
- Retrieve media objects
- Retrieves a list of collects
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query ProductMetafield($namespace: String!, $key: String!, $ownerId: ID!) {
product(id: $ownerId) {
linerMaterial: metafield(namespace: $namespace, key: $key) {
value
}
}
}`,
{
variables: {
"namespace": "my_fields",
"key": "liner_material",
"ownerId": "gid://shopify/Product/108828309"
},
},
);
const data = await response.json();
query ProductMetafield($namespace: String!, $key: String!, $ownerId: ID!) {
product(id: $ownerId) {
linerMaterial: metafield(namespace: $namespace, key: $key) {
value
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query ProductMetafield($namespace: String!, $key: String!, $ownerId: ID!) { product(id: $ownerId) { linerMaterial: metafield(namespace: $namespace, key: $key) { value } } }",
"variables": {
"namespace": "my_fields",
"key": "liner_material",
"ownerId": "gid://shopify/Product/108828309"
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query ProductMetafield($namespace: String!, $key: String!, $ownerId: ID!) {
product(id: $ownerId) {
linerMaterial: metafield(namespace: $namespace, key: $key) {
value
}
}
}`,
{
variables: {
"namespace": "my_fields",
"key": "liner_material",
"ownerId": "gid://shopify/Product/108828309"
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query ProductMetafield($namespace: String!, $key: String!, $ownerId: ID!) {
product(id: $ownerId) {
linerMaterial: metafield(namespace: $namespace, key: $key) {
value
}
}
}`,
"variables": {
"namespace": "my_fields",
"key": "liner_material",
"ownerId": "gid://shopify/Product/108828309"
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
query ProductMetafield($namespace: String!, $key: String!, $ownerId: ID!) {
product(id: $ownerId) {
linerMaterial: metafield(namespace: $namespace, key: $key) {
value
}
}
}
QUERY
variables = {
"namespace": "my_fields",
"key": "liner_material",
"ownerId": "gid://shopify/Product/108828309"
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"namespace": "my_fields",
"key": "liner_material",
"ownerId": "gid://shopify/Product/108828309"
}
Response
JSON{
"product": {
"linerMaterial": {
"value": "synthetic leather"
}
}
}