Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@shopify/shopify-api
Advanced tools
Shopify TypeScript API to support core API functionality (auth, graphql proxy, webhooks)
@shopify/shopify-api is an official Node.js library provided by Shopify to interact with the Shopify API. It allows developers to build applications that can integrate with Shopify stores, manage store data, and perform various operations related to e-commerce.
Authentication
This feature allows you to authenticate your application with Shopify using API keys and scopes. The code sample demonstrates how to set up the Shopify object with necessary credentials and scopes.
const { Shopify } = require('@shopify/shopify-api');
const shopify = new Shopify({
apiKey: 'your-api-key',
apiSecretKey: 'your-api-secret',
scopes: ['read_products', 'write_products'],
hostName: 'your-app-hostname',
apiVersion: '2023-01'
});
// Use the shopify object to authenticate requests
REST API Client
This feature provides a REST API client to interact with Shopify's REST API. The code sample shows how to create a REST client and fetch a list of products from a Shopify store.
const { Shopify } = require('@shopify/shopify-api');
const client = new Shopify.Clients.Rest('your-shop-name.myshopify.com', 'your-access-token');
async function getProducts() {
const products = await client.get({
path: 'products'
});
console.log(products.body);
}
getProducts();
GraphQL API Client
This feature provides a GraphQL API client to interact with Shopify's GraphQL API. The code sample demonstrates how to create a GraphQL client and query shop details.
const { Shopify } = require('@shopify/shopify-api');
const client = new Shopify.Clients.Graphql('your-shop-name.myshopify.com', 'your-access-token');
async function getShopDetails() {
const query = `{
shop {
name
primaryDomain {
url
host
}
}
}`;
const response = await client.query({
data: query
});
console.log(response.body.data.shop);
}
getShopDetails();
Webhook Management
This feature allows you to manage webhooks for your Shopify app. The code sample shows how to register a webhook handler for the 'PRODUCTS_CREATE' event.
const { Shopify } = require('@shopify/shopify-api');
const webhook = new Shopify.Webhooks.Registry();
webhook.addHandler('PRODUCTS_CREATE', {
path: '/webhooks/products/create',
webhookHandler: async (topic, shop, body) => {
console.log(`Received webhook: ${topic} for shop: ${shop}`);
}
});
shopify-api-node is a popular Node.js library for interacting with the Shopify API. It provides a simple and flexible interface for making requests to Shopify's REST and GraphQL APIs. Compared to @shopify/shopify-api, it is community-maintained and may not have the same level of official support or updates.
shopify-node-api is another Node.js library for accessing the Shopify API. It offers features for authentication, REST API requests, and webhook handling. While it provides similar functionalities to @shopify/shopify-api, it is less frequently updated and may lack some of the latest features provided by Shopify's official library.
@shopify/shopify-api
This library provides support for TypeScript/JavaScript Shopify apps to access the Shopify Admin API, by making it easier to perform the following actions:
This library can be used in any application that has a Node.js backend, since it doesn't rely on any specific framework—you can include it alongside your preferred stack and only use the features that you need to build your app.
To follow these usage guides, you will need to:
ngrok
URL and the appropriate redirect for your OAuth callback route to your app settingsYou can follow our getting started guide, which will provide instructions on how to create an app using plain Node.js code, or the Express framework. Both examples are written in Typescript.
FAQs
Shopify API Library for Node - accelerate development with support for authentication, graphql proxy, webhooks
The npm package @shopify/shopify-api receives a total of 68,403 weekly downloads. As such, @shopify/shopify-api popularity was classified as popular.
We found that @shopify/shopify-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.