Quickstart
This guide will help you make your first API request to Shopify using the Admin API Client. We’ll query for a product in just a few lines of code.This quickstart uses the
@shopify/admin-api-client package, which is perfect for simple API access. If you’re building a full Shopify app with OAuth and webhooks, see the choosing a package guide.Prerequisites
Before you begin, you’ll need:- A Shopify store (development or production)
- An Admin API access token with appropriate scopes
- Node.js 18 or higher installed
Installation
Install the Admin API Client package using your preferred package manager:Your First API Request
Create a new file calledindex.js (or index.ts for TypeScript) and add the following code:
Replace Configuration Values
Update
storeDomain with your shop’s myshopify.com domain and accessToken with your Admin API access token.Update the Product ID
Replace the product ID with a valid product ID from your store. You can find product IDs in your Shopify admin.
Understanding the Response
Theclient.request() method returns a normalized response object:
- data - Contains the successful API response
- errors - Contains any network or GraphQL errors
- extensions - Additional metadata like query cost and rate limit info
Using the REST Client
You can also use the REST Admin API client for REST endpoints:Adding TypeScript Types
For full type safety, install the codegen preset to automatically generate types from your queries:.graphqlrc.ts file:
package.json:
#graphql and run npm run graphql-codegen to generate types automatically.
Next Steps
Explore Admin API Client
Learn about all available methods and configuration options
Try Storefront API
Build customer-facing features with the Storefront API
Build a Full App
Add OAuth, webhooks, and session management
Add Type Safety
Generate TypeScript types from your GraphQL operations