Skip to main content

Admin API
object

Contains objects used to interact with the Admin API.

This object is returned as part of different contexts, such as admin, unauthenticated.admin, and webhook.

Provides utilities that apps can use to make requests to the Admin API.

<Resources>
required

Methods for interacting with the Shopify Admin REST API

There are methods for interacting with individual REST resources. You can also make GET, POST, PUT and DELETE requests should the REST resources not meet your needs.

<AdminOperations>
required

Methods for interacting with the Shopify Admin GraphQL API

Was this section helpful?

Getting the number of orders in a store using REST resources. Visit the Admin REST API references for examples on using each resource.

Anchor to example-performing-a-get-request-to-the-rest-apiPerforming a GET request to the REST API

Use admin.rest.get to make custom requests to make a request to to the customer/count endpoint

Anchor to example-performing-a-post-request-to-the-rest-apiPerforming a POST request to the REST API

Use admin.rest.post to make custom requests to make a request to to the customers.json endpoint to send a welcome email

Was this section helpful?

Using REST resources

import { LoaderFunctionArgs, json } from "@remix-run/node";
import { authenticate } from "../shopify.server";

export const loader = async ({ request }: LoaderFunctionArgs) => {
const {
admin,
session,
} = await authenticate.admin(request);

return json(
admin.rest.resources.Order.count({ session }),
);
};

Use admin.graphql to make query / mutation requests.

Catch GraphqlQueryError errors to see error messages from the API.

Was this section helpful?

Querying the GraphQL API

import { ActionFunctionArgs } from "@remix-run/node";
import { authenticate } from "../shopify.server";

export const action = async ({ request }: ActionFunctionArgs) => {
const { admin } = await authenticate.admin(request);

const response = await admin.graphql(
`#graphql
mutation populateProduct($input: ProductInput!) {
productCreate(input: $input) {
product {
id
}
}
}`,
{
variables: {
input: { title: "Product Name" },
},
},
);

const productData = await response.json();
return json({
productId: productData.data?.productCreate?.product?.id,
});
}