### Generate and Use Shopify Python Client Source: https://github.com/allengrant/shopify_openapi/blob/master/README.md Provides instructions for generating a Python client for the Shopify Admin API using the 'openapi-python-client' tool. It then shows how to instantiate the generated client with a base URL. Dependencies include the 'openapi-python-client' package. ```bash # Generate the Python Client openapi-python-client generate \ --url https://github.com/allengrant/shopify_openapi/raw/master/shopify_openapi.yaml cd shopify-admin-api-client ``` ```python from shopify_admin_api_client import Client client = Client(base_url="https://example.myshopify.com") ``` -------------------------------- ### Initialize Shopify OpenAPI Client with TypeScript Source: https://github.com/allengrant/shopify_openapi/blob/master/README.md Demonstrates how to initialize the OpenAPI client using the 'openapi-client-axios' library in TypeScript. It requires the path to the OpenAPI definition file. The output is an initialized API client instance. ```javascript const OpenAPIClientAxios = require('openapi-client-axios').default const definition = 'https://github.com/allengrant/shopify_openapi/raw/master/shopify_openapi.yaml' let api = new OpenAPIClientAxios({ definition }) api = await api.init() ``` -------------------------------- ### Manage Shopify Theme Assets with cURL Source: https://context7.com/allengrant/shopify_openapi/llms.txt Demonstrates how to list, retrieve, and update theme assets (like Liquid, CSS, JS) using cURL. Requires shop URL, API version, theme ID, and an access token. Handles different asset operations via HTTP GET and PUT requests. ```bash # List all assets in a theme curl -X GET "https://{shop}.myshopify.com/admin/api/2020-10/themes/828155753/assets.json" \ -H "X-Shopify-Access-Token: {access_token}" # Get specific asset curl -X GET "https://{shop}.myshopify.com/admin/api/2020-10/themes/828155753/assets.json?asset[key]=sections/header.liquid" \ -H "X-Shopify-Access-Token: {access_token}" # Update asset curl -X PUT "https://{shop}.myshopify.com/admin/api/2020-10/themes/828155753/assets.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" \ -d '{ "asset": { "key": "assets/custom.css", "value": ".custom-class { color: blue; }" } }' ``` -------------------------------- ### Get Customer Account Activation URL Source: https://context7.com/allengrant/shopify_openapi/llms.txt Generates a unique URL for a customer to activate their account. This is useful for customers who have not yet set up their account. Requires shop URL, access token, and customer ID. ```bash curl -X POST "https://{shop}.myshopify.com/admin/api/2020-10/customers/207119551/account_activation_url.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` -------------------------------- ### Manage Product Images with cURL Source: https://context7.com/allengrant/shopify_openapi/llms.txt Provides cURL commands to list, add, and get the count of images for a specific product. Requires shop URL, access token, and product ID. Image addition supports specifying position and source URL. ```bash # List product images curl -X GET "https://{shop}.myshopify.com/admin/api/2020-10/products/632910392/images.json" \ -H "X-Shopify-Access-Token: {access_token}" # Add image from URL curl -X POST "https://{shop}.myshopify.com/admin/api/2020-10/products/632910392/images.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" \ -d '{ "image": { "position": 1, "src": "https://example.com/product-image.jpg", "alt": "Product front view" } }' # Get image count curl -X GET "https://{shop}.myshopify.com/admin/api/2020-10/products/632910392/images/count.json" \ -H "X-Shopify-Access-Token: {access_token}" ``` -------------------------------- ### GET /admin/api/2020-10/application_charges.json Source: https://context7.com/allengrant/shopify_openapi/llms.txt Retrieves all application charges with optional filtering by status. ```APIDOC ## GET /admin/api/2020-10/application_charges.json ### Description Retrieves all application charges with optional filtering by status. ### Method GET ### Endpoint https://{shop}.myshopify.com/admin/api/2020-10/application_charges.json ### Parameters #### Query Parameters - **since_id** (integer) - Optional - Retrieve charges created after this ID. - **fields** (string) - Optional - Comma-separated list of fields to include in the response. ### Response #### Success Response (200) - **application_charges** (array) - A list of application charge objects. - Each object contains: - **id** (integer) - The unique identifier for the charge. - **name** (string) - The name of the charge. - **status** (string) - The current status of the charge. - **price** (string) - The price of the charge. #### Response Example ```json { "application_charges": [ { "id": 675931192, "name": "Premium Feature", "status": "accepted", "price": "9.99" } ] } ``` ``` -------------------------------- ### Get Customer Count Source: https://context7.com/allengrant/shopify_openapi/llms.txt Retrieves the total number of customers associated with a shop. This endpoint can be used to get a simple count or a count filtered by specific criteria, though the example only shows a basic count. ```bash curl -X GET "https://{shop}.myshopify.com/admin/api/2020-10/customers/count.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` -------------------------------- ### Get Collection Products Source: https://context7.com/allengrant/shopify_openapi/llms.txt Retrieves products belonging to a specific collection. ```APIDOC ## GET /admin/api/2020-10/collections/{collection_id}/products.json ### Description Retrieves products belonging to a specific collection. ### Method GET ### Endpoint https://{shop}.myshopify.com/admin/api/2020-10/collections/{collection_id}/products.json ### Parameters #### Path Parameters - **collection_id** (integer) - Required - The ID of the collection. #### Query Parameters - **limit** (integer) - Optional - The maximum number of results to retrieve. ### Request Example ```bash curl -X GET "https://{shop}.myshopify.com/admin/api/2020-10/collections/841564295/products.json?limit=50" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` ### Response #### Success Response (200) - **products** (array) - A list of product objects. - **id** (integer) - The ID of the product. - **title** (string) - The title of the product. - **vendor** (string) - The vendor of the product. #### Response Example ```json { "products": [ { "id": 632910392, "title": "IPod Nano - 8GB", "vendor": "Apple" } ] } ``` ``` -------------------------------- ### Send Customer Invite Email Source: https://context7.com/allengrant/shopify_openapi/llms.txt Sends an email invitation to a customer to create their account. Allows customization of the subject and message. Requires shop URL, access token, and customer ID. ```bash curl -X POST "https://{shop}.myshopify.com/admin/api/2020-10/customers/207119551/send_invite.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" \ -d '{ "customer_invite": { "subject": "Welcome to Our Store!", "custom_message": "We are excited to have you as a customer." } }' ``` -------------------------------- ### Batch Create Discount Codes using Shopify API Source: https://context7.com/allengrant/shopify_openapi/llms.txt Creates multiple discount codes for a given price rule in a single batch request. This API requires the shop domain, an access token, and a JSON payload containing an array of discount codes. The response indicates the status of the batch job. ```bash curl -X POST "https://{shop}.myshopify.com/admin/api/2020-10/price_rules/507328175/batch.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" \ -d '{ "discount_codes": [ {"code": "SAVE10"}, {"code": "SAVE15"}, {"code": "SAVE20"} ] }' ``` -------------------------------- ### GET /admin/api/2020-10/storefront_access_tokens.json Source: https://context7.com/allengrant/shopify_openapi/llms.txt Retrieves all storefront access tokens that have been issued for the shop. ```APIDOC ## GET /admin/api/2020-10/storefront_access_tokens.json ### Description Retrieves all storefront access tokens that have been issued for the shop. ### Method GET ### Endpoint `https://{shop}.myshopify.com/admin/api/2020-10/storefront_access_tokens.json` ### Parameters #### Headers - **X-Shopify-Access-Token** (string) - Required - Your Shopify API access token. - **Content-Type** (string) - Required - `application/json` ### Request Example ```bash curl -X GET "https://{shop}.myshopify.com/admin/api/2020-10/storefront_access_tokens.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` ### Response #### Success Response (200) - **storefront_access_tokens** (array) - A list of storefront access token objects. - **id** (integer) - The unique identifier for the storefront access token. - **access_token** (string) - The access token. - **title** (string) - The title of the storefront access token. #### Response Example ```json { "storefront_access_tokens": [ { "id": 755357713, "access_token": "c68234c41234567890abcdef12345678", "title": "My Headless Storefront" } ] } ``` ``` -------------------------------- ### Batch Create Discount Codes Source: https://context7.com/allengrant/shopify_openapi/llms.txt Creates multiple discount codes in a batch job for a given price rule. The response indicates the status of the batch job. ```APIDOC ## POST /admin/api/2020-10/price_rules/{price_rule_id}/batch.json ### Description Creates multiple discount codes in a batch job for a price rule. ### Method POST ### Endpoint /admin/api/2020-10/price_rules/{price_rule_id}/batch.json ### Parameters #### Path Parameters - **price_rule_id** (integer) - Required - The ID of the price rule to associate the discount codes with. #### Request Body - **discount_codes** (array of objects) - Required - A list of discount codes to create. - **code** (string) - Required - The discount code string. ### Request Example ```json { "discount_codes": [ {"code": "SAVE10"}, {"code": "SAVE15"}, {"code": "SAVE20"} ] } ``` ### Response #### Success Response (200 OK) - **discount_code_creation** (object) - Information about the batch creation job. - **id** (integer) - The ID of the batch job. - **price_rule_id** (integer) - The ID of the associated price rule. - **started_at** (string) - The start time of the job (null if not started). - **completed_at** (string) - The completion time of the job (null if not completed). - **status** (string) - The current status of the job (e.g., "queued"). - **codes_count** (integer) - The number of codes to be created. #### Response Example ```json { "discount_code_creation": { "id": 989355119, "price_rule_id": 507328175, "started_at": null, "completed_at": null, "status": "queued", "codes_count": 3 } } ``` ``` -------------------------------- ### GET /admin/api/{api_version}/orders/{order_id}/risks.json Source: https://context7.com/allengrant/shopify_openapi/llms.txt Retrieves all risk assessments associated with a specific order. ```APIDOC ## GET /admin/api/{api_version}/orders/{order_id}/risks.json ### Description Retrieves all risk assessments associated with an order. ### Method GET ### Endpoint `/admin/api/{api_version}/orders/{order_id}/risks.json` ### Parameters #### Path Parameters - **order_id** (integer) - Required - The ID of the order to retrieve risks for. - **api_version** (string) - Required - The API version to use (e.g., `2020-10`). ### Request Example ```bash curl -X GET "https://{shop}.myshopify.com/admin/api/2020-10/orders/450789469/risks.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` ### Response #### Success Response (200) - **risks** (array) - A list of risk assessment objects. - **id** (integer) - The unique identifier for the risk assessment. - **order_id** (integer) - The ID of the order associated with the risk. - **recommendation** (string) - The recommended action for the risk (e.g., "investigate"). - **score** (string) - A score indicating the level of risk. - **message** (string) - A message describing the risk. #### Response Example ```json { "risks": [ { "id": 284138680, "order_id": 450789469, "recommendation": "investigate", "score": "0.8", "message": "This order came from an unusual IP address" } ] } ``` ``` -------------------------------- ### GET /admin/api/2020-10/reports/{report_id}.json Source: https://context7.com/allengrant/shopify_openapi/llms.txt Retrieves a single report by ID, limited to reports created by your app. ```APIDOC ## GET /admin/api/2020-10/reports/{report_id}.json ### Description Retrieves a single report by ID, limited to reports created by your app. ### Method GET ### Endpoint https://{shop}.myshopify.com/admin/api/2020-10/reports/{report_id}.json ### Parameters #### Path Parameters - **report_id** (integer) - Required - The ID of the report to retrieve. #### Query Parameters - **fields** (string) - Optional - Comma-separated list of fields to include in the response. ### Response #### Success Response (200) - **report** (object) - The requested report object. - **id** (integer) - The unique identifier for the report. - **name** (string) - The name of the report. - **shopify_ql** (string) - The ShopifyQL query used for the report. #### Response Example ```json { "report": { "id": 517154478, "name": "Sales by product", "shopify_ql": "SHOW total_sales BY product_id FROM sales SINCE -1m UNTIL today" } } ``` ``` -------------------------------- ### TypeScript Client Initialization Source: https://context7.com/allengrant/shopify_openapi/llms.txt Initialize a typed TypeScript/JavaScript client using openapi-client-axios from the OpenAPI specification. ```APIDOC ## TypeScript Client Initialization Use the `openapi-client-axios` library to generate a typed TypeScript/JavaScript client from the OpenAPI specification. ```javascript const OpenAPIClientAxios = require('openapi-client-axios').default const definition = 'https://github.com/allengrant/shopify_openapi/raw/master/shopify_openapi.yaml' let api = new OpenAPIClientAxios({ definition }) api = await api.init() // Example: Get access scopes const response = await api.get_admin_oauth_access_scopes() console.log(response.data) // Expected output: { access_scopes: [{ handle: "read_products" }, { handle: "write_orders" }] } ``` ``` -------------------------------- ### GET /admin/oauth/access_scopes Source: https://context7.com/allengrant/shopify_openapi/llms.txt Retrieves a list of access scopes associated with the current access token, useful for verifying app permissions. ```APIDOC ## GET /admin/oauth/access_scopes ### Description Retrieves a list of access scopes associated with the current access token, useful for verifying app permissions. ### Method GET ### Endpoint `https://{shop}.myshopify.com/admin/oauth/access_scopes.json` ### Parameters #### Headers - **X-Shopify-Access-Token** (string) - Required - Your Shopify API access token. - **Content-Type** (string) - Required - `application/json` ### Request Example ```bash curl -X GET "https://{shop}.myshopify.com/admin/oauth/access_scopes.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` ### Response #### Success Response (200) - **access_scopes** (array) - A list of access scope objects. - **handle** (string) - The name of the access scope. #### Response Example ```json { "access_scopes": [ { "handle": "read_products" }, { "handle": "write_products" }, { "handle": "read_orders" }, { "handle": "write_orders" } ] } ``` ``` -------------------------------- ### Create New Customer Source: https://context7.com/allengrant/shopify_openapi/llms.txt Creates a new customer record in Shopify. Requires shop URL and access token. Can include details like name, email, phone, and default address. Optionally sends a welcome email. ```bash curl -X POST "https://{shop}.myshopify.com/admin/api/2020-10/customers.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" \ -d '{ "customer": { "first_name": "Jane", "last_name": "Doe", "email": "jane@example.com", "phone": "+15551234567", "verified_email": true, "addresses": [ { "address1": "123 Main St", "city": "New York", "province": "NY", "zip": "10001", "country": "US", "default": true } ], "send_email_welcome": false } }' ``` -------------------------------- ### GET /admin/api/2020-10/reports.json Source: https://context7.com/allengrant/shopify_openapi/llms.txt Retrieves a list of reports with pagination support. Results are paginated via link headers since API version 2019-10. ```APIDOC ## GET /admin/api/2020-10/reports.json ### Description Retrieves a list of reports with pagination support. Results are paginated via link headers since API version 2019-10. ### Method GET ### Endpoint `https://{shop}.myshopify.com/admin/api/2020-10/reports.json` ### Parameters #### Query Parameters - **ids** (string) - Optional - Comma-separated list of report IDs. - **limit** (integer) - Optional - Results per page (default: 50, max: 250). - **since_id** (integer) - Optional - Restrict results to after specified ID. - **updated_at_min** (string) - Optional - Filter by update date (format: `2014-04-25T16:15:47-04:00`). - **updated_at_max** (string) - Optional - Filter by update date (format: `2014-04-25T16:15:47-04:00`). #### Headers - **X-Shopify-Access-Token** (string) - Required - Your Shopify API access token. - **Content-Type** (string) - Required - `application/json` ### Request Example ```bash curl -X GET "https://{shop}.myshopify.com/admin/api/2020-10/reports.json?limit=50" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` ### Response #### Success Response (200) - **reports** (array) - A list of report objects. (Structure of report objects not detailed in provided text). #### Response Example (Response example not provided in the input text.) ``` -------------------------------- ### Get Single Report by ID Source: https://context7.com/allengrant/shopify_openapi/llms.txt Retrieves a specific report by its ID. Supports field selection to limit the returned data. Requires shop domain and access token. ```bash curl -X GET "https://{shop}.myshopify.com/admin/api/2020-10/reports/517154478.json?fields=id,name,shopify_ql" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` -------------------------------- ### Create One-Time Application Charge Source: https://context7.com/allengrant/shopify_openapi/llms.txt Creates a one-time application charge that the merchant must approve. Includes charge details like name, price, and return URL. Requires shop domain and access token. ```bash curl -X POST "https://{shop}.myshopify.com/admin/api/2020-10/application_charges.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" \ -d '{ "application_charge": { "name": "Premium Feature Unlock", "price": 9.99, "return_url": "https://myapp.com/charge/callback", "test": true } }' ``` -------------------------------- ### Create Discount Code using cURL Source: https://context7.com/allengrant/shopify_openapi/llms.txt Creates a discount code associated with a price rule. This API call requires the price rule ID, shop domain, access token, and the desired discount code. ```bash curl -X POST "https://{shop}.myshopify.com/admin/api/2020-10/price_rules/507328175/discount_codes.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" \ -d '{ "discount_code": { "code": "SUMMER20" } }' ``` -------------------------------- ### Get Shopify Access Scopes using cURL Source: https://context7.com/allengrant/shopify_openapi/llms.txt Retrieves a list of access scopes associated with the current access token for a Shopify store. This is useful for verifying the permissions granted to your application. ```bash curl -X GET "https://{shop}.myshopify.com/admin/oauth/access_scopes.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" # Expected Response: # { # "access_scopes": [ # { "handle": "read_products" }, # { "handle": "write_products" }, # { "handle": "read_orders" }, # { "handle": "write_orders" } # ] # } ``` -------------------------------- ### List Order Risks - Bash Source: https://context7.com/allengrant/shopify_openapi/llms.txt Retrieves all risk assessments associated with a specific order using a GET request to the Shopify Admin API. Requires shop domain, order ID, and an access token. ```bash curl -X GET "https://{shop}.myshopify.com/admin/api/2020-10/orders/450789469/risks.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` -------------------------------- ### Create Recurring Application Charge Source: https://context7.com/allengrant/shopify_openapi/llms.txt Creates a recurring subscription charge for an app, including details like name, price, capped amount, trial days, and terms. Requires shop domain and access token. ```bash curl -X POST "https://{shop}.myshopify.com/admin/api/2020-10/recurring_application_charges.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" \ -d '{ "recurring_application_charge": { "name": "Pro Plan Monthly", "price": 29.99, "return_url": "https://myapp.com/subscription/callback", "capped_amount": 100.00, "terms": "Includes unlimited products and priority support", "trial_days": 14, "test": true } }' ``` -------------------------------- ### Get Collection Products using cURL Source: https://context7.com/allengrant/shopify_openapi/llms.txt Retrieves products belonging to a specific collection. This API call requires the collection ID, shop domain, and an access token. It supports pagination with the 'limit' parameter. ```bash curl -X GET "https://{shop}.myshopify.com/admin/api/2020-10/collections/841564295/products.json?limit=50" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` -------------------------------- ### Product APIs Source: https://context7.com/allengrant/shopify_openapi/llms.txt APIs for managing products, including listing, creating, and managing product images. ```APIDOC ## GET /admin/api/2020-10/products.json ### Description Retrieves a paginated list of products with filtering by various attributes. ### Method GET ### Endpoint /admin/api/2020-10/products.json ### Parameters #### Query Parameters - **limit** (integer) - Optional - The maximum number of products to return. - **status** (string) - Optional - Filter by product status (active, archived, or draft). - **published_status** (string) - Optional - Filter by publication status (published, unpublished, or any). - **ids** (string) - Optional - Comma-separated product IDs. - **collection_id** (integer) - Optional - Filter by collection ID. - **product_type** (string) - Optional - Filter by product type. - **vendor** (string) - Optional - Filter by vendor. - **handle** (string) - Optional - Filter by product handle. ### Response #### Success Response (200) - **products** (array) - A list of product objects. - **id** (integer) - The unique identifier for the product. - **title** (string) - The title of the product. - **body_html** (string) - The HTML description of the product. - **vendor** (string) - The vendor of the product. - **product_type** (string) - The type of the product. - **handle** (string) - The handle of the product. - **variants** (array) - List of product variants. - **images** (array) - List of product images. #### Response Example ```json { "products": [ { "id": 632910392, "title": "IPod Nano - 8GB", "body_html": "

