SDKs overview
Shopify provides a suite of Software Development Kits (SDKs) and libraries designed to streamline interaction with its platform APIs. These resources abstract away the complexities of HTTP requests, authentication, and response parsing, allowing developers to focus on application logic. The SDKs support both the Shopify Admin REST API for managing store operations and the Shopify Storefront GraphQL API for building custom buyer experiences.
The SDK ecosystem includes officially supported libraries for popular programming languages, alongside community-contributed tools and frameworks. These tools are instrumental for developing custom Shopify applications, integrating third-party services, and building headless commerce solutions using frameworks like Shopify Hydrogen.
Official SDKs by language
Shopify maintains official SDKs for several programming languages, providing consistent interfaces and robust support for interacting with its APIs. These SDKs are actively developed and documented, ensuring compatibility with the latest API versions and features. The following table outlines the key official SDKs:
| Language | Package Name | Primary Use Case | Maturity |
|---|---|---|---|
| Ruby | shopify_api |
Admin API integration, app development | Stable, actively maintained |
| Python | ShopifyAPI |
Admin API integration, scripting | Stable, actively maintained |
| PHP | shopify/shopify-api |
Admin API integration, web applications | Stable, actively maintained |
| Node.js | @shopify/shopify-api |
Admin & Storefront API, app development, webhooks | Stable, actively maintained |
| Java | com.shopify.shopify-api |
Admin API integration, enterprise applications | Stable, actively maintained |
| Go | github.com/Shopify/shopify-api-go |
Admin API integration, high-performance services | Stable, actively maintained |
| GraphQL | @shopify/graphql-codegen |
Storefront API client generation, type safety | Stable, actively maintained |
| React Native | @shopify/react-native-skia |
UI components for mobile apps | Stable, actively maintained |
Each SDK is designed to simplify common API tasks such as authentication with OAuth 2.0, making authenticated requests, handling pagination, and managing webhooks. Developers can find detailed documentation and examples for each official SDK on the Shopify developer documentation portal.
Installation
The installation process for Shopify SDKs typically involves using a language-specific package manager. Before installing an SDK, ensure you have the appropriate language runtime and package manager set up in your development environment.
Node.js SDK
For Node.js projects, use npm or yarn:
npm install @shopify/shopify-api
# or
yarn add @shopify/shopify-api
Ruby SDK
Add the shopify_api gem to your Gemfile and run bundle install:
# Gemfile
gem 'shopify_api'
Then, from your terminal:
bundle install
Python SDK
Install the ShopifyAPI package using pip:
pip install ShopifyAPI
PHP SDK
Install the PHP SDK via Composer:
composer require shopify/shopify-api
Java SDK
If using Maven, add the dependency to your pom.xml:
<dependency>
<groupId>com.shopify</groupId>
<artifactId>shopify-api</artifactId>
<version>X.Y.Z</version> <!-- Replace with the latest version -->
</dependency>
If using Gradle, add to your build.gradle:
implementation 'com.shopify:shopify-api:X.Y.Z' // Replace with the latest version
Go SDK
Use go get to add the Go SDK to your project:
go get github.com/Shopify/shopify-api-go/v2
Quickstart example
This Node.js example demonstrates how to initialize the Shopify API client and fetch a list of products from a Shopify store using the Admin API. This requires an authenticated session, typically established via OAuth during the app installation process.
First, ensure you have installed the Node.js SDK as described in the Installation section.
import { Shopify } from "@shopify/shopify-api";
import "@shopify/shopify-api/rest/unstable_rest_client"; // Required for REST API
// Basic configuration (replace with your actual values)
const API_KEY = process.env.SHOPIFY_API_KEY;
const API_SECRET_KEY = process.env.SHOPIFY_API_SECRET_KEY;
const SCOPES = "read_products,write_products"; // Required scopes
const HOST = "https://your-app-domain.com"; // Your app's host URL
// Initialize Shopify API client
Shopify.Context.initialize({
API_KEY: API_KEY,
API_SECRET_KEY: API_SECRET_KEY,
SCOPES: SCOPES.split(","),
HOST_NAME: HOST.replace(/https:\/\//, ""),
IS_EMBEDDED_APP: false, // Set to true if your app is embedded in Shopify admin
API_VERSION: "2023-10", // Or the latest stable API version
SESSION_STORAGE: new Shopify.Session.MemorySessionStorage(), // Replace with a persistent storage for production
});
// Example: Fetch products using a pre-existing session
// In a real application, the session would come from your database after OAuth flow
async function getProducts(shop, accessToken) {
try {
const client = new Shopify.Clients.Rest(shop, accessToken);
const products = await client.get({
path: 'products',
query: { limit: 5 }
});
console.log("Fetched products:", products.body.products);
return products.body.products;
} catch (error) {
console.error("Error fetching products:", error);
throw error;
}
}
// Example usage (assuming you have a shop domain and access token)
// const shopDomain = "your-shop-name.myshopify.com";
// const shopAccessToken = "shpat_YOUR_ACCESS_TOKEN";
// getProducts(shopDomain, shopAccessToken);
console.log("Shopify API client initialized. Ready to make requests once session is available.");
This quickstart provides a foundational understanding. For a complete application, you would implement the OAuth flow to obtain shopDomain and shopAccessToken, and configure persistent session storage. More advanced examples, including GraphQL API usage and webhook handling, are available in the Shopify Node.js SDK documentation.
Community libraries
Beyond the official SDKs, the Shopify developer community has created various libraries and tools that extend functionality or offer alternative approaches to interacting with the platform. These community-driven resources can range from specific utility functions to full-fledged frameworks, often catering to niche use cases or preferred development patterns.
While not officially supported by Shopify, many community libraries are well-maintained and widely used. Developers often leverage these resources for:
- Front-end frameworks: Libraries that integrate Shopify Storefront API data into popular front-end frameworks like React, Vue, or Angular, beyond what Shopify Hydrogen offers for React.
- Specialized API clients: Clients tailored for specific Shopify APIs (e.g., Fulfillment API, Marketing Events API) that might not have direct official SDK support or require custom wrappers.
- Development tools: CLI tools, testing utilities, or deployment scripts that streamline the Shopify app development lifecycle.
- Language-specific wrappers: SDKs or wrappers for languages not officially supported, or alternative implementations for existing languages that align with specific developer preferences.
When considering a community library, it is advisable to evaluate its active maintenance, community support, and compatibility with current Shopify API versions. Resources like GitHub, npm, and other package repositories are common places to discover these libraries. The Shopify Developer Community forums and Discord channels can also be valuable for finding recommendations and support for community-developed tools.