Skip to Content

product

Get a single product by ID.

Query Structure

query { product(id: ID!) { handle minQuantity maxQuantity seoDescription seoTitle seoKeywords id combinedListing { # See CombinedListing object for fields } firstAvailableVariant { # See ProductVariant object for fields } hasOnlyDefaultVariant variants { # See ProductVariant object for fields } options optionsWithValues { # See ProductOption object for fields } optionsByHandle { # See ProductOption object for fields } defaultOrSelectedVariant { # See ProductVariant object for fields } tags customFields { # See CustomField object for fields } inPreview isAvailable isDirectlyBuyable title manufacturer { # See Manufacturer object for fields } shortDescription description compatible { # See Product object for fields } similar { # See Product object for fields } related { # See Product object for fields } deliverer { # See Deliverer object for fields } productGroups { # See ProductGroup object for fields } returnPolicyTimeLimit rating reviewCount maxRating reviews { # See Review object for fields } attachments { # See Attachment object for fields } reviewsAreEnabled reviewsRequireAccount reviewsRequirePurchase reviewsRequireApproval taxonomy { # See ProductTaxonomy object for fields } createdAt updatedAt rate inCustomersWishlist customerHasReviewed customerCanReview customerHasPurchased } }

Arguments

ArgumentTypeDescriptionRequiredDefault
idID!The ID of the product to retrieveYesNone

Return Type

Type: Product

Describes a product with the following fields:

FieldTypeDescription
handleStringReturns the handle.
minQuantityIntReturns the minimum quantity that can be bought.
maxQuantityIntReturns the maximum quantity that can be bought.
seoDescriptionStringReturns description for search engines.
seoTitleStringReturns title for search engines.
seoKeywordsStringReturns keywords for search engines.
idIntReturns the id.
combinedListingCombinedListingReturns the combined listing object.
firstAvailableVariantProductVariantReturns the first available variant.
hasOnlyDefaultVariantBooleanReturns true if product has only default variant.
variants[ProductVariant]Returns the product variants.
options[String]Returns the options handles.
optionsWithValues[ProductOption]Returns array of product options with values.
optionsByHandle[ProductOption]Returns array of product options indexed by handle.
defaultOrSelectedVariantProductVariantReturns the selected variant or the default one if none is selected.
tags[String]Returns product tags.
customFields[CustomField]Returns product custom fields as CustomFieldDrop objects.
inPreviewBooleanReturns true if product is in preview.
isAvailableBooleanReturns true if product is available for purchase.
isDirectlyBuyableBooleanReturns true if product can be bought without selecting any attributes.
titleStringReturns the title.
manufacturerManufacturerReturns the manufacturer object.
shortDescriptionStringReturns the short description.
descriptionStringReturns the description.
compatible[Product]Returns compatible products.
similar[Product]Returns similar products.
related[Product]Returns related products.
delivererDelivererReturns the deliverer object.
productGroups[ProductGroup]Returns associated product groups.
returnPolicyTimeLimitIntReturns the product return policy time limit in days.
ratingFloatReturns the rating.
reviewCountIntReturns the review count.
maxRatingIntReturns the maximum rating.
reviews[Review]Returns the product reviews.
attachments[Attachment]Returns the product attachments as AttachmentDrop objects.
reviewsAreEnabledBooleanReturns true if reviews are enabled for this product.
reviewsRequireAccountBooleanReturns true if creating a review requires an account.
reviewsRequirePurchaseBooleanReturns true if product must be purchased before review can be made.
reviewsRequireApprovalBooleanReturns true if reviews are approved before published.
taxonomyProductTaxonomyReturns the product taxonomy.
createdAtStringReturns the creation date.
updatedAtStringReturns the last updated date.
rateStringReturns the tax rate.
inCustomersWishlistStringReturns true if product is in customer’s wishlist.
customerHasReviewedStringReturns true if customer has reviewed the product.
customerCanReviewStringReturns true if customer can review the product.
customerHasPurchasedStringReturns true if customer has purchased the product.

Examples

Basic Query

query { product(id: 12345) { id title description isAvailable } }

Advanced Query

query { product(id: 12345) { id title handle seoTitle seoDescription minQuantity maxQuantity isAvailable isDirectlyBuyable tags rating reviewCount variants { id title sku price available } manufacturer { id name } reviewsAreEnabled reviewsRequireAccount reviewsRequirePurchase reviewsRequireApproval reviews { id rating title content createdAt } productGroups { id name description } createdAt updatedAt } }

Field Selection

query { product(id: 12345) { id title options optionsWithValues { id name values } defaultOrSelectedVariant { id sku price available } attachments { id url title } } }

cURL Example

curl -X POST https://www.mystoreurl.com/graphql/0.8.0/ \ -H "Content-Type: application/json" \ -d '{"query":"query { product(id: 12345) { id title description isAvailable } }"}'

JavaScript Example

async function fetchProduct(productId) { const query = ` query { product(id: ${productId}) { id title description isAvailable } } `; try { const response = await fetch('https://www.mystoreurl.com/graphql/0.8.0/', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ query }), }); const result = await response.json(); if (result.errors) { console.error('GraphQL errors:', result.errors); return null; } return result.data.product; } catch (error) { console.error('Network error:', error); return null; } } // Usage example fetchProduct(12345).then(product => { if (product) { console.log('Product:', product); } else { console.log('Failed to fetch product.'); } });

Response Format

The response will contain a product object with the requested fields. Example response for a basic query:

{ "data": { "product": { "id": 12345, "title": "Example Product", "description": "This is an example product description.", "isAvailable": true } } }

If the product is not found, product will be null.

Error Handling

Error CodeDescription
BAD_USER_INPUTThe provided id argument is invalid or missing.
NOT_FOUNDNo product found with the specified ID.
INTERNAL_SERVER_ERRORAn unexpected error occurred on the server.
RATE_LIMIT_EXCEEDEDThe client has exceeded the allowed number of requests.

Clients should check for errors in the GraphQL response’s errors array and handle accordingly.

Performance Considerations

  • Limit requested fields to only those needed to reduce response size and improve performance.
  • Avoid requesting deeply nested fields unless necessary.
  • Use pagination on nested lists (e.g., variants, reviews) when supported to reduce payload size.
  • The API enforces rate limiting; clients should implement retry logic with exponential backoff.
  • Responses may be cached by clients or intermediaries; consider cache headers if provided.

Authentication

This API currently does not require authentication. However, authentication requirements may be introduced in future versions. Monitor API updates for any changes to authentication requirements.

Notes

  • The id argument is mandatory and must be a valid product ID.
  • Fields marked as optional may return null if data is not available.
  • Some fields like reviewsRequireAccount and customerHasPurchased provide insight into review and purchase requirements and statuses.
  • Use the defaultOrSelectedVariant field to retrieve the variant that should be displayed or purchased by default.
  • The isDirectlyBuyable field indicates if the product can be purchased without selecting variant options.
  • The API supports rich product data including SEO fields, manufacturer info, attachments, and related products.
Last updated on