Great music player

", "vendor": "Apple", "product_type": "Electronics", "handle": "ipod-nano", "variants": [...], "images": [...] } ] } ``` ## POST /admin/api/2020-10/products.json ### Description Creates a new product with variants, images, and metafields. ### Method POST ### Endpoint /admin/api/2020-10/products.json ### Parameters #### Request Body - **product** (object) - Required - The product details. - **title** (string) - Required - The title of the product. - **body_html** (string) - Optional - The HTML description of the product. - **vendor** (string) - Optional - The vendor of the product. - **product_type** (string) - Optional - The type of the product. - **tags** (string) - Optional - Comma-separated tags for the product. - **variants** (array) - Optional - List of product variants. - **options** (array) - Optional - List of product options. - **images** (array) - Optional - List of product images. ### Request Example ```json { "product": { "title": "Burton Custom Snowboard", "body_html": "

Premium snowboard for experts

", "vendor": "Burton", "product_type": "Snowboard", "tags": "winter, sports, premium", "variants": [ { "option1": "155cm", "price": "599.99", "sku": "BURTON-155", "inventory_quantity": 10, "inventory_management": "shopify" }, { "option1": "160cm", "price": "649.99", "sku": "BURTON-160", "inventory_quantity": 5 } ], "options": [ { "name": "Size", "values": ["155cm", "160cm"] } ], "images": [ { "src": "https://example.com/snowboard.jpg" } ] } } ``` #### Response Example ```json { "product": { "id": 1071559582, "title": "Burton Custom Snowboard", "handle": "burton-custom-snowboard", "variants": [...] } } ``` ## GET /admin/api/2020-10/products/count.json ### Description Returns the total number of products matching specified criteria. ### Method GET ### Endpoint /admin/api/2020-10/products/count.json ### Parameters #### Query Parameters - **vendor** (string) - Optional - Filter by vendor. - **product_type** (string) - Optional - Filter by product type. ### Response #### Success Response (200) - **count** (integer) - The total number of products matching the criteria. #### Response Example ```json { "count": 42 } ``` ## GET /admin/api/2020-10/products/{product_id}/images.json ### Description Lists all images associated with a specific product. ### Method GET ### Endpoint /admin/api/2020-10/products/{product_id}/images.json ### Parameters #### Path Parameters - **product_id** (integer) - Required - The ID of the product whose images are to be listed. ### Response #### Success Response (200) - **images** (array) - A list of image objects associated with the product. #### Response Example ```json { "images": [ { "id": 850703190, "product_id": 632910392, "position": 1, "src": "https://cdn.shopify.com/...", "width": 800, "height": 600 } ] } ``` ## POST /admin/api/2020-10/products/{product_id}/images.json ### Description Adds a new image to a product. ### Method POST ### Endpoint /admin/api/2020-10/products/{product_id}/images.json ### Parameters #### Path Parameters - **product_id** (integer) - Required - The ID of the product to which the image will be added. #### Request Body - **image** (object) - Required - The image details. - **position** (integer) - Optional - The position of the image in the product's image list. - **src** (string) - Required - The URL of the image. - **alt** (string) - Optional - Alternative text for the image. ### Request Example ```json { "image": { "position": 1, "src": "https://example.com/product-image.jpg", "alt": "Product front view" } } ``` ## GET /admin/api/2020-10/products/{product_id}/images/count.json ### Description Returns the total number of images for a specific product. ### Method GET ### Endpoint /admin/api/2020-10/products/{product_id}/images/count.json ### Parameters #### Path Parameters - **product_id** (integer) - Required - The ID of the product. ### Response #### Success Response (200) - **image** (object) - **id** (integer) - The ID of the image. - **product_id** (integer) - The ID of the product. - **position** (integer) - The position of the image. - **src** (string) - The URL of the image. - **width** (integer) - The width of the image. - **height** (integer) - The height of the image. #### Response Example ```json { "image": { "id": 850703190, "product_id": 632910392, "position": 1, "src": "https://cdn.shopify.com/", "width": 800, "height": 600 } } ``` ``` -------------------------------- ### Get Product Count with cURL Source: https://context7.com/allengrant/shopify_openapi/llms.txt Retrieves the total count of products that match specified criteria, such as vendor and product type. Requires shop URL and access token. The response is a JSON object containing the count. ```bash curl -X GET "https://{shop}.myshopify.com/admin/api/2020-10/products/count.json?vendor=Apple&product_type=Electronics" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` -------------------------------- ### Create Report using ShopifyQL Source: https://context7.com/allengrant/shopify_openapi/llms.txt Creates a new custom report using the ShopifyQL query language. Requires shop domain, access token, and a JSON payload with report details. ```bash curl -X POST "https://{shop}.myshopify.com/admin/api/2020-10/reports.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" \ -d '{ "report": { "name": "Monthly Sales by Order", "shopify_ql": "SHOW total_sales BY order_id FROM sales SINCE -1m UNTIL today ORDER BY total_sales" } }' ``` -------------------------------- ### Create Product with cURL Source: https://context7.com/allengrant/shopify_openapi/llms.txt Creates a new product in Shopify, including details like title, body HTML, vendor, type, tags, variants, options, and images. Requires shop URL and access token. The request body is a JSON object. ```bash curl -X POST "https://{shop}.myshopify.com/admin/api/2020-10/products.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" \ -d '{ "product": { "title": "Burton Custom Snowboard", "body_html": "

