npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sommpicks/sommpicks-shopify

v24.12.19

Published

Shopify REST API & GraphQL calls

Readme

inspira-shopify

Shopify Rest API calls utility

HOW TO USE


npm install --save inspira-shopify

Use shopify rest calls


import ShopifyRest from 'inspira-shopify';


const inspiraShopify = new ShopifyRest('<your shop>.myshopify.com','<shopify token>');

//Override default options
const inspiraShopify = new ShopifyRest('<your shop>.myshopify.com','<shopify token>', {timeout:4000, retries: 3, debug: true, logger: mylogger});

//Create a customer example
inspiraShopify.customer.create(
    {email:'[email protected]', verified_email: true, first_name:'hweweji', last_name:'eqwewwert', phone:'07470874486'})
    .catch((err) => { console.log( err)} )
    .then((result) => { console.log(result)});

Use shopify express Router

Set shopify endpoints for installing your app.


import { Router } from 'inspira-shopify';

...

const app = express();

...

function callback(token, shop, response, err) {
    //manage your shopify token and send response to the client
    if(err) { console.error(err)}
    response.sendFile( ... );
}

app.use('/shopify', new Router( 'secret', 'key', 'scopes', 'app base url', callback).buildRoutes());

Use Hmac utilities.


import { HmacUtils } from 'inspira-shopify';

...

router.post('/<someendpoint>', HmacUtils.jsonWebhookParser, async (req, res) => {
    const isHmacOk = await HmacUtils.checkHmac(req, 'SHOPIFY_SECRET');
    if(!isHmacOk) throw 'Hmac not correct';
    ...
});

...

Cache Shopify Calls


import { RestCacheWrapper } from 'inspira-shopify';

...
private static methodCached = new RestCacheWrapper<Response Type>(<Items to holds in cache>, <Shopify rest method to be cached>);

await methodCached.execute(...args);
...

SHOPIFY REST OPTIONS

  • timeout(ms): timeout while perfoming rest call. Default is 3000.
  • retries: How many times will the call tried. It will retry when it is a network error or a 5xx error.
  • debug: When debug is set to true it will log debug data. You must specify a logger.
  • logger: Logger object used for logging data.

And example of a logger can be:


//using console for building my logger 
const mylogger = {error: console.error, info: console.log};

new ShopifyRest('<your shop>.myshopify.com','<shopify token>', {timeout:4000, retries: 3, debug: true, logger: mylogger})

HOW TO PUBLISH

Push a change with a new version set in package.json and bitbucket pipeline will automatically publish a new npm package.

NOTE: To understand when the version number needs to change refer to npm documentation

Functionalities

  • Customers
    • getInBatch
    • getById
    • getByEmail
    • getByTag
    • getByLastNameContains
    • addAddress
    • removeAddress
    • updateAddress
    • addressAsDefault
    • replacesAddressAsDefault
    • addAddressAsDefault
    • create
    • update
    • get(numOfCustomers)
    • getMetafields
    • getMetafield
    • postMetafield
    • deleteMetafield
    • sendInvite
  • Inventory
    • setItemToTrackable
    • setQuantity
    • getLevel
    • getInventoryItemsOfProduct
    • adjustQuantityOfInventoryItem
    • adjustQuantity
    • setItemCostAndSkuToBe
    • setItemCostToBe
    • getInventoryLevelsOfProduct
  • Draft Order
    • create
    • createAndSendInvoice
    • updateShippingAddress
    • createFromCart
    • fromCartToDraft
  • Order
    • getFulfillments
    • createFulfillments
    • completeFulfillment
    • openFulfillment
    • cancelFulfillment
    • fulfillAllItems
    • getById
    • addAdditionalAttribute
    • setTags
    • getAll
    • getInBatch
    • create
    • applyWeightAndCountryBasedShippingToOrder
    • getShippingByWeight
    • updateShippingAddress
    • getAvailableShippingRatesByAddress
    • getAvailableShippingRatesByCustomerDefaultAddress
    • applyShippingToOrder
    • duplicate
  • OrderRisks
    • getFromOrderById
  • OrderRefunds
    • getOrderRefunds
    • createRefunds
  • Product
    • getAll
    • getByTitle
    • getByHandle
    • getByProductType
    • getById
    • getCount
    • getCountByPusblishedStatus
    • update
    • create
    • delete
    • publish
    • unPublish
    • get(numOfProducts)
    • getMetafields
    • getMetafield
    • saveOrUpdateMetafield
    • saveOrAddToMetafield
    • deleteMetafield
    • deleteMetafieldsByNamespace
    • getUnpublishedInBatch
    • getPublishedInBatchAfterDay
    • getInBatch
  • Variant
    • create
    • update
    • getCount
    • getMetafields
    • saveOrUpdateMetafield
    • getMetafield
    • getById
    • delete
    • deleteMetafieldByKey
    • deleteMetafield
    • deleteMetafieldByKeys
  • Webhook
    • deleteAll
    • delete (By ID)
    • create
    • getAll
    • deleteByTopic
    • updateWebhooksAPI
  • Fulfillment Service
    • create
    • getAll
    • addTrackingInfoToFulfillment
  • Shop
    • ShopDetails
    • getShippingRates
  • Collections
    • create
    • createCollect
    • getAll (limit 250)
    • delete
    • removeCollects (With TimerQueue)
  • Themes
    • getAll (limit 250)
    • getMainTheme (returns null if no theme has been found)
  • Template
    • get
    • put
  • Assets
    • put
  • Locations
    • getAll
  • Pages
    • post
    • put
    • postMetafields
  • Discounts
    • getPercentageDiscountCodeForItem
    • getFixedDiscountCodeForOrder
    • removeDiscount
  • Billing
    • cancelBilling
    • requestBilling
    • getRecurringApplicationCharge
    • getApplicationCharge
    • singlePayment
    • addUsage
  • Shopify express route needed for installing the App.
  • Shopify Hmac validation utilities.
  • Shopify Rest Utils.
  • Cache functionality.