Version: 2024-10
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { collectionByHandle(handle: \\\"there is no collection with a handle like this\\\") { id title products(first: 5, reverse: true) { edges { node { id title createdAt priceRangeV2 { minVariantPrice { amount currencyCode } maxVariantPrice { amount currencyCode } } } } } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n collectionByHandle(handle: \"there is no collection with a handle like this\") {\n id\n title\n products(first: 5, reverse: true) {\n edges {\n node {\n id\n title\n createdAt\n priceRangeV2 {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\n amount\n currencyCode\n }\n }\n }\n }\n }\n }\n }`,\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n collectionByHandle(handle: \"there is no collection with a handle like this\") {\n id\n title\n products(first: 5, reverse: true) {\n edges {\n node {\n id\n title\n createdAt\n priceRangeV2 {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\n amount\n currencyCode\n }\n }\n }\n }\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query {\n collectionByHandle(handle: \"there is no collection with a handle like this\") {\n id\n title\n products(first: 5, reverse: true) {\n edges {\n node {\n id\n title\n createdAt\n priceRangeV2 {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\n amount\n currencyCode\n }\n }\n }\n }\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n collectionByHandle(handle: \"there is no collection with a handle like this\") {\n id\n title\n products(first: 5, reverse: true) {\n edges {\n node {\n id\n title\n createdAt\n priceRangeV2 {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\n amount\n currencyCode\n }\n }\n }\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n collectionByHandle(handle: \"there is no collection with a handle like this\") {\n id\n title\n products(first: 5, reverse: true) {\n edges {\n node {\n id\n title\n createdAt\n priceRangeV2 {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\n amount\n currencyCode\n }\n }\n }\n }\n }\n }\n}"
input: null
response: { "data": { "collectionByHandle": null } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { collectionByHandle(handle: \\\"everything\\\") { id title products(first: 5, sortKey: BEST_SELLING) { edges { node { id title priceRangeV2 { minVariantPrice { amount currencyCode } maxVariantPrice { amount currencyCode } } } } } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n collectionByHandle(handle: \"everything\") {\n id\n title\n products(first: 5, sortKey: BEST_SELLING) {\n edges {\n node {\n id\n title\n priceRangeV2 {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\n amount\n currencyCode\n }\n }\n }\n }\n }\n }\n }`,\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n collectionByHandle(handle: \"everything\") {\n id\n title\n products(first: 5, sortKey: BEST_SELLING) {\n edges {\n node {\n id\n title\n priceRangeV2 {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\n amount\n currencyCode\n }\n }\n }\n }\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query {\n collectionByHandle(handle: \"everything\") {\n id\n title\n products(first: 5, sortKey: BEST_SELLING) {\n edges {\n node {\n id\n title\n priceRangeV2 {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\n amount\n currencyCode\n }\n }\n }\n }\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n collectionByHandle(handle: \"everything\") {\n id\n title\n products(first: 5, sortKey: BEST_SELLING) {\n edges {\n node {\n id\n title\n priceRangeV2 {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\n amount\n currencyCode\n }\n }\n }\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n collectionByHandle(handle: \"everything\") {\n id\n title\n products(first: 5, sortKey: BEST_SELLING) {\n edges {\n node {\n id\n title\n priceRangeV2 {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\n amount\n currencyCode\n }\n }\n }\n }\n }\n }\n}"
input: null
response: { "data": { "collectionByHandle": { "id": "gid://shopify/Collection/94229130", "title": "All products more expensive than free", "products": { "edges": [ { "node": { "id": "gid://shopify/Product/108828309", "title": "Draft", "priceRangeV2": { "minVariantPrice": { "amount": "10.0", "currencyCode": "USD" }, "maxVariantPrice": { "amount": "10.0", "currencyCode": "USD" } } } }, { "node": { "id": "gid://shopify/Product/910489600", "title": "Crafty Shoes", "priceRangeV2": { "minVariantPrice": { "amount": "100.0", "currencyCode": "USD" }, "maxVariantPrice": { "amount": "100.0", "currencyCode": "USD" } } } }, { "node": { "id": "gid://shopify/Product/20995642", "title": "Element", "priceRangeV2": { "minVariantPrice": { "amount": "10.0", "currencyCode": "USD" }, "maxVariantPrice": { "amount": "15.0", "currencyCode": "USD" } } } }, { "node": { "id": "gid://shopify/Product/121709582", "title": "Boots", "priceRangeV2": { "minVariantPrice": { "amount": "30.0", "currencyCode": "USD" }, "maxVariantPrice": { "amount": "30.0", "currencyCode": "USD" } } } }, { "node": { "id": "gid://shopify/Product/912855135", "title": "SEO Boots", "priceRangeV2": { "minVariantPrice": { "amount": "35.0", "currencyCode": "USD" }, "maxVariantPrice": { "amount": "35.0", "currencyCode": "USD" } } } } ] } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query getCollectionIdFromHandle($handle: String!) { collectionByHandle(handle: $handle) { id } }\",\n \"variables\": {\n \"handle\": \"ipods\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query getCollectionIdFromHandle($handle: String!) {\n collectionByHandle(handle: $handle) {\n id\n }\n }`,\n \"variables\": {\n \"handle\": \"ipods\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query getCollectionIdFromHandle($handle: String!) {\n collectionByHandle(handle: $handle) {\n id\n }\n }\nQUERY\n\nvariables = {\n \"handle\": \"ipods\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query getCollectionIdFromHandle($handle: String!) {\n collectionByHandle(handle: $handle) {\n id\n }\n }\nQUERY;\n\n$variables = [\n \"handle\" => \"ipods\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query getCollectionIdFromHandle($handle: String!) {\n collectionByHandle(handle: $handle) {\n id\n }\n }`,\n {\n variables: {\n \"handle\": \"ipods\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query getCollectionIdFromHandle($handle: String!) {\n collectionByHandle(handle: $handle) {\n id\n }\n}"
input: { "handle": "ipods" }
response: { "data": { "collectionByHandle": { "id": "gid://shopify/Collection/841564295" } } }