Skip to main content

How to authenticate with the Shopify API

· 2 min read

I use Node.js. So to programatically connect to Shopify’s Admin API, I use the npm package @shopify/shopify-api. The Admin API supports both GraphQL and REST.

I found the details on how to authenticate using the API was not very obvious though. This is how to do it.

First we need to get an Admin API access token

  1. Login to your Shopify Dashboard.
  2. Go to App and Sales channel settings

app and sales channel settings

  1. Click Develop apps for your store

develop apps for store button

  1. Then create a new app

create app button

  1. And then copy the access token.

api credentials

Using the access token in your code

Let’s go through an example. Let’s say we want to fetch the first three products from the store using GraphQL.

I created a .env file that looks like this


Then we just need to install two libraries

yarn add @shopify/shopify-api dotenv

Then our code will look as follows…

import { Shopify } from '@shopify/shopify-api';
import * as dotenv from 'dotenv';

const test = async () => {
const queryString = `{
products (first: 3) {
edges {
node {

const client = new Shopify.Clients.Graphql(
const products = await client.query({
data: queryString


So in essence, from the Shopify docs on authenticating, you don’t need to figure out the more complex flow of OAuth.