Premium snowboard for experts

", "vendor": "Burton", "product_type": "Snowboard", "tags": "winter, sports, premium", "variants": [ { "option1": "155cm", "price": "599.99", "sku": "BURTON-155", "inventory_quantity": 10, "inventory_management": "shopify" }, { "option1": "160cm", "price": "649.99", "sku": "BURTON-160", "inventory_quantity": 5 } ], "options": [ { "name": "Size", "values": ["155cm", "160cm"] } ], "images": [ { "src": "https://example.com/snowboard.jpg" } ] } }' ``` -------------------------------- ### Create Refund - Bash Source: https://context7.com/allengrant/shopify_openapi/llms.txt Creates a refund for an order via the Shopify Admin API. This POST request supports options for restocking items, providing a note, and specifying refund details including currency, shipping, line items, and transactions. ```bash curl -X POST "https://{shop}.myshopify.com/admin/api/2020-10/orders/450789469/refunds.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" \ -d '{ "refund": { "currency": "USD", "notify": true, "note": "Customer returned damaged item", "shipping": { "full_refund": true }, "refund_line_items": [ { "line_item_id": 518995019, "quantity": 1, "restock_type": "return", "location_id": 905684977 } ], "transactions": [ { "parent_id": 801038806, "amount": "55.50", "kind": "refund", "gateway": "bogus" } ] } }' ``` -------------------------------- ### Create Usage Charge for Recurring Application Source: https://context7.com/allengrant/shopify_openapi/llms.txt Creates a usage-based charge against an active recurring application charge. This requires the shop URL, an access token, and the charge ID. The charge includes a description and a price. ```bash curl -X POST "https://{shop}.myshopify.com/admin/api/2020-10/recurring_application_charges/455696195/usage_charges.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" \ -d '{ "usage_charge": { "description": "1000 additional API calls", "price": 5.00 } }' ``` -------------------------------- ### Search Customers by Query Source: https://context7.com/allengrant/shopify_openapi/llms.txt Searches for customers using a query string that can match various fields like email, name, phone, etc. Requires shop URL and access token. Allows limiting the number of results. ```bash curl -X GET "https://{shop}.myshopify.com/admin/api/2020-10/customers/search.json?query=email:bob@example.com&limit=50" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` -------------------------------- ### Create Discount Code Source: https://context7.com/allengrant/shopify_openapi/llms.txt Creates a discount code associated with a price rule. ```APIDOC ## POST /admin/api/2020-10/price_rules/{price_rule_id}/discount_codes.json ### Description Creates a discount code associated with a price rule. ### Method POST ### Endpoint https://{shop}.myshopify.com/admin/api/2020-10/price_rules/{price_rule_id}/discount_codes.json ### Parameters #### Path Parameters - **price_rule_id** (integer) - Required - The ID of the price rule. #### Request Body - **discount_code** (object) - Required - The discount code details. - **code** (string) - Required - The discount code string. ### Request Example ```json { "discount_code": { "code": "SUMMER20" } } ``` ### Response #### Success Response (200) - **discount_code** (object) - The created discount code. - **id** (integer) - The ID of the discount code. - **price_rule_id** (integer) - The ID of the associated price rule. - **code** (string) - The discount code string. - **usage_count** (integer) - The current number of times the code has been used. - **created_at** (string) - The timestamp when the discount code was created. #### Response Example ```json { "discount_code": { "id": 1054381139, "price_rule_id": 507328175, "code": "SUMMER20", "usage_count": 0, "created_at": "2020-10-15T12:00:00-04:00" } } ``` ``` -------------------------------- ### List Application Charges Source: https://context7.com/allengrant/shopify_openapi/llms.txt Retrieves all application charges associated with the shop. Supports filtering by ID and selecting specific fields. Requires shop domain and access token. ```bash curl -X GET "https://{shop}.myshopify.com/admin/api/2020-10/application_charges.json?since_id=1000&fields=id,name,status,price" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` -------------------------------- ### Activate Application Charge Source: https://context7.com/allengrant/shopify_openapi/llms.txt Activates an accepted application charge to finalize the billing transaction. Requires shop domain, access token, and the charge ID. ```bash curl -X POST "https://{shop}.myshopify.com/admin/api/2020-10/application_charges/675931192/activate.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` -------------------------------- ### Create Shopify Script Tag with cURL Source: https://context7.com/allengrant/shopify_openapi/llms.txt Demonstrates creating a script tag to inject JavaScript into the Shopify storefront using cURL. Specifies the event to trigger the script, the source URL, and the display scope. Requires shop URL, API version, and an access token. ```bash curl -X POST "https://{shop}.myshopify.com/admin/api/2020-10/script_tags.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" \ -d '{ "script_tag": { "event": "onload", "src": "https://myapp.com/scripts/tracking.js", "display_scope": "all" } }' ``` -------------------------------- ### Create Shopify Gift Card with cURL Source: https://context7.com/allengrant/shopify_openapi/llms.txt Shows how to create a new gift card for a Shopify store using cURL. Allows specifying the initial value, a unique code, and a note. Requires shop URL, API version, and an access token. ```bash curl -X POST "https://{shop}.myshopify.com/admin/api/2020-10/gift_cards.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" \ -d '{ "gift_card": { "initial_value": "100.00", "code": "GIFT-1234-5678-9012", "note": "Birthday gift for VIP customer" } }' ``` -------------------------------- ### Create Webhook Subscription using Shopify API Source: https://context7.com/allengrant/shopify_openapi/llms.txt Creates a new webhook subscription to receive real-time notifications for specific events occurring in the Shopify store. This requires the shop domain, an access token, and a JSON payload specifying the topic, callback URL, and format. Supported topics include orders, products, customers, checkouts, and app uninstalls. ```bash curl -X POST "https://{shop}.myshopify.com/admin/api/2020-10/webhooks.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" \ -d '{ "webhook": { "topic": "orders/create", "address": "https://myapp.com/webhooks/orders", "format": "json" } }' ``` -------------------------------- ### List Blog Articles Source: https://context7.com/allengrant/shopify_openapi/llms.txt Retrieves a list of articles from a specific blog. You can filter by publication status and set a limit for the number of articles returned. ```APIDOC ## GET /admin/api/2020-10/blogs/{blog_id}/articles.json ### Description Retrieves articles from a blog with filtering and pagination. ### Method GET ### Endpoint /admin/api/2020-10/blogs/{blog_id}/articles.json ### Parameters #### Path Parameters - **blog_id** (integer) - Required - The ID of the blog to retrieve articles from. #### Query Parameters - **limit** (integer) - Optional - The maximum number of articles to return (default 50). - **published_status** (string) - Optional - Filter articles by their publication status (e.g., "published", "unpublished"). ### Request Example ```bash curl -X GET "https://{shop}.myshopify.com/admin/api/2020-10/blogs/241253187/articles.json?limit=50&published_status=published" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` ### Response #### Success Response (200 OK) - **articles** (array of objects) - A list of article objects. - **id** (integer) - The article ID. - **title** (string) - The title of the article. #### Response Example ```json { "articles": [ { "id": 989034056, "title": "How to Choose the Right Snowboard" } ] } ``` ``` -------------------------------- ### List Blog Articles using Shopify API Source: https://context7.com/allengrant/shopify_openapi/llms.txt Retrieves a list of articles from a specific blog. This endpoint allows filtering by publication status and limiting the number of results. It requires the shop domain, an access token, and the blog ID. ```bash curl -X GET "https://{shop}.myshopify.com/admin/api/2020-10/blogs/241253187/articles.json?limit=50&published_status=published" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` -------------------------------- ### List Customers with Filtering Source: https://context7.com/allengrant/shopify_openapi/llms.txt Retrieves a paginated list of customers with options to filter by creation date, update date, and other parameters. Requires shop URL and access token. Supports limiting results and selecting specific fields. ```bash curl -X GET "https://{shop}.myshopify.com/admin/api/2020-10/customers.json?limit=50&created_at_min=2020-01-01T00:00:00-00:00" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ```