--- title: Admin API description: >- Contains objects used to interact with the Admin API. This object is returned as part of different contexts, such as [`admin`](/docs/api/shopify-app-remix/authenticate/admin), [`unauthenticated.admin`](/docs/api/shopify-app-remix/unauthenticated/unauthenticated-admin), and [`webhook`](/docs/api/shopify-app-remix/authenticate/webhook). api_version: v1 api_name: shopify-app-remix source_url: html: 'https://shopify.dev/docs/api/shopify-app-remix/v1/apis/admin-api' md: 'https://shopify.dev/docs/api/shopify-app-remix/v1/apis/admin-api.md' --- # Admin API Contains objects used to interact with the Admin API. This object is returned as part of different contexts, such as [`admin`](https://shopify.dev/docs/api/shopify-app-remix/authenticate/admin), [`unauthenticated.admin`](https://shopify.dev/docs/api/shopify-app-remix/unauthenticated/unauthenticated-admin), and [`webhook`](https://shopify.dev/docs/api/shopify-app-remix/authenticate/webhook). ## admin Provides utilities that apps can use to make requests to the Admin API. * rest RestClientWithResources\ 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. * graphql GraphQLClient required Methods for interacting with the Shopify Admin GraphQL API ### RestClientWithResources ```ts RemixRestClient & {resources: Resources} ``` ## Examples ### rest ### Examples * #### Using REST resources ##### Description Getting the number of orders in a store using REST resources. ##### /app/shopify.server.ts ```typescript import { shopifyApp } from "@shopify/shopify-app-remix/server"; import { restResources } from "@shopify/shopify-api/rest/admin/2023-07"; const shopify = shopifyApp({ restResources, // ...etc }); export default shopify; export const authenticate = shopify.authenticate; ``` ##### /app/routes/\*\*\\/\*.ts ```typescript import { LoaderArgs, json } from "@remix-run/node"; import { authenticate } from "../shopify.server"; export const loader = async ({ request }: LoaderArgs) => { const { admin, session } = await authenticate.admin(request); return json(admin.rest.resources.Order.count({ session })); }; ``` * #### Performing a GET request to the REST API ##### Description Use \`admin.rest.\\` to make custom requests to the API. ##### /app/shopify.server.ts ```typescript import { shopifyApp } from "@shopify/shopify-app-remix/server"; import { restResources } from "@shopify/shopify-api/rest/admin/2023-04"; const shopify = shopifyApp({ restResources, // ...etc }); export default shopify; export const authenticate = shopify.authenticate; ``` ##### /app/routes/\*\*\\/\*.ts ```typescript import { LoaderArgs, json } from "@remix-run/node"; import { authenticate } from "../shopify.server"; export const loader = async ({ request }: LoaderArgs) => { const { admin, session } = await authenticate.admin(request); const response = await admin.rest.get({ path: "/customers/count.json" }); const customers = await response.json(); return json({ customers }); }; ``` ### graphql ### Examples * #### Querying the GraphQL API ##### Description Use \`admin.graphql\` to make query / mutation requests. ##### Example ```typescript import { ActionArgs } from "@remix-run/node"; import { authenticate } from "../shopify.server"; export async function action({ request }: ActionArgs) { 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({ data: productData.data }); } ``` ## Related [Authenticate requests from Shopify Admin. - Authenticated context](https://shopify.dev/docs/api/shopify-app-remix/authenticate/admin) [Interact with the Admin API on non-Shopify requests. - Unauthenticated context](https://shopify.dev/docs/api/shopify-app-remix/unauthenticated/unauthenticated-admin)