New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@shopify/shopify-api

Package Overview
Dependencies
Maintainers
19
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/shopify-api

Shopify TypeScript API to support core API functionality (auth, graphql proxy, webhooks)

  • 0.5.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
68K
decreased by-36.22%
Maintainers
19
Weekly downloads
 
Created

What is @shopify/shopify-api?

@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.

What are @shopify/shopify-api's main functionalities?

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}`);
  }
});

Other packages similar to @shopify/shopify-api

FAQs

Package last updated on 18 Feb 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc