- v17.0Latest
- v16.9
- v16.8
- v16.7
- v16.6
- 16.6
- v16.5
- v16.4
- v16.3
- v16.2
- v16.1
- v16.0
- v15.9
- v15.8
- v15.7
- v15.6
- v15.5
- v15.4
- v15.3
- v15.2
- v15.1
- v15.0
- v14.9
- v14.8
- v14.7
- v14.6
- v14.5
- v14.4
- v14.3
- v14.2
- v14.1
- v14.0
- v13.9
- v13.8
- v13.7
- v13.6
- v13.5
- v13.4
- v13.3
- v13.2
- v13.1
- v13.0
- v12.9
- v12.8
- v12.7
- v12.6
- v12.5
- v12.4
- v12.3
- v12.2
- v12.1
- v12.0
- v11.9
- v11.8
- v11.7
- v11.6
- v11.5
- v11.4
- v11.3
- v11.2
- v11.1
- v11.0
- v10.9
- v10.8
- v10.7
- v10.6
- v10.5
- v10.4
- v10.3
- v10.2
- v10.1
- v10.0
- v9.9
- v9.8
- v9.7
- v9.6
- v9.5
- v9.4
- v9.3
- v9.2
- v9.1
- v8.9
- v8.8
- v8.7
- v8.6
- v8.5
- v8.4
- v8.3
- v8.2
- v8.1
- v8.0
- v7.9
- v7.8
- v7.7
- v7.6
- v7.5
- v7.4
- v7.3
- v7.2
- v7.1
- v7.0
- v6.9
- v6.8
- v6.7
- v6.6
- v6.5
- v6.4
- v6.3
- v6.2
- v6,2
- v6.1
- v6.0
- v5.9
- v5.8
- v5.7
- v5.6
- v5.5
- v5.4
- v5.3
- v5.2
- v5.1
- v5.0
- v4.9
- v4.8
- v4.7
- v4.6
- v4.5
- v4.4
- v4.3
- v4.2
- v4.1
- v4.0
- v3.9
- v3.8
- v3.7
- v3.6
- v3.5
- v3.4
- v3.3
- v3.2
- v3.1
- v3.0
- v2.9
- v2.8
- v2.7
- v2.6
- v2.5
- v2.4
- v2.3
- v2.2
- v2.1
- v2.0
- v1.9
- v1.8
- v1.7
- v1.6
- v1.5
- v1.4
- v1.3
- v1.2
- v1.1
- v1.0
Shopify Deno π
Shopify Integration for Deno.
Note:ShopifyAPI
works on any platform, butShopifyApp
is currently exclusive to Deno.
Table of Contents
Overview β
This library provides a smooth integration between Shopify and Deno.
- Use ShopifyAPI for platform-agnostic interactions.
- Leverage ShopifyApp for building Deno-specific applications.
Getting Started π§
Install or import the library via your preferred Deno module management. For more details, please refer to the installation guide.
Application Setup π
Creating Application Instances
This implementation lets you run multiple Shopify applications on the same server effortlessly. Routes are automatically generated.
Example
import { req, res, Server } from "jsr:@hviana/faster";
import { ShopifyAPI, ShopifyApp, WebHookCall } from "jsr:@hviana/shopify-deno";
const server = new Server();
// Define a custom home route for your app
server.get("/my_app_1_index", async (ctx: any, next: any) => {
ctx.res.body = "My Shopify Deno";
await next();
});
// Set up a Deno KV instance (configure your parameters as needed)
const kv = await Deno.openKv(); // Use your custom configuration here
// Instantiate your Shopify app with the necessary options
const shopifyApp1 = new ShopifyApp(
{
kv: kv,
api_key: "79e4871756c98ccf48ac647c724022e1",
api_secret: "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",
scopes: "read_products,read_orders",
host: "https://xxx.ngrok.io", // Do not end with a "/"
namespace: "my_app_1_ns", // Use unique namespaces for multiple apps on the same server
home_route: "/my_path1", // Simple path (query parameters are not allowed)
// This path will receive the "shop" and "session" parameters (e.g., /my_path1?shop=example.myshopify.com&session=...)
webhooks: [ // (Optional) Define your webhooks
{
topic: "orders/create", // Only one webhook per topic is allowed
func: (hook: WebHookCall) => {
// Avoid using await here to prevent Shopify webhook timeouts
console.log(hook.data);
console.log(hook.shop);
},
},
],
},
server,
);
// Start the server on port 80
await server.listen({ port: 80 });
Tip: Check out the
ShopifyAppOptions
type for the full list of available options.
Routes Configuration π
Configure the auto-generated routes in your Shopify admin settings as follows:
App URL:
"host"/"namespace"/install
Allowed Redirection URLs:
"host"/"namespace"/auth "host"/"home_route"
Privacy Policy:
"host"/"namespace"/privacy_policy
Customer Data Request Endpoint:
"host"/"namespace"/webhooks/client_data
Customer Data Erasure Endpoint:
"host"/"namespace"/webhooks/delete_client
Shop Data Erasure Endpoint:
"host"/"namespace"/webhooks/delete_shop
Each webhook is automatically accessible at:
"host"/"namespace"/webhooks/"topic"
Note: The library automatically registers these webhooks with the Shopify API.
API Usage π‘
The library abstracts the communication with Shopify and manages API rate limits seamlessly.
GraphQL Example
const access_token = await shopifyApp1.getAccessToken(shop);
const api = new ShopifyAPI(shop, access_token); // 'shop' is something like "myexampleshop.myshopify.com"
// Execute a GraphQL query to fetch product tags
const data1 = await api.graphQL(`
{
products(first: 10, query:"tag:*(MY_TAG1)*") {
edges {
node {
tags
}
}
}
}
`);
REST GET Request
const data2 = await api.get(`/admin/api/2025-04/script_tags.json`);
REST POST Request
const data3 = await api.post(`/admin/api/2025-04/script_tags.json`, {
"script_tag": {
"event": "onload",
"src": "https://xxx.ngrok.io/myscript.js",
"cache": true,
},
});
StoreFront Call (GraphQL or REST)
Pass true
as the second parameter to indicate a StoreFront call:
await api.graphQL(
`
mutation {
cartCreate(
input: {
lines: [{ quantity: 1, merchandiseId: "gid://shopify/ProductVariant/46983787708666" }]
buyerIdentity: {
email: "henrique@lafort.com.br"
countryCode: BR
deliveryAddressPreferences: [
{ deliveryAddress: { province: "Pinhais", country: "Brazil", zip: "83324500" } }
]
}
}
) {
cart {
checkoutUrl
createdAt
id
...DeliveryGroups @defer
}
userErrors {
field
message
}
}
}
fragment DeliveryGroups on Cart {
deliveryGroups(first: 10, withCarrierRates: true) {
edges {
node {
deliveryOptions {
title
handle
deliveryMethodType
estimatedCost {
amount
}
}
selectedDeliveryOption {
title
handle
deliveryMethodType
estimatedCost {
amount
currencyCode
}
}
}
}
}
}
`,
true,
);
Imports Overview π¦
Include the necessary modules in your project:
import {
ShopifyAPI,
ShopifyApp,
ShopifyAppOptions,
UserTokenFunc,
WebHook,
WebHookCall,
WebHookFunc,
} from "jsr:@hviana/shopify-deno";
import { req, res, Server } from "jsr:@hviana/faster";
Bonus: The
ShopifyAPI
class includes additional abstracted methods (e.g.,includeScripts
,searchTags
) that you might find useful.
About π€
Author: Henrique Emanoel Viana
Profession: Computer Scientist & Web Technology Enthusiast
Contact: +55 (41) 99999-4664
Website: henriqueviana
Improvements and suggestions are always welcome!
Happy Coding! π»β¨