--- title: location - GraphQL Admin description: Returns an inventory Location resource by ID. api_version: 2025-10 api_name: admin type: query api_type: graphql source_url: html: https://shopify.dev/docs/api/admin-graphql/latest/queries/location?example=retrieve-a-single-location-by-its-id md: https://shopify.dev/docs/api/admin-graphql/latest/queries/location.md?example=retrieve-a-single-location-by-its-id --- # location query Returns an inventory Location resource by ID. ## Arguments * id [ID](https://shopify.dev/docs/api/admin-graphql/latest/scalars/ID) The ID of the location to return. If no ID is provided, the primary location of the Shop is returned. *** ## Possible returns * Location [Location](https://shopify.dev/docs/api/admin-graphql/latest/objects/Location) Represents the location where the physical good resides. You can stock inventory at active locations. Active locations that have `fulfills_online_orders: true` and are configured with a shipping rate, pickup enabled or local delivery will be able to sell from their storefront. *** ## Examples * ### Get a metafield attached to a location #### Description Get the metafield value identified by \`my\_fields.hours\` on a specific location. #### Query ```graphql query LocationMetafield($namespace: String!, $key: String!, $ownerId: ID!) { location(id: $ownerId) { hours: metafield(namespace: $namespace, key: $key) { value } } } ``` #### Variables ```json { "namespace": "my_fields", "key": "hours", "ownerId": "gid://shopify/Location/346779380" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query LocationMetafield($namespace: String!, $key: String!, $ownerId: ID!) { location(id: $ownerId) { hours: metafield(namespace: $namespace, key: $key) { value } } }", "variables": { "namespace": "my_fields", "key": "hours", "ownerId": "gid://shopify/Location/346779380" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query LocationMetafield($namespace: String!, $key: String!, $ownerId: ID!) { location(id: $ownerId) { hours: metafield(namespace: $namespace, key: $key) { value } } }`, { variables: { "namespace": "my_fields", "key": "hours", "ownerId": "gid://shopify/Location/346779380" }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby 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 LocationMetafield($namespace: String!, $key: String!, $ownerId: ID!) { location(id: $ownerId) { hours: metafield(namespace: $namespace, key: $key) { value } } } QUERY variables = { "namespace": "my_fields", "key": "hours", "ownerId": "gid://shopify/Location/346779380" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query LocationMetafield($namespace: String!, $key: String!, $ownerId: ID!) { location(id: $ownerId) { hours: metafield(namespace: $namespace, key: $key) { value } } }`, "variables": { "namespace": "my_fields", "key": "hours", "ownerId": "gid://shopify/Location/346779380" }, }, }); ``` #### Response ```json { "location": { "hours": { "value": "Open daily 9AM-5PM" } } } ``` * ### Get metafields attached to a location #### Description Get a page of metafields attached to a specific location. #### Query ```graphql query LocationMetafields($ownerId: ID!) { location(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } } ``` #### Variables ```json { "ownerId": "gid://shopify/Location/346779380" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query LocationMetafields($ownerId: ID!) { location(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } }", "variables": { "ownerId": "gid://shopify/Location/346779380" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query LocationMetafields($ownerId: ID!) { location(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } }`, { variables: { "ownerId": "gid://shopify/Location/346779380" }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby 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 LocationMetafields($ownerId: ID!) { location(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } } QUERY variables = { "ownerId": "gid://shopify/Location/346779380" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query LocationMetafields($ownerId: ID!) { location(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } }`, "variables": { "ownerId": "gid://shopify/Location/346779380" }, }, }); ``` #### Response ```json { "location": { "metafields": { "edges": [ { "node": { "namespace": "my_fields", "key": "hours", "value": "Open daily 9AM-5PM" } } ] } } } ``` * ### Get pinned metafield definitions associated with a location #### Description Get names and types of the first page of pinned metafield definitions associated with a location. #### Query ```graphql query LocationMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) { location(id: $ownerId) { metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) { edges { node { name namespace key type { name } } } } } } ``` #### Variables ```json { "pinnedStatus": "PINNED", "ownerId": "gid://shopify/Location/346779380", "first": 10, "sortKey": "PINNED_POSITION" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query LocationMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) { location(id: $ownerId) { metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) { edges { node { name namespace key type { name } } } } } }", "variables": { "pinnedStatus": "PINNED", "ownerId": "gid://shopify/Location/346779380", "first": 10, "sortKey": "PINNED_POSITION" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query LocationMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) { location(id: $ownerId) { metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) { edges { node { name namespace key type { name } } } } } }`, { variables: { "pinnedStatus": "PINNED", "ownerId": "gid://shopify/Location/346779380", "first": 10, "sortKey": "PINNED_POSITION" }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby 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 LocationMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) { location(id: $ownerId) { metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) { edges { node { name namespace key type { name } } } } } } QUERY variables = { "pinnedStatus": "PINNED", "ownerId": "gid://shopify/Location/346779380", "first": 10, "sortKey": "PINNED_POSITION" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query LocationMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) { location(id: $ownerId) { metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) { edges { node { name namespace key type { name } } } } } }`, "variables": { "pinnedStatus": "PINNED", "ownerId": "gid://shopify/Location/346779380", "first": 10, "sortKey": "PINNED_POSITION" }, }, }); ``` #### Response ```json { "location": { "metafieldDefinitions": { "edges": [ { "node": { "name": "Additional Notes", "namespace": "my_fields", "key": "notes", "type": { "name": "single_line_text_field" } } }, { "node": { "name": "Operating Since", "namespace": "my_fields", "key": "operating_since", "type": { "name": "date" } } } ] } } } ``` * ### Retrieve a list of inventory levels for a location #### Query ```graphql query LocationInventoryLevelList($id: ID!) { location(id: $id) { inventoryLevels(first: 10) { nodes { item { id } location { id } quantities(names: ["available"]) { name quantity } } } } } ``` #### Variables ```json { "id": "gid://shopify/Location/346779380" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query LocationInventoryLevelList($id: ID!) { location(id: $id) { inventoryLevels(first: 10) { nodes { item { id } location { id } quantities(names: [\"available\"]) { name quantity } } } } }", "variables": { "id": "gid://shopify/Location/346779380" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query LocationInventoryLevelList($id: ID!) { location(id: $id) { inventoryLevels(first: 10) { nodes { item { id } location { id } quantities(names: ["available"]) { name quantity } } } } }`, { variables: { "id": "gid://shopify/Location/346779380" }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby 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 LocationInventoryLevelList($id: ID!) { location(id: $id) { inventoryLevels(first: 10) { nodes { item { id } location { id } quantities(names: ["available"]) { name quantity } } } } } QUERY variables = { "id": "gid://shopify/Location/346779380" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query LocationInventoryLevelList($id: ID!) { location(id: $id) { inventoryLevels(first: 10) { nodes { item { id } location { id } quantities(names: ["available"]) { name quantity } } } } }`, "variables": { "id": "gid://shopify/Location/346779380" }, }, }); ``` #### Response ```json { "location": { "inventoryLevels": { "nodes": [ { "item": { "id": "gid://shopify/InventoryItem/113711323" }, "location": { "id": "gid://shopify/Location/346779380" }, "quantities": [ { "name": "available", "quantity": 8 } ] }, { "item": { "id": "gid://shopify/InventoryItem/30322695" }, "location": { "id": "gid://shopify/Location/346779380" }, "quantities": [ { "name": "available", "quantity": 2 } ] } ] } } } ``` * ### Retrieve a single location by its ID #### Query ```graphql query LocationShow($id: ID!) { location(id: $id) { id name fulfillmentService { handle } address { address1 address2 city country countryCode province provinceCode zip } fulfillsOnlineOrders hasActiveInventory isActive } } ``` #### Variables ```json { "id": "gid://shopify/Location/346779380" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query LocationShow($id: ID!) { location(id: $id) { id name fulfillmentService { handle } address { address1 address2 city country countryCode province provinceCode zip } fulfillsOnlineOrders hasActiveInventory isActive } }", "variables": { "id": "gid://shopify/Location/346779380" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query LocationShow($id: ID!) { location(id: $id) { id name fulfillmentService { handle } address { address1 address2 city country countryCode province provinceCode zip } fulfillsOnlineOrders hasActiveInventory isActive } }`, { variables: { "id": "gid://shopify/Location/346779380" }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby 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 LocationShow($id: ID!) { location(id: $id) { id name fulfillmentService { handle } address { address1 address2 city country countryCode province provinceCode zip } fulfillsOnlineOrders hasActiveInventory isActive } } QUERY variables = { "id": "gid://shopify/Location/346779380" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query LocationShow($id: ID!) { location(id: $id) { id name fulfillmentService { handle } address { address1 address2 city country countryCode province provinceCode zip } fulfillsOnlineOrders hasActiveInventory isActive } }`, "variables": { "id": "gid://shopify/Location/346779380" }, }, }); ``` #### Response ```json { "location": { "id": "gid://shopify/Location/346779380", "name": "Ottawa Store", "fulfillmentService": null, "address": { "address1": "126 york street", "address2": "second and third floor", "city": "ottawa", "country": "Canada", "countryCode": "CA", "province": "Ontario", "provinceCode": "ON", "zip": "k1n5t5" }, "fulfillsOnlineOrders": true, "hasActiveInventory": true, "isActive": true } } ``` * ### Returns a Location resource by ID #### Description The following query retrieves the location with the associated ID. It returns the location fields specified in the query. #### Query ```graphql query { location(id: "gid://shopify/Location/346779380") { id name address { formatted } deactivatable fulfillsOnlineOrders hasActiveInventory isActive shipsInventory } } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query { location(id: \"gid://shopify/Location/346779380\") { id name address { formatted } deactivatable fulfillsOnlineOrders hasActiveInventory isActive shipsInventory } }" }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query { location(id: "gid://shopify/Location/346779380") { id name address { formatted } deactivatable fulfillsOnlineOrders hasActiveInventory isActive shipsInventory } }`, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby 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 { location(id: "gid://shopify/Location/346779380") { id name address { formatted } deactivatable fulfillsOnlineOrders hasActiveInventory isActive shipsInventory } } QUERY response = client.query(query: query) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `query { location(id: "gid://shopify/Location/346779380") { id name address { formatted } deactivatable fulfillsOnlineOrders hasActiveInventory isActive shipsInventory } }`, }); ``` #### Response ```json { "location": { "id": "gid://shopify/Location/346779380", "name": "Ottawa Store", "address": { "formatted": [ "126 york street", "second and third floor", "ottawa ON k1n5t5", "Canada" ] }, "deactivatable": true, "fulfillsOnlineOrders": true, "hasActiveInventory": true, "isActive": true, "shipsInventory": false } } ``` [Open in GraphiQL](http://localhost:3457/graphiql?query=query%20LocationShow\(%24id%3A%20ID!\)%20%7B%0A%20%20location\(id%3A%20%24id\)%20%7B%0A%20%20%20%20id%0A%20%20%20%20name%0A%20%20%20%20fulfillmentService%20%7B%0A%20%20%20%20%20%20handle%0A%20%20%20%20%7D%0A%20%20%20%20address%20%7B%0A%20%20%20%20%20%20address1%0A%20%20%20%20%20%20address2%0A%20%20%20%20%20%20city%0A%20%20%20%20%20%20country%0A%20%20%20%20%20%20countryCode%0A%20%20%20%20%20%20province%0A%20%20%20%20%20%20provinceCode%0A%20%20%20%20%20%20zip%0A%20%20%20%20%7D%0A%20%20%20%20fulfillsOnlineOrders%0A%20%20%20%20hasActiveInventory%0A%20%20%20%20isActive%0A%20%20%7D%0A%7D\&variables=%7B%0A%20%20%22id%22%3A%20%22gid%3A%2F%2Fshopify%2FLocation%2F346779380%22%0A%7D) ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query LocationShow($id: ID!) { location(id: $id) { id name fulfillmentService { handle } address { address1 address2 city country countryCode province provinceCode zip } fulfillsOnlineOrders hasActiveInventory isActive } }`, { variables: { "id": "gid://shopify/Location/346779380" }, }, ); const json = await response.json(); return json.data; } ``` ##### GQL ``` query LocationShow($id: ID!) { location(id: $id) { id name fulfillmentService { handle } address { address1 address2 city country countryCode province provinceCode zip } fulfillsOnlineOrders hasActiveInventory isActive } } ``` ##### cURL ``` curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query LocationShow($id: ID!) { location(id: $id) { id name fulfillmentService { handle } address { address1 address2 city country countryCode province provinceCode zip } fulfillsOnlineOrders hasActiveInventory isActive } }", "variables": { "id": "gid://shopify/Location/346779380" } }' ``` ##### React Router ``` import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query LocationShow($id: ID!) { location(id: $id) { id name fulfillmentService { handle } address { address1 address2 city country countryCode province provinceCode zip } fulfillsOnlineOrders hasActiveInventory isActive } }`, { variables: { "id": "gid://shopify/Location/346779380" }, }, ); const json = await response.json(); return json.data; } ``` ##### Node.js ``` const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query LocationShow($id: ID!) { location(id: $id) { id name fulfillmentService { handle } address { address1 address2 city country countryCode province provinceCode zip } fulfillsOnlineOrders hasActiveInventory isActive } }`, "variables": { "id": "gid://shopify/Location/346779380" }, }, }); ``` ##### Ruby ``` 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 LocationShow($id: ID!) { location(id: $id) { id name fulfillmentService { handle } address { address1 address2 city country countryCode province provinceCode zip } fulfillsOnlineOrders hasActiveInventory isActive } } QUERY variables = { "id": "gid://shopify/Location/346779380" } response = client.query(query: query, variables: variables) ``` ## Input variables JSON ```json { "id": "gid://shopify/Location/346779380" } ``` ## Response JSON ```json { "location": { "id": "gid://shopify/Location/346779380", "name": "Ottawa Store", "fulfillmentService": null, "address": { "address1": "126 york street", "address2": "second and third floor", "city": "ottawa", "country": "Canada", "countryCode": "CA", "province": "Ontario", "provinceCode": "ON", "zip": "k1n5t5" }, "fulfillsOnlineOrders": true, "hasActiveInventory": true, "isActive": true } } ```