The Admin API client provides both GraphQL and REST interfaces for interacting with the Shopify Admin API.
createAdminApiClient()
Creates a GraphQL client for the Shopify Admin API.
import { createAdminApiClient } from '@shopify/shopify-app-js' ;
const client = createAdminApiClient ({
storeDomain: 'my-store.myshopify.com' ,
apiVersion: '2025-10' ,
accessToken: 'shpat_xxxxx' ,
});
Parameters
The Shopify store domain (e.g., my-store.myshopify.com)
The Admin API version to use (e.g., 2025-10)
Admin API access token for authentication
Optional prefix to add to the User-Agent header
Number of retry attempts for failed requests
Custom fetch implementation (defaults to global fetch)
Logger function for debugging and monitoring requests
Set to true to skip server-side usage validation during testing
Returns
Admin API client instance with the following properties: Read-only configuration object containing:
storeDomain: The normalized store URL
apiVersion: The API version in use
accessToken: The access token
headers: Default headers for all requests
apiUrl: The complete API endpoint URL
userAgentPrefix: Optional user agent prefix
Returns merged headers combining default headers with optional overrides
getApiUrl
(apiVersion?: string) => string
Returns the API URL, optionally for a different API version
Low-level fetch method that returns a raw Response object const response = await client . fetch ( query , {
variables: { id: 'gid://shopify/Product/123' },
});
GraphQL request method that returns parsed response data const { data , errors } = await client . request ( query , {
variables: { id: 'gid://shopify/Product/123' },
});
Client Methods
fetch()
Executes a GraphQL operation and returns the raw response.
const response = await client . fetch (
`query getProduct($id: ID!) {
product(id: $id) {
id
title
}
}` ,
{
variables: { id: 'gid://shopify/Product/123' },
}
);
GraphQL query or mutation string
Request options:
variables: GraphQL variables object
headers: Additional headers to merge with defaults
apiVersion: Override the default API version
retries: Override the default retry count
signal: AbortSignal for request cancellation
request()
Executes a GraphQL operation and returns parsed response data.
const { data , errors } = await client . request (
`mutation productUpdate($input: ProductInput!) {
productUpdate(input: $input) {
product { id title }
userErrors { field message }
}
}` ,
{
variables: {
input: {
id: 'gid://shopify/Product/123' ,
title: 'New Title' ,
},
},
}
);
Returns a ClientResponse<TData> object:
The GraphQL response data
Error information if the request failed:
networkStatusCode: HTTP status code
message: Error message
graphQLErrors: Array of GraphQL errors
response: Raw Response object
GraphQL extensions from the response
Example Usage
Basic Query
With Variables
Mutation
With Custom Headers
With Retries
import { createAdminApiClient } from '@shopify/shopify-app-js' ;
const client = createAdminApiClient ({
storeDomain: 'my-store.myshopify.com' ,
apiVersion: '2025-10' ,
accessToken: process . env . SHOPIFY_ADMIN_TOKEN ,
});
const { data , errors } = await client . request (
`query {
shop {
name
email
}
}`
);
if ( errors ) {
console . error ( 'GraphQL errors:' , errors );
} else {
console . log ( 'Shop name:' , data . shop . name );
}
Type Safety
The Admin API client supports TypeScript type generation for full type safety. See the API Codegen guide for details.
import { createAdminApiClient } from '@shopify/shopify-app-js' ;
import type { AdminQueries } from './generated/admin.types' ;
const client = createAdminApiClient < AdminQueries >({
storeDomain: 'my-store.myshopify.com' ,
apiVersion: '2025-10' ,
accessToken: process . env . SHOPIFY_ADMIN_TOKEN ,
});
// TypeScript will now provide autocomplete and type checking
const { data } = await client . request ( 'GetProduct' , {
variables: { id: 'gid://shopify/Product/123' },
});