Skip to main content
The Admin REST API client provides methods for making REST requests to the Shopify Admin API.

createAdminRestApiClient()

Creates a REST client for the Shopify Admin API with methods for GET, POST, PUT, and DELETE requests.
import { createAdminRestApiClient } from '@shopify/shopify-app-js';

const client = createAdminRestApiClient({
  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
default:"fetch"
Custom fetch implementation (defaults to global fetch)
logger
Logger
Logger function for debugging and monitoring requests
scheme
'https' | 'http'
default:"'https'"
URL scheme to use for requests
defaultRetryTime
number
Default wait time in milliseconds between retry attempts
formatPaths
boolean
default:"true"
Automatically format paths to include /admin/api/{version}/ and .json extension
isTesting
boolean
Set to true to skip server-side usage validation during testing

Returns

AdminRestApiClient
object
REST API client instance with HTTP methods:

Client Methods

get()

Execute a GET request to the Admin REST API.
const response = await client.get('/products', {
  searchParams: {
    limit: 10,
    status: 'active',
  },
});

const products = await response.json();
path
string
required
API endpoint path (e.g., /products or /products/123)When formatPaths is true (default), the path is automatically formatted:
  • /products/admin/api/2025-10/products.json
  • Leading slashes are removed
  • .json extension is added if not present
options
GetRequestOptions
Request options:

post()

Execute a POST request to the Admin REST API.
const response = await client.post('/products', {
  data: {
    product: {
      title: 'New Product',
      body_html: '<p>Product description</p>',
      vendor: 'My Vendor',
    },
  },
});

const newProduct = await response.json();
path
string
required
API endpoint path
options
PostRequestOptions
required
Request options:

put()

Execute a PUT request to the Admin REST API.
const response = await client.put('/products/123', {
  data: {
    product: {
      title: 'Updated Product Title',
    },
  },
});

const updatedProduct = await response.json();
path
string
required
API endpoint path
options
PutRequestOptions
required
Request options (same as POST options)

delete()

Execute a DELETE request to the Admin REST API.
const response = await client.delete('/products/123');

if (response.ok) {
  console.log('Product deleted successfully');
}
path
string
required
API endpoint path
options
DeleteRequestOptions
Request options (same as GET options)

Response Handling

All methods return a standard Response object from the Fetch API. You can parse the response using:
// Parse JSON response
const data = await response.json();

// Get response text
const text = await response.text();

// Check status
if (response.ok) {
  // Status is 2xx
}

// Get headers
const rateLimit = response.headers.get('X-Shopify-Shop-Api-Call-Limit');

Example Usage

import { createAdminRestApiClient } from '@shopify/shopify-app-js';

const client = createAdminRestApiClient({
  storeDomain: 'my-store.myshopify.com',
  apiVersion: '2025-10',
  accessToken: process.env.SHOPIFY_ADMIN_TOKEN,
});

// Get all products
const response = await client.get('/products', {
  searchParams: {
    limit: 50,
    status: 'active',
  },
});

const { products } = await response.json();
console.log(`Found ${products.length} products`);

Path Formatting

By default, the client automatically formats paths:
// With formatPaths: true (default)
client.get('/products');
// → GET https://my-store.myshopify.com/admin/api/2025-10/products.json

// Disable automatic formatting
const client = createAdminRestApiClient({
  storeDomain: 'my-store.myshopify.com',
  apiVersion: '2025-10',
  accessToken: 'token',
  formatPaths: false,
});

client.get('/admin/api/2025-10/products.json');
// → GET https://my-store.myshopify.com/admin/api/2025-10/products.json

Search Parameters

The searchParams option supports:
  • Primitives: strings, numbers, booleans
  • Arrays: converted to key[]=value format
  • Objects: converted to key[nested]=value format
{
  searchParams: {
    limit: 10,                    // → limit=10
    fields: ['id', 'title'],      // → fields[]=id&fields[]=title
    created_at: {
      min: '2024-01-01',          // → created_at[min]=2024-01-01
      max: '2024-12-31',          // → created_at[max]=2024-12-31
    },
  }
}

Types

type SearchParams = Record<string, SearchParamFields>;

type SearchParamFields =
  | string
  | number
  | SearchParamField[]
  | Record<string, SearchParamField | SearchParamField[]>;

type HeaderOptions = Record<string, string | number | string[]>;

interface GetRequestOptions {
  headers?: HeaderOptions;
  searchParams?: SearchParams;
  retries?: number;
  apiVersion?: string;
}

interface PostRequestOptions extends GetRequestOptions {
  data: Record<string, any> | string;
}

interface PutRequestOptions extends PostRequestOptions {}

interface DeleteRequestOptions extends GetRequestOptions {}

Build docs developers (and LLMs) love