Skip to main content
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

storeDomain
string
required
The Shopify store domain (e.g., my-store.myshopify.com)
apiVersion
string
required
The Admin API version to use (e.g., 2025-10)
accessToken
string
required
Admin API access token for authentication
userAgentPrefix
string
Optional prefix to add to the User-Agent header
retries
number
default:"0"
Number of retry attempts for failed requests
customFetchApi
CustomFetchApi
Custom fetch implementation (defaults to global fetch)
logger
ApiClientLogger
Logger function for debugging and monitoring requests
isTesting
boolean
Set to true to skip server-side usage validation during testing

Returns

AdminApiClient
object
Admin API client instance with the following properties:

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' },
  }
);
operation
string
required
GraphQL query or mutation string
options
object
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:
data
TData
The GraphQL response data
errors
ResponseErrors
Error information if the request failed:
  • networkStatusCode: HTTP status code
  • message: Error message
  • graphQLErrors: Array of GraphQL errors
  • response: Raw Response object
extensions
object
GraphQL extensions from the response
headers
Headers
Response headers

Example Usage

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' },
});

Build docs developers (and LLMs) love