{"id":5475,"library":"shopifyapi","title":"Shopify API Python","description":"The `shopifyapi` library (version 12.7.0) enables Python developers to programmatically access the administrative section of Shopify stores. It provides an ActiveResource-like interface for interacting with both the REST and GraphQL APIs. Shopify releases new API versions quarterly, which often include breaking changes that developers need to anticipate and manage in their integrations.","status":"active","version":"12.7.0","language":"en","source_language":"en","source_url":"https://github.com/Shopify/shopify_python_api","tags":["ecommerce","shopify","api","admin","rest","graphql"],"install":[{"cmd":"pip install ShopifyAPI","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core dependency for ActiveResource-like interface.","package":"pyactiveresource","optional":false}],"imports":[{"note":"The main library is imported as 'shopify'.","symbol":"shopify","correct":"import shopify"},{"note":"Used for establishing API connection.","symbol":"Session","correct":"from shopify import Session"},{"note":"Used for activating the API session.","symbol":"ShopifyResource","correct":"from shopify import ShopifyResource"}],"quickstart":{"code":"import os\nimport shopify\n\n# --- Configuration from Environment Variables ---\n# For a Private App, you need API Key and Password\nSHOPIFY_API_KEY = os.environ.get('SHOPIFY_API_KEY', 'your_api_key')\nSHOPIFY_PASSWORD = os.environ.get('SHOPIFY_PASSWORD', 'your_password')\nSHOPIFY_SHOP_NAME = os.environ.get('SHOPIFY_SHOP_NAME', 'your-shop-name') # e.g., 'my-awesome-store'\nSHOPIFY_API_VERSION = os.environ.get('SHOPIFY_API_VERSION', '2024-07') # Use a stable, supported API version\n\n# Construct the shop URL for a private app\nshop_url = f\"https://{SHOPIFY_API_KEY}:{SHOPIFY_PASSWORD}@{SHOPIFY_SHOP_NAME}.myshopify.com/admin\"\n\n# Set up the API session\nshopify.ShopifyResource.set_site(shop_url)\nshopify.ShopifyResource.set_api_version(SHOPIFY_API_VERSION)\n\ntry:\n    # Activate a temporary session to make calls\n    with shopify.Session.temp(shop_url, SHOPIFY_API_VERSION):\n        # Example: Fetching the current shop's details\n        shop = shopify.Shop.current()\n        print(f\"Connected to shop: {shop.name} (ID: {shop.id})\")\n\n        # Example: Fetching a product by ID (replace with a real product ID from your store)\n        # product_id = 1234567890123 # Replace with an actual product ID\n        # try:\n        #     product = shopify.Product.find(product_id)\n        #     print(f\"Found product: {product.title} (ID: {product.id})\")\n        # except Exception as e:\n        #     print(f\"Could not find product {product_id}: {e}\")\n\n        # Example: Making a GraphQL query (Recommended for new development)\n        graphql_client = shopify.GraphQL()\n        query = \"\"\"\n            query { \n                shop { \n                    name \n                    id \n                } \n            }\n        \"\"\"\n        result = graphql_client.execute(query)\n        print(f\"GraphQL Shop Info: {result}\")\n\nexcept shopify.pyactiveresource.connection.ClientError as e:\n    print(f\"API Client Error: {e.response.code} - {e.response.message}\")\n    print(\"Check your API Key, Password, Shop Name, and API Version.\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to authenticate with the Shopify API using a private app's API key and password, activate a session, and perform basic operations like fetching shop details and making a GraphQL query. Remember to set your `SHOPIFY_API_KEY`, `SHOPIFY_PASSWORD`, `SHOPIFY_SHOP_NAME`, and `SHOPIFY_API_VERSION` environment variables or replace the placeholder values. Shopify recommends using GraphQL for new development."},"warnings":[{"fix":"Subscribe to the Shopify Developer Changelog and regularly review API release notes for your target API version. Plan for quarterly maintenance to update your integration code as needed.","message":"Shopify APIs undergo quarterly version updates, which frequently introduce breaking changes, deprecations, and structural modifications. These can directly impact existing `shopifyapi` integrations. For instance, the '2024-04' version deprecated specific REST API endpoints and changed how products are published/unpublished.","severity":"breaking","affected_versions":"All versions, as it depends on the specific Shopify API version used."},{"fix":"Migrate to `InventoryBulkAdjustQuantityAtLocation` for inventory adjustments and use the 'Publish to Sales Channels' or 'Unpublish from Sales Channels' actions for product visibility management.","message":"The `InventoryAdjustQuantityMutation` in the Admin API has been deprecated and replaced with `InventoryBulkAdjustQuantityAtLocation`. Similarly, direct product publish/unpublish actions are deprecated in favor of publishing/unpublishing to specific sales channels.","severity":"breaking","affected_versions":"Shopify API versions 2024-04 and later."},{"fix":"Prioritize GraphQL API for new features and consider migrating existing REST API calls to GraphQL where feasible to ensure long-term compatibility.","message":"Shopify generally recommends using the GraphQL API for new development, as the REST API is subject to deprecation in the future.","severity":"deprecated","affected_versions":"All versions, especially for new integrations."},{"fix":"Migrate to the Storefront Cart API or Checkout Sheet Kit before the deprecation deadline.","message":"The Checkout API is being fully deprecated. This is a significant change impacting how custom checkout experiences are built.","severity":"breaking","affected_versions":"Shopify API version 2025-04-01 and later."},{"fix":"Always explicitly specify a currently supported API version (e.g., '2024-07') in your code. Consult Shopify's API documentation for valid versions.","message":"When setting up `shopify.Session` or `shopify.ShopifyResource.set_site()`, ensure you provide the correct API version. Using an unsupported or incorrect API version will lead to connection errors.","severity":"gotcha","affected_versions":"All versions."}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}