Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
8493c36
[ts] Add id to IOrderShippingLine interface (#525)
zronn Feb 3, 2022
a7f20a2
[dist] 3.8.2
lpinca Feb 3, 2022
baadd6e
[ci] Update actions/setup-node action to v3
lpinca Mar 2, 2022
76779d6
[ci] Update actions/checkout action to v3
lpinca Mar 9, 2022
0bcb125
[api] Add DeprecatedApiCall resource
lpinca Mar 30, 2022
0d4b6c9
[ts] Add private_metafield_namespaces property to webhook types (#530)
kristianpd Apr 2, 2022
d03abc8
[dist] 3.9.0
lpinca Apr 2, 2022
aaa9447
[ci] Do not test on node 17
lpinca May 2, 2022
2fd1eba
[ci] Test on node 18
lpinca May 2, 2022
608345e
[pkg] Update husky to version 8.0.1
lpinca May 16, 2022
498c2a7
[pkg] Update lint-staged to version 13.0.0
lpinca Jun 2, 2022
1da5918
[ts] Fix up ITransaction interface (#540)
tkalliom Jun 21, 2022
0afb707
[dist] 3.9.1
lpinca Jun 21, 2022
279671a
[test] Use a more revealing assertion for leftover nock mocks (#542)
airhorns Jun 23, 2022
69cac59
[doc] Remove broken links
lpinca Jun 24, 2022
cbf9e10
[doc] Update Shopify URLs to avoid redirects
lpinca Jun 24, 2022
be39fd4
[api] Introduce the `maxRetries` option (#541)
airhorns Jun 28, 2022
0188f1f
[minor] Fix nits
lpinca Jun 28, 2022
603a7c0
[dist] 3.10.0
lpinca Jun 28, 2022
32d17cb
[ts] Add maxRetries to I{Private,Public}ShopifyConfig (#546)
leparrav Jul 8, 2022
49a52f7
[dist] 3.10.1
lpinca Jul 8, 2022
f390c9c
[fix] Inspect extensions only if body.errors is an array (#548)
airhorns Jul 14, 2022
b4f059b
[minor] Fix nit
lpinca Jul 14, 2022
419b2ce
[dist] 3.10.2
lpinca Jul 14, 2022
89c48b8
[api] Add setFulfillmentOrdersDeadline action to FulfillmentOrder
lpinca Jul 21, 2022
c936f04
[api] Add DisputeEvidence resource
lpinca Jul 21, 2022
f4f89c4
[api] Add DisputeFileUpload resource
lpinca Jul 21, 2022
9f9a678
[ts] Fix misleading comment
lpinca Jul 21, 2022
bf2c998
[dist] 3.11.0
lpinca Jul 21, 2022
c77cc20
[ts] Add missing webhook topics (#550)
MBogdan18 Sep 2, 2022
e995286
[dist] 3.11.1
lpinca Sep 2, 2022
3dfcd8b
[fix] Respect the maxRetries option (#554)
jasong689 Sep 23, 2022
00c9f86
[minor] Fix nits
lpinca Sep 23, 2022
9fc7192
[dist] 3.11.2
lpinca Sep 23, 2022
0b3484e
[ts] Add missing valuse to fulfillment event status enum (#555)
summersk Sep 30, 2022
fc41cf4
[dist] 3.11.3
lpinca Sep 30, 2022
dcbcd22
[doc] Fix CI badge URL
lpinca Dec 19, 2022
6c2a086
[ts] Add initial_value to IGiftCard interface (#561)
ikudosi Dec 23, 2022
b8de68b
[api] Add cancelV2 action to Fulfillment resource
tkalliom Dec 27, 2022
01f0e7b
[api] Add fulfillments action to FulfillmentOrder resource
tkalliom Dec 27, 2022
c7a85e7
[fix] Ensure that response.body.errors is an array (#564)
summersk Dec 28, 2022
55865bd
[ts] Fix amount type (#565)
summersk Dec 28, 2022
eeda198
[api] Introduce the hooks option (#560)
airhorns Dec 3, 2022
19d3a26
[fix] Ensure that error.response.body is truthy
lpinca Jan 1, 2023
cfafdf1
[dist] 3.12.0
lpinca Jan 1, 2023
6f8c8a3
[fix] Fix got types to properly reference the hooks type
airhorns Jan 3, 2023
a329b5e
[test] Add a light test suite for the typescript types
airhorns Jan 3, 2023
f2109be
[ts] move index.d.ts and index.test-d.ts to the types folder
lpinca Jan 3, 2023
fdbc785
[dist] 3.12.1
lpinca Jan 3, 2023
73007be
[ts] Add missing properties to IFulfillmentOrder (#572)
devlifetimebrands Jan 19, 2023
584d4d0
[ts] Fix delivery_method type (#574)
ikudosi Jan 21, 2023
358f952
[ts] Fix up IShop interface
lpinca Jan 22, 2023
3669aac
[dist] 3.12.2
lpinca Jan 22, 2023
0385fc8
[ts] Add missing statuses (#591)
frostycoles Mar 20, 2023
0b7dc2b
[dist] 3.12.3
lpinca Mar 20, 2023
163fe80
[ci] Test on node 20
lpinca Apr 22, 2023
744af50
[ts] Add checksum to IAsset interface
lpinca May 1, 2023
48928cf
[dist] 3.12.4
lpinca May 1, 2023
479c41f
[ts] Add checkout_token to IOrder interface (#604)
jmustonen May 16, 2023
ef75570
[dist] 3.12.5
lpinca May 16, 2023
b22de83
[ci] Update coverallsapp/github-action action to v2
lpinca Jun 16, 2023
a669e7b
[pkg] Update tsd to version 0.27.0
lpinca Jun 16, 2023
7272847
[doc] Fix broken link (#613)
richgilbank Jul 10, 2023
c36891d
[pkg] Update prettier to version 3.0.0
lpinca Jul 14, 2023
daab990
[pkg] Update eslint-plugin-prettier to version 5.0.0
lpinca Jul 14, 2023
c9dc3d8
[ts] Add missing webhook topics (#621)
colinmollenhour Jul 26, 2023
848b773
[dist] 3.12.6
lpinca Jul 26, 2023
ccaf044
[doc] Fix usage example (#626)
matt-cos Aug 6, 2023
e2a716b
[pkg] Update eslint-config-prettier to version 9.0.0
lpinca Aug 19, 2023
feba071
[pkg] Update lint-staged to version 14.0.1
lpinca Sep 14, 2023
6bd417f
[ci] Update actions/checkout action to v4
lpinca Sep 14, 2023
edf16df
[minor] Improve compatibility with bundlers (#634)
reecefenwick Oct 12, 2023
93d5838
[ts] Add contact_email and total_outstanding to IOrder interface (#635)
dennisdup Oct 12, 2023
c109341
[dist] 3.12.7
lpinca Oct 12, 2023
56c9100
[ci] Update actions/setup-node action to v4
lpinca Dec 7, 2023
398a981
[pkg] Update lint-staged to version 15.2.0
lpinca Dec 7, 2023
a75493b
[codestyle] Ignore ternaries formatting
lpinca Dec 7, 2023
4f02cc9
[api] Introduce the agent option (#643)
Youkehai Jan 13, 2024
92c7d76
[minor] Fix nits
lpinca Jan 13, 2024
6be11b2
[dist] 3.13.0
lpinca Jan 13, 2024
66e2a83
[ts] Add email_marketing_consent to I{,Order}Customer (#646)
patrickyau-visualsquares Feb 8, 2024
b1b40f2
[lint] Fix lint error
lpinca Feb 8, 2024
6e09645
[dist] 3.13.1
lpinca Feb 8, 2024
988162a
Update README.md
alexandresaiz Apr 4, 2024
2f26a41
[lint] Fix lint error
lpinca Apr 6, 2024
78ca9bc
[pkg] Update eslint to version 9.2.0
lpinca May 13, 2024
fd6d034
[ci] Test on node 22
lpinca May 13, 2024
137627e
[ts] Update definitions for I{Cre,Upd}ateArticle (#653)
ryanbalsdon Jun 30, 2024
6b7aad4
[ts] Fix multipass_identifier type (#654)
natewaddoups Jun 30, 2024
19916ac
[dist] 3.13.2
lpinca Jun 30, 2024
6e30c44
[ts] Add current_quantity to IOrderLineItem interface (#656)
peter-visualsquares Jul 9, 2024
47b6bd1
[ts] Add discount_allocations to IFulfillmentLineItem interface
lpinca Jul 9, 2024
159c2e7
[dist] 3.13.3
lpinca Jul 9, 2024
3dbf82a
[ts] Add discount webhook topics (#659)
sleepdotexe Jul 18, 2024
6080d51
[dist] 3.13.4
lpinca Jul 18, 2024
7803fa1
[api] Add hold action to FulfillmentOrder resource (#660)
aldochaconc Aug 20, 2024
dadedd2
[api] Add releaseHold action to FulfillmentOrder resource
lpinca Aug 20, 2024
101cc52
[minor] Fix nits
lpinca Aug 20, 2024
9901908
[api] Add reschedule action to FulfillmentOrder resource
lpinca Aug 20, 2024
715d536
[api] Remove the params argument from FulfillmentOrder#cancel()
lpinca Aug 20, 2024
be6706d
[dist] 3.14.0
lpinca Aug 20, 2024
b253236
[ts] Add confirmation_number to IOrder interface
lpinca Dec 8, 2024
48e23de
[dist] 3.14.1
lpinca Dec 8, 2024
6cf1b53
[fix] Always set the Content-Type header to application/json
infiton Feb 12, 2025
857bfe1
[dist] 3.14.2
lpinca Feb 12, 2025
509912e
[pkg] Update eslint-config-prettier to version 10.1.1
lpinca Apr 5, 2025
e3c0e0b
[pkg] Update globals to version 16.0.0
lpinca Apr 5, 2025
066f84a
[minor] Add error-throwing hook last (#673)
infiton Apr 6, 2025
65f667f
[test] Simplify test
lpinca Apr 6, 2025
c6159df
[dist] 3.15.0
lpinca Apr 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions .eslintrc.yaml

This file was deleted.

15 changes: 9 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ jobs:
- 12
- 14
- 16
- 17
- 18
- 20
- 22
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npm run lint
if: matrix.node == 16
if: matrix.node == 22
- run: npm test
- uses: coverallsapp/github-action@1.1.3
if: matrix.node == 16
- run: npm run test:types
- uses: coverallsapp/github-action@v2
if: matrix.node == 22
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"*.js": "eslint --fix",
"*.{json,md,ts,yml,yaml}": "prettier --write"
"*.{js,json,md,ts,yml,yaml}": "prettier --write"
}
137 changes: 99 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ Creates a new `Shopify` instance.
[OAuth 2.0][oauth] access token. This option is mutually exclusive with the
`apiKey` and `password` options. If you are looking for a premade solution to
obtain an access token, take a look at the [shopify-token][] module.
- `agent` - Optional - An object that is passed as the `agent` option to `got`.
This allows to use a proxy server. See
[Got documentation](https://github.com/sindresorhus/got/tree/v11.8.6?tab=readme-ov-file#proxies)
for more details.
- `apiVersion` - Optional - A string to specify the [Shopify API
version][api-versioning] to use for requests. Defaults to the oldest supported
stable version.
Expand All @@ -52,7 +56,19 @@ Creates a new `Shopify` instance.
bucket size. For example `{ calls: 2, interval: 1000, bucketSize: 35 }`
specifies a limit of 2 requests per second with a burst of 35 requests. When
set to `true` requests are limited as specified in the above example. Defaults
to `false`.
to `false`. Mutually exclusive with the `maxRetries` option.
- `hooks` - Optional - A list of `got`
[request hooks](https://github.com/sindresorhus/got/tree/v11.8.6#hooks) to
attach to all outgoing requests, like `beforeRetry`, `afterResponse`, etc.
Hooks should be provided in the same format that Got expects them and will
receive the same arguments Got passes unchanged.
- `maxRetries` - Optional - The number of times to attempt to make the request
to Shopify before giving up. Defaults to `0`, which means no automatic
retries. If set to a value greater than `0`, `shopify-api-node` will make up
to that many retries. `shopify-api-node` will respect the `Retry-After` header
for requests to the REST API, and the throttled cost data for requests to the
GraphQL API, and retry the request after that time has elapsed. Mutually
exclusive with the `autoLimit` option.
- `parseJson` - Optional - The function used to parse JSON. The function is
passed a single argument. This option allows the use of a custom JSON parser
that might be needed to properly handle long integer IDs. Defaults to
Expand Down Expand Up @@ -220,7 +236,7 @@ shopify.metafield
.create({
key: 'warehouse',
value: 25,
value_type: 'integer',
type: 'integer',
namespace: 'inventory',
owner_resource: 'product',
owner_id: 632910392
Expand Down Expand Up @@ -256,6 +272,35 @@ parameters needed to fetch the next and previous page of results.

This feature is only available on version 2.24.0 and above.

## Shopify rate limit avoidance

`shopify-api-node` has two optional mechanisms for avoiding requests failing
with `429 Rate Limit Exceeded` errors from Shopify.

The `autoLimit` option implements a client side leaky bucket algorithm for
delaying requests until Shopify is likely to accept them. When `autoLimit` is
on, each `Shopify` instance will track how many requests have been made, and
delay sending subsequent requests if the rate limit has been exceeded.
`autoLimit` is very efficient because it almost entirely avoids sending requests
which will return 429 errors, but, it does not coordinate between multiple
`Shopify` instances or across multiple processes. If you're using
`shopify-api-node` in many different processes, `autoLimit` will not correctly
avoid 429 errors.

The `maxRetries` option implements a retry based strategy for getting requests
to Shopify, where when a 429 error occurs, the request is automatically retried
after waiting. Shopify usually replies with a `Retry-After` header indicating to
the client when the rate limit is available, and so `shopify-api-node` will wait
that long before retrying. If you are using `shopify-api-node` in many different
processes, they will all be competing to use the same rate limit shopify
enforces, so there is no guarantee that retrying after the `Retry-After` header
delay will work. It is recommended to set `maxRetries` to a high value like `10`
if you are making many concurrent requests in many processes to ensure each
request is retried for long enough to succeed.

`autoLimit` and `maxRetries` can't be used simultaneously. Both are off by
default.

## Available resources and methods

- accessScope
Expand Down Expand Up @@ -381,6 +426,8 @@ This feature is only available on version 2.24.0 and above.
- `get(id[, params])`
- `list([params])`
- `update(id, params)`
- deprecatedApiCall
- `list()`
- discountCode
- `create(priceRuleId, params)`
- `delete(priceRuleId, id)`
Expand All @@ -395,6 +442,12 @@ This feature is only available on version 2.24.0 and above.
- dispute
- `get(id)`
- `list([params])`
- disputeEvidence
- `get(disputeId)`
- `update(disputeId, params)`
- disputeFileUpload
- `create(disputeId, params)`
- `delete(disputeId, id)`
- draftOrder
- `complete(id[, params])`
- `count()`
Expand All @@ -410,6 +463,7 @@ This feature is only available on version 2.24.0 and above.
- `list([params])`
- fulfillment
- `cancel(orderId, id)`
- `cancelV2(id)`
- `complete(orderId, id)`
- `count(orderId[, params)`
- `create(orderId, params)`
Expand All @@ -426,12 +480,17 @@ This feature is only available on version 2.24.0 and above.
- `list(orderId, fulfillmentId[, params])`
- `update(orderId, fulfillmentId, id, params)`
- fulfillmentOrder
- `cancel(id, params)`
- `cancel(id)`
- `close(id[, message])`
- `fulfillments(id)`
- `get(id)`
- `hold(id, params)`
- `list([params])`
- `locationsForMove(id)`
- `move(id, locationId)`
- `releaseHold(id)`
- `reschedule(id, deadline)`
- `setFulfillmentOrdersDeadline(params)`
- fulfillmentRequest
- `accept(fulfillmentOrderId[, message])`
- `create(fulfillmentOrderId, params)`
Expand All @@ -450,7 +509,7 @@ This feature is only available on version 2.24.0 and above.
- `list([params])`
- `search(params)`
- `update(id, params)`
- [giftCardAdjustment](https://help.shopify.com/en/api/reference/plus/gift_card_adjustment)
- [giftCardAdjustment](https://shopify.dev/api/admin-rest/2022-04/resources/gift-card-adjustment)
- `create(giftCardId, params)`
- `get(giftCardId, id)`
- `list(giftCardId)`
Expand Down Expand Up @@ -545,7 +604,7 @@ This feature is only available on version 2.24.0 and above.
- `get(productId)`
- `list([params])`
- `productIds([params])`
- [productResourceFeedback](https://help.shopify.com/en/api/reference/sales-channels/productresourcefeedback)
- [productResourceFeedback](https://shopify.dev/api/admin-rest/2022-04/resources/product-resourcefeedback)
- `create(productId[, params])`
- `list(productId)`
- productVariant
Expand Down Expand Up @@ -641,8 +700,8 @@ This feature is only available on version 2.24.0 and above.
- `list([params])`
- `update(id, params)`

where `params` is a plain JavaScript object. See
https://help.shopify.com/api/reference?ref=microapps for parameters details.
where `params` is a plain JavaScript object. See the [Rest Admin API
reference][reading-api-docs] for parameters details.

## GraphQL

Expand Down Expand Up @@ -672,10 +731,31 @@ shopify
.catch((err) => console.error(err));
```

## Hooks

`shopify-api-node` supports being passed hooks which are called by `got` (the
underlying HTTP library) during the request lifecycle.

For example, we can log every error that is encountered when using the
`maxRetries` option:

```js
const shopify = new Shopify({
shopName: 'your-shop-name',
accessToken: 'your-oauth-token',
maxRetries: 3,
// Pass the `beforeRetry` hook down to Got.
hooks: {
beforeRetry: [(options, error, retryCount) => console.error(error)]
}
});
```

For more information on the available `got` hooks, see the
[`got` v11 hooks documentation](https://github.com/sindresorhus/got/tree/v11#hooks).

## Become a master of the Shopify ecosystem by:

- [Becoming a Shopify App Developer][becoming-a-shopify-app-developer]
- [Checking out the roots][checking-out-the-roots]
- [Talking To Other Masters][talking-to-other-masters]
- [Reading API Docs][reading-api-docs]
- [Learning from others][learning-from-others]
Expand All @@ -689,19 +769,14 @@ shopify
(add yours!)

- [Sample Node Express app by Shopify][sample-node-express-app-by-shopify]
- [Wholesaler][wholesaler]
- [Wholesaler & Customer Pricing][wholesaler-customer-pricing]
- [Wholesaler PRO][wholesaler-pro]
- [Youtube Traffic][youtube-traffic]
- [Shipatron][shipatron]
- [UPC Code Manager][upc-code-manager]
- [Shopify Passwordless Login][dimension-software]

## Supported by:

[microapps][microapps]

Used in our live products: [MoonMail][moonmail] & [MONEI][monei]
[MONEI][monei]

## License

Expand All @@ -712,39 +787,25 @@ Used in our live products: [MoonMail][moonmail] & [MONEI][monei]
[npm-shopify-api-node-badge]: https://img.shields.io/npm/v/shopify-api-node.svg
[npm-shopify-api-node]: https://www.npmjs.com/package/shopify-api-node
[ci-shopify-api-node-badge]:
https://img.shields.io/github/workflow/status/MONEI/Shopify-api-node/CI/master?label=CI
https://img.shields.io/github/actions/workflow/status/MONEI/Shopify-api-node/ci.yml?branch=master&label=CI
[ci-shopify-api-node]:
https://github.com/MONEI/Shopify-api-node/actions?query=workflow%3ACI+branch%3Amaster
[coverage-shopify-api-node-badge]:
https://img.shields.io/coveralls/MONEI/Shopify-api-node/master.svg
[coverage-shopify-api-node]: https://coveralls.io/github/MONEI/Shopify-api-node
[generate-private-app-credentials]:
https://help.shopify.com/api/guides/api-credentials#generate-private-app-credentials?ref=microapps
[oauth]: https://help.shopify.com/api/guides/authentication/oauth?ref=microapps
https://shopify.dev/apps/auth/basic-http#step-2-generate-api-credentials
[oauth]: https://shopify.dev/apps/auth/oauth
[shopify-token]: https://github.com/lpinca/shopify-token
[api-call-limit]:
https://help.shopify.com/api/guides/api-call-limit/?ref=microapps
[api-versioning]: https://help.shopify.com/en/api/versioning
[becoming-a-shopify-app-developer]:
https://app.shopify.com/services/partners/signup?ref=microapps
[checking-out-the-roots]: https://help.shopify.com/api/guides?ref=microapps
[talking-to-other-masters]:
https://ecommerce.shopify.com/c/shopify-apps?ref=microapps
[reading-api-docs]: https://help.shopify.com/api/reference/?ref=microapps
[api-call-limit]: https://shopify.dev/api/usage/rate-limits
[api-versioning]: https://shopify.dev/api/usage/versioning
[talking-to-other-masters]: https://community.shopify.com/
[reading-api-docs]: https://shopify.dev/api/admin-rest
[learning-from-others]: https://stackoverflow.com/questions/tagged/shopify
[paginated-rest-results]:
https://help.shopify.com/en/api/guides/paginated-rest-results
[paginated-rest-results]: https://shopify.dev/api/usage/pagination-rest
[polaris]: https://polaris.shopify.com/?ref=microapps
[microapps]:
http://microapps.com/?utm_source=shopify-api-node-module-repo-readme&utm_medium=click&utm_campaign=github
[moonmail]:
https://moonmail.io/?utm_source=shopify-api-node-module-repo-readme&utm_medium=click&utm_campaign=github
[monei]:
https://monei.net/?utm_source=shopify-api-node-module-repo-readme&utm_medium=click&utm_campaign=github
[wholesaler]: https://apps.shopify.com/wholesaler?ref=microapps
[wholesaler-customer-pricing]:
https://apps.shopify.com/wholesaler-pro-1?ref=microapps
[wholesaler-pro]: https://apps.shopify.com/wholesaler-pro-2?ref=microapps
https://monei.com/?utm_source=shopify-api-node-module-repo-readme&utm_medium=click&utm_campaign=github
[youtube-traffic]: https://apps.shopify.com/youtube-traffic?ref=microapps
[shipatron]: https://shipatron.io
[upc-code-manager]: https://apps.shopify.com/upc-code-manager-1
Expand Down
24 changes: 24 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';

const pluginPrettierRecommended = require('eslint-plugin-prettier/recommended');
const globals = require('globals');
const js = require('@eslint/js');

module.exports = [
js.configs.recommended,
{
ignores: ['coverage/', 'node_modules/'],
languageOptions: {
ecmaVersion: 'latest',
globals: {
...globals.mocha,
...globals.node
}
},
rules: {
'no-var': 'error',
'prefer-const': 'error'
}
},
pluginPrettierRecommended
];
Loading