- v16.6Latest
- 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.
How to use
This library has an abstraction of the application and the use of the API.
Creating the application instances
This implementation allows several applications in the same server instance in a simple way. Routes are automatically generated.
Example:
import { req, res, Server } from "https://deno.land/x/faster/mod.ts";
import {
ShopifyAPI,
ShopifyApp,
WebHookCall,
} from "https://deno.land/x/shopify_deno/mod.ts";
const server = new Server();
server.get(
"/my_app_1_index", //shopifyApp1 home route
async (ctx: any, next: any) => {
ctx.res.body = "My Shopify Deno";
await next();
},
);
const shopifyApp1 = new ShopifyApp(
{
api_key: "79e4871756c98ccf48ac647c724022e1",
api_secret: "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",
scopes: "read_products,read_orders",
host: "https://xxx.ngrok.io",
namespace: "my_app_1_ns", //you can instantiate different apps on the same server with different namespaces
home_route: "/my_app_1_index",
userTokenFunc: async (shop: string, access_token: string) => { //OPTIONAL
//SAVE shop access_token HERE, for later use.
//need to return url parameters, default is (if userTokenFunc not defined):
return `${access_token}&shop=${shop}`;
},
webhooks: [ //OPTIONAL
{
topic: "orders/create",
func: (data: WebHookCall) => {
//avoid using await here, prevent shopify webhook timeout is important
console.log(data.data);
console.log(data.shop);
},
},
],
},
server,
);
await server.listen({ port: 80 });
See type “ShopifyAppOptions” for full options.
Configure auto renerated routes
In Shopify Configs, configure:
- App URL:
"host"/"namespace"/install
- Allowed redirection URL(s):
"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 placed in (for information only, the library registers automatically with the api):
"host"/"namespace"/webhooks/"topic"
Using the API
This library abstracts the communication and handles the “API rate limit”.
Examples:
const api = new ShopifyAPI(shop, access_token); // 'shop' it's something like myexampleshop.myshopify.com, 'shop' and 'access_token' comes from 'userTokenFunc'
const data1 = await api.graphQL(`
{
products(first: 10, query:"tag:*(MY_TAG1)*"){
edges{
node {
tags
}
}
}
}
`);
const data2 = await api.get(
`/admin/api/2021-01/script_tags.json`,
);
const data3 = await this.post(`/admin/api/2021-01/script_tags.json`, {
"script_tag": {
"event": "onload",
"src": "https://xxx.ngrok.io/myscript.js",
"cache": true,
},
});
All imports
import {
ShopifyAPI,
ShopifyApp,
ShopifyAppOptions,
UserTokenFunc,
WebHook,
WebHookCall,
WebHookFunc,
} from "https://deno.land/x/shopify_deno/mod.ts";
import { req, res, Server } from "https://deno.land/x/faster/mod.ts";
This library has some more abstracted methods for some applications I created, explore the ShopifyAPI class (may be useful for you). Some examples are: “includeScripts” and “searchTags”.
About
Author: Henrique Emanoel Viana, a Brazilian computer scientist, enthusiast of web technologies, cel: +55 (41) 99999-4664. URL: https://sites.google.com/site/henriqueemanoelviana
Improvements and suggestions are welcome!