productByIdentifier
Requires access scope.
Return a product by an identifier.
Arguments
- Anchor to identifieridentifier•Product
Identifier requiredInput! The identifier of the product.
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.
- Find a product by custom id
- Find a product by handle
Examples
query($identifier: ProductIdentifierInput!) {
product: productByIdentifier(identifier: $identifier) {
id
handle
title
}
}
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($identifier: ProductIdentifierInput!) { product: productByIdentifier(identifier: $identifier) { id handle title } }",
"variables": {
"identifier": {
"customId": {
"namespace": "custom",
"key": "id",
"value": "1001"
}
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query($identifier: ProductIdentifierInput!) {
product: productByIdentifier(identifier: $identifier) {
id
handle
title
}
}`,
{
variables: {
"identifier": {
"customId": {
"namespace": "custom",
"key": "id",
"value": "1001"
}
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query($identifier: ProductIdentifierInput!) {
product: productByIdentifier(identifier: $identifier) {
id
handle
title
}
}`,
"variables": {
"identifier": {
"customId": {
"namespace": "custom",
"key": "id",
"value": "1001"
}
}
},
},
});
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($identifier: ProductIdentifierInput!) {
product: productByIdentifier(identifier: $identifier) {
id
handle
title
}
}
QUERY
variables = {
"identifier": {
"customId": {
"namespace": "custom",
"key": "id",
"value": "1001"
}
}
}
response = client.query(query: query, variables: variables)