Creates a new library object that provides all features needed for an app to interact with Shopify APIs. Use this function when you set up your app.
import {shopifyApi, ApiVersion, BillingInterval} from '@shopify/shopify-api';
import {restResources} from '@shopify/shopify-api/rest/admin/2022-07';
const shopify = shopifyApi({
apiKey: 'APIKeyFromPartnersDashboard',
apiSecretKey: 'APISecretFromPartnersDashboard',
scopes: ['read_products'],
hostName: 'localhost:4321',
hostScheme: 'http',
apiVersion: ApiVersion.July22,
isEmbeddedApp: true,
isCustomStoreApp: false,
userAgentPrefix: 'Custom prefix',
privateAppStorefrontAccessToken: 'PrivateAccessToken',
customShopDomains: ['*.my-custom-domain.io'],
billing: {
'My plan': {
amount: 5.0,
currencyCode: 'USD',
interval: BillingInterval.OneTime,
},
},
logger: {
log: (severity, message) => {
myAppsLogFunction(severity, message);
},
},
restResources,
future: {
// ...
},
});
string
| ❗ required
API key for the app. You can find it in the Partners Dashboard.
string
| ❗ required
API secret key for the app. You can find it in the Partners Dashboard.
string[] | AuthScopes
| ❗ required
Shopify scopes required for your app.
string
| ❗ required
App host name in the format my-host-name.com
. Do not include the scheme or leading or trailing slashes.
"https" | "http"
| Defaults to "https"
The scheme for your app's public URL. http
is only allowed if your app is running on localhost
.
ApiVersion
| Defaults to LATEST_API_VERSION
API version your app will be querying. E.g. ApiVersion.October22
.
boolean
| Defaults to true
Whether your app will run within the Shopify Admin. Learn more about embedded apps with App Bridge
.
boolean
| Defaults to false
Whether you are building a private app for a store.
string
| Defaults to undefined
Any prefix you wish to include in the User-Agent
for requests made by the library.
string
| Defaults to undefined
Fixed Storefront API access token for private apps.
(RegExp | string)[]
| Defaults to undefined
Use this if you need to allow values other than myshopify.com
.
BillingConfig
| Defaults to undefined
Billing configurations. See documentation for full description.
ShopifyRestResources
Mounts the given REST resources onto the object. Learn more about using REST resources.
Note: Must use the same version as
apiVersion
.
string: boolean
Apps can enable future flags to opt in to new functionality and breaking changes ahead of time.
LoggerConfig
Tweaks the behaviour of the package's internal logging to make it easier to debug applications.
() => Promise<void>
Async callback function used for logging, which takes in a LogSeverity
value and a formatted message
. Defaults to using console
calls matching the severity parameter.
LogSeverity
| Defaults to LogSeverity.Info
Minimum severity for which to trigger the log function.
boolean
| Defaults to false
Whether to log ALL HTTP requests made by the package.
Note: Only takes effect if
level
is set toLogSeverity.Debug
.
boolean
| Defaults to false
Whether to add the current timestamp to every logged message.
This function returns an object containing the following properties:
Property | Description |
---|---|
config | The options used to set up the object, containing the parameters of this function. |
auth | Object containing functions to authenticate with Shopify APIs. |
clients | Object containing clients to access Shopify APIs. |
session | Object containing functions to manage Shopify sessions. |
webhooks | Object containing functions to configure and handle Shopify webhooks. |
billing | Object containing functions to enable apps to bill merchants. |
flow | Object containing functions to authenticate Flow extension requests. |
fulfillment service | Object containing functions to authenticate and create fulfillment service requests. |
utils | Object containing general functions to help build apps. |
rest | Object containing OO representations of the Admin REST API. See the API reference documentation for details. |