Version: 2025-01
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { company(id: \\\"gid://shopify/Company/426793626\\\") { id name note externalId totalSpent { amount currencyCode } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n company(id: \"gid://shopify/Company/426793626\") {\n id\n name\n note\n externalId\n totalSpent {\n amount\n currencyCode\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 company(id: \"gid://shopify/Company/426793626\") {\n id\n name\n note\n externalId\n totalSpent {\n amount\n currencyCode\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 company(id: \"gid://shopify/Company/426793626\") {\n id\n name\n note\n externalId\n totalSpent {\n amount\n currencyCode\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 company(id: \"gid://shopify/Company/426793626\") {\n id\n name\n note\n externalId\n totalSpent {\n amount\n currencyCode\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n company(id: \"gid://shopify/Company/426793626\") {\n id\n name\n note\n externalId\n totalSpent {\n amount\n currencyCode\n }\n }\n}"
input: null
response: { "data": { "company": { "id": "gid://shopify/Company/426793626", "name": "Fancy Pants Inc.", "note": "test notes", "externalId": "external_id1", "totalSpent": { "amount": "120.0", "currencyCode": "USD" } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query CompanyMetafield($namespace: String!, $key: String!, $ownerId: ID!) { company(id: $ownerId) { industry: metafield(namespace: $namespace, key: $key) { value } } }\",\n \"variables\": {\n \"namespace\": \"my_fields\",\n \"key\": \"industry\",\n \"ownerId\": \"gid://shopify/Company/426793626\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query CompanyMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n company(id: $ownerId) {\n industry: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }`,\n \"variables\": {\n \"namespace\": \"my_fields\",\n \"key\": \"industry\",\n \"ownerId\": \"gid://shopify/Company/426793626\"\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 CompanyMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n company(id: $ownerId) {\n industry: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }\nQUERY\n\nvariables = {\n \"namespace\": \"my_fields\",\n \"key\": \"industry\",\n \"ownerId\": \"gid://shopify/Company/426793626\"\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 CompanyMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n company(id: $ownerId) {\n industry: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }\nQUERY;\n\n$variables = [\n \"namespace\" => \"my_fields\",\n \"key\" => \"industry\",\n \"ownerId\" => \"gid://shopify/Company/426793626\",\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 CompanyMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n company(id: $ownerId) {\n industry: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }`,\n {\n variables: {\n \"namespace\": \"my_fields\",\n \"key\": \"industry\",\n \"ownerId\": \"gid://shopify/Company/426793626\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query CompanyMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n company(id: $ownerId) {\n industry: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n}"
input: { "namespace": "my_fields", "key": "industry", "ownerId": "gid://shopify/Company/426793626" }
response: { "data": { "company": { "industry": { "value": "retail" } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query CompanyMetafields($ownerId: ID!) { company(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } }\",\n \"variables\": {\n \"ownerId\": \"gid://shopify/Company/426793626\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query CompanyMetafields($ownerId: ID!) {\n company(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"ownerId\": \"gid://shopify/Company/426793626\"\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 CompanyMetafields($ownerId: ID!) {\n company(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"ownerId\": \"gid://shopify/Company/426793626\"\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 CompanyMetafields($ownerId: ID!) {\n company(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"ownerId\" => \"gid://shopify/Company/426793626\",\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 CompanyMetafields($ownerId: ID!) {\n company(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"ownerId\": \"gid://shopify/Company/426793626\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query CompanyMetafields($ownerId: ID!) {\n company(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n}"
input: { "ownerId": "gid://shopify/Company/426793626" }
response: { "data": { "company": { "metafields": { "edges": [ { "node": { "namespace": "my_fields", "key": "industry", "value": "retail" } } ] } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query CompanyMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) { company(id: $ownerId) { metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) { edges { node { name namespace key type { name } } } } } }\",\n \"variables\": {\n \"pinnedStatus\": \"PINNED\",\n \"ownerId\": \"gid://shopify/Company/426793626\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query CompanyMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n company(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"pinnedStatus\": \"PINNED\",\n \"ownerId\": \"gid://shopify/Company/426793626\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\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 CompanyMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n company(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"pinnedStatus\": \"PINNED\",\n \"ownerId\": \"gid://shopify/Company/426793626\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\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 CompanyMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n company(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"pinnedStatus\" => \"PINNED\",\n \"ownerId\" => \"gid://shopify/Company/426793626\",\n \"first\" => 10,\n \"sortKey\" => \"PINNED_POSITION\",\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 CompanyMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n company(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"pinnedStatus\": \"PINNED\",\n \"ownerId\": \"gid://shopify/Company/426793626\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query CompanyMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n company(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n}"
input: { "pinnedStatus": "PINNED", "ownerId": "gid://shopify/Company/426793626", "first": 10, "sortKey": "PINNED_POSITION" }
response: { "data": { "company": { "metafieldDefinitions": { "edges": [ { "node": { "name": "Website", "namespace": "my_fields", "key": "website", "type": { "name": "single_line_text_field" } } }, { "node": { "name": "Industry", "namespace": "my_fields", "key": "industry", "type": { "name": "single_line_text_field" } } } ] } } } }