Version: 2024-10
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Storefront-Access-Token: {storefront_access_token}' \\\n-d '{\n\"query\": \"query getProductById($id: ID!) { product(id: $id) { title } }\"\n}'\n" Node example: "const client = new shopify.clients.Storefront({\n domain: 'your-development-store.myshopify.com',\n storefrontAccessToken,\n});\nconst data = await client.query({\n data: `query getProductById($id: ID!) {\n product(id: $id) {\n title\n }\n }`,\n});\n" Ruby example: null PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new ShopifyClientsStorefront(\"your-development-store.myshopify.com\", $storefrontAccessToken);\n$query = <<<QUERY\n query getProductById($id: ID!) {\n product(id: $id) {\n title\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" Remix example: "const { storefront } = await unauthenticated.storefront(\n 'your-development-store.myshopify.com'\n);\n\nconst response = await storefront.graphql(\n `#graphql\n query getProductById($id: ID!) {\n product(id: $id) {\n title\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query getProductById($id: ID!) {\n product(id: $id) {\n title\n }\n}"
input: null
response: { "data": { "product": { "title": "Camper Van" } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Storefront-Access-Token: {storefront_access_token}' \\\n-d '{\n\"query\": \"query getProductMedia($id: ID!) { product(id: $id) { id media(first: 10) { edges { node { mediaContentType alt ...mediaFieldsByType } } } } } fragment mediaFieldsByType on Media { ... on ExternalVideo { id embeddedUrl } ... on MediaImage { image { url } } ... on Model3d { sources { url mimeType format filesize } } ... on Video { sources { url mimeType format height width } } }\"\n}'\n" Node example: "const client = new shopify.clients.Storefront({\n domain: 'your-development-store.myshopify.com',\n storefrontAccessToken,\n});\nconst data = await client.query({\n data: `query getProductMedia($id: ID!) {\n product(id: $id) {\n id\n media(first: 10) {\n edges {\n node {\n mediaContentType\n alt\n ...mediaFieldsByType\n }\n }\n }\n }\n }\n \n fragment mediaFieldsByType on Media {\n ... on ExternalVideo {\n id\n embeddedUrl\n }\n ... on MediaImage {\n image {\n url\n }\n }\n ... on Model3d {\n sources {\n url\n mimeType\n format\n filesize\n }\n }\n ... on Video {\n sources {\n url\n mimeType\n format\n height\n width\n }\n }\n }`,\n});\n" Ruby example: null PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new ShopifyClientsStorefront(\"your-development-store.myshopify.com\", $storefrontAccessToken);\n$query = <<<QUERY\n query getProductMedia($id: ID!) {\n product(id: $id) {\n id\n media(first: 10) {\n edges {\n node {\n mediaContentType\n alt\n ...mediaFieldsByType\n }\n }\n }\n }\n }\n \n fragment mediaFieldsByType on Media {\n ... on ExternalVideo {\n id\n embeddedUrl\n }\n ... on MediaImage {\n image {\n url\n }\n }\n ... on Model3d {\n sources {\n url\n mimeType\n format\n filesize\n }\n }\n ... on Video {\n sources {\n url\n mimeType\n format\n height\n width\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" Remix example: "const { storefront } = await unauthenticated.storefront(\n 'your-development-store.myshopify.com'\n);\n\nconst response = await storefront.graphql(\n `#graphql\n query getProductMedia($id: ID!) {\n product(id: $id) {\n id\n media(first: 10) {\n edges {\n node {\n mediaContentType\n alt\n ...mediaFieldsByType\n }\n }\n }\n }\n }\n \n fragment mediaFieldsByType on Media {\n ... on ExternalVideo {\n id\n embeddedUrl\n }\n ... on MediaImage {\n image {\n url\n }\n }\n ... on Model3d {\n sources {\n url\n mimeType\n format\n filesize\n }\n }\n ... on Video {\n sources {\n url\n mimeType\n format\n height\n width\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query getProductMedia($id: ID!) {\n product(id: $id) {\n id\n media(first: 10) {\n edges {\n node {\n mediaContentType\n alt\n ...mediaFieldsByType\n }\n }\n }\n }\n}\n\nfragment mediaFieldsByType on Media {\n ... on ExternalVideo {\n id\n embeddedUrl\n }\n ... on MediaImage {\n image {\n url\n }\n }\n ... on Model3d {\n sources {\n url\n mimeType\n format\n filesize\n }\n }\n ... on Video {\n sources {\n url\n mimeType\n format\n height\n width\n }\n }\n}"
input: null
response: { "data": { "product": { "id": "gid://shopify/Product/929898465", "media": { "edges": [ { "node": { "mediaContentType": "IMAGE", "alt": "", "image": { "url": "https://cdn.shopify.com/s/files/1/0003/2595/3821/products/draft58.jpg?v=1683592994" } } }, { "node": { "mediaContentType": "IMAGE", "alt": "", "image": { "url": "https://cdn.shopify.com/s/files/1/0003/2595/3821/products/draft59.jpg?v=1683592994" } } } ] } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Storefront-Access-Token: {storefront_access_token}' \\\n-d '{\n\"query\": \"query ProductPricing @inContext(country: CA) { product(handle: \\\"wool-sweater\\\") { variants(first: 1) { nodes { price { amount currencyCode } } } } }\"\n}'\n" Node example: "const client = new shopify.clients.Storefront({\n domain: 'your-development-store.myshopify.com',\n storefrontAccessToken,\n});\nconst data = await client.query({\n data: `query ProductPricing @inContext(country: CA) {\n product(handle: \"wool-sweater\") {\n variants(first: 1) {\n nodes {\n price {\n amount\n currencyCode\n }\n }\n }\n }\n }`,\n});\n" Ruby example: null PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new ShopifyClientsStorefront(\"your-development-store.myshopify.com\", $storefrontAccessToken);\n$query = <<<QUERY\n query ProductPricing @inContext(country: CA) {\n product(handle: \"wool-sweater\") {\n variants(first: 1) {\n nodes {\n price {\n amount\n currencyCode\n }\n }\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" Remix example: "const { storefront } = await unauthenticated.storefront(\n 'your-development-store.myshopify.com'\n);\n\nconst response = await storefront.graphql(\n `#graphql\n query ProductPricing @inContext(country: CA) {\n product(handle: \"wool-sweater\") {\n variants(first: 1) {\n nodes {\n price {\n amount\n currencyCode\n }\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query ProductPricing @inContext(country: CA) {\n product(handle: \"wool-sweater\") {\n variants(first: 1) {\n nodes {\n price {\n amount\n currencyCode\n }\n }\n }\n }\n}"
input: null
response: { "data": { "product": { "variants": { "nodes": [ { "price": { "amount": "90.0", "currencyCode": "CAD" } } ] } } }, "extensions": { "context": { "country": "CA", "language": "EN" } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Storefront-Access-Token: {storefront_access_token}' \\\n-d '{\n\"query\": \"query ProductTitle @inContext(country: CA, language: FR) { product(handle: \\\"wool-sweater\\\") { title description } }\"\n}'\n" Node example: "const client = new shopify.clients.Storefront({\n domain: 'your-development-store.myshopify.com',\n storefrontAccessToken,\n});\nconst data = await client.query({\n data: `query ProductTitle @inContext(country: CA, language: FR) {\n product(handle: \"wool-sweater\") {\n title\n description\n }\n }`,\n});\n" Ruby example: null PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new ShopifyClientsStorefront(\"your-development-store.myshopify.com\", $storefrontAccessToken);\n$query = <<<QUERY\n query ProductTitle @inContext(country: CA, language: FR) {\n product(handle: \"wool-sweater\") {\n title\n description\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" Remix example: "const { storefront } = await unauthenticated.storefront(\n 'your-development-store.myshopify.com'\n);\n\nconst response = await storefront.graphql(\n `#graphql\n query ProductTitle @inContext(country: CA, language: FR) {\n product(handle: \"wool-sweater\") {\n title\n description\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query ProductTitle @inContext(country: CA, language: FR) {\n product(handle: \"wool-sweater\") {\n title\n description\n }\n}"
input: null
response: { "data": { "product": { "title": "Chandail en laine", "description": "C’est très chaud!" } }, "extensions": { "context": { "country": "CA", "language": "FR" } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Storefront-Access-Token: {storefront_access_token}' \\\n-d '{\n\"query\": \"query Products @inContext(country: GB) { woolSweater: product(handle: \\\"wool-sweater\\\") { title } alarmClock: product(handle: \\\"alarm-clock\\\") { title } products(first: 2) { nodes { title } } }\"\n}'\n" Node example: "const client = new shopify.clients.Storefront({\n domain: 'your-development-store.myshopify.com',\n storefrontAccessToken,\n});\nconst data = await client.query({\n data: `query Products @inContext(country: GB) {\n woolSweater: product(handle: \"wool-sweater\") {\n title\n }\n alarmClock: product(handle: \"alarm-clock\") {\n title\n }\n products(first: 2) {\n nodes {\n title\n }\n }\n }`,\n});\n" Ruby example: null PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new ShopifyClientsStorefront(\"your-development-store.myshopify.com\", $storefrontAccessToken);\n$query = <<<QUERY\n query Products @inContext(country: GB) {\n woolSweater: product(handle: \"wool-sweater\") {\n title\n }\n alarmClock: product(handle: \"alarm-clock\") {\n title\n }\n products(first: 2) {\n nodes {\n title\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" Remix example: "const { storefront } = await unauthenticated.storefront(\n 'your-development-store.myshopify.com'\n);\n\nconst response = await storefront.graphql(\n `#graphql\n query Products @inContext(country: GB) {\n woolSweater: product(handle: \"wool-sweater\") {\n title\n }\n alarmClock: product(handle: \"alarm-clock\") {\n title\n }\n products(first: 2) {\n nodes {\n title\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query Products @inContext(country: GB) {\n woolSweater: product(handle: \"wool-sweater\") {\n title\n }\n alarmClock: product(handle: \"alarm-clock\") {\n title\n }\n products(first: 2) {\n nodes {\n title\n }\n }\n}"
input: null
response: { "data": { "woolSweater": { "title": "Wool sweater" }, "alarmClock": null, "products": { "nodes": [ { "title": "Wool sweater" } ] } }, "extensions": { "context": { "country": "GB", "language": "EN" } } }