Shopify B2B Wholesale Solution

  1. Home
  2. Docs
  3. Shopify B2B Wholesale Solution
  4. Custom Pricing (CP)
  5. Public APIs

Public APIs

B2B/Wholesale Custom Pricing Public API for Shopify Stores

Custom pricing public API is an feature of B2B/Wholesale Solution shopify app. To use APIs, you must install app, upgrade to Platinum plan and get the access key.

These APIs are REST APIs. You can use them to manage customer pricing rules, calculate variants' price based on rules, search customers, get products, etc. Detailed instructions on how to do it is showing bellow:

How to get the access key

After you install B2B/Wholesale Solution Shopify app. Go to Public API page, click on the Copy button.

Rule endpoints

There are fields of rule, you need to understand:
- priority: decides whether a rule is prioritized over another or not.
- status:

0: inactive
1: active

- apply_to:

0: All customers
1: Logged-in customers
2: Not-logged-in customers
3: Specific customers
4: Customer tags

- product_condition_type:

0: All products
1: Specific products
2: Product collections
3: Product tags

- discount_type:

0: Apply a price to selected products
1: Decrease a fixed amount of the original prices of selected products
2: Decrease the original prices of selected products by a percentage (%)

Get Rules by Domain

Request URL: https://b2b-solution-api.bsscommerce.com/api/v1/rule/get-by-domain
Method: POST
Content-type: application/json
Request body: 

domain: your default Shopify store domain.
accessKey: value of access key.
{ 
  "domain": "abc.myshopify.com", 
  "accessKey": "xxx" 
}

Response body:

{
   "success":true,
   "rules":[
      {
         "id":79,
         "shop_id":13,
         "name":"Discount 40%",
         "priority":1,
         "status":1,
         "apply_to":4,
         "customer_ids":[
            "5127974846637"
         ],
         "customer_tags":[
            "wholesale"
         ],
         "product_condition_type":0,
         "product_ids":[
            "6586590625965",
            "6586590658733",
            "6586590691501"
         ],
         "product_collections":[
            
         ],
         "product_tags":[
            
         ],
         "discount_type":2,
         "discount_value":"40.00",
         "createdAt":"2021-06-03T07:37:26.000Z",
         "updatedAt":"2021-06-04T09:28:17.000Z"
      }
   ]
}

Get Rule by ID

Request URL: https://b2b-solution-api.bsscommerce.com/api/v1/rule/get-by-id
Method: POST
Content-type: application/json
Request body:

{
  "domain": "abc.myshopify.com", 
  "accessKey": "xxx",
  "id": 79
}

Response body:

{
   "success":true,
   "rule":{
      "id":79,
      "name":"Discount 40%",
      "priority":1,
      "status":1,
      "apply_to":4,
      "product_condition_type":0,
      "customer_ids":[
         "5127974846637"
      ],
      "customer_tags":[
         "wholesale"
      ],
      "product_ids":[
         "6586590625965",
         "6586590658733",
         "6586590691501"
      ],
      "product_collections":[
         
      ],
      "product_tags":[
         
      ],
      "discount_type":2,
      "discount_value":"40.00",
      "createdAt":"2021-06-03T07:37:26.000Z",
      "updatedAt":"2021-06-04T09:28:17.000Z"
   }
}

Create or  Update Single Rule

Request URL: https://b2b-solution-api.bsscommerce.com/api/v1/rule/save
Method: POST
Content-type: application/json
Request body:

If there is no ID in rule data, a new rule will be created. Otherwise, existing rule with ID will be updated.

{
  "domain":"abc.myshopify.com",
  "accessKey": "xxx",
  "rule": {
   "id": 79,
   "name": "Discount 20%",
   "priority": 1,
   "status": 1,
   "apply_to": 0,
   "product_condition_type": 0,
   "customer_ids": [],
   "customer_tags": [],
   "product_ids": [ "6586590625965", "6586590658733", "6586590691501" ],
   "product_collections": [],
   "product_tags": [],
   "discount_type": 2,
   "discount_value": 10.00
 }

}

Response body

{
"success": true,
"message": "Update the rule successfully"
}

Create or Update Multiple Rules

Request URL: https://b2b-solution-api.bsscommerce.com/api/v1/rule/bulk-save
Method: POST
Content-type: application/json
Request body:

{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "rules": [
    {
      "id": 79,
      "name": "Discount 20%",
      "priority": 1,
      "status": 1,
      "apply_to": 0,
      "product_condition_type": 0,
      "customer_ids": [],
      "customer_tags": [],
      "product_ids": [
        6586590625965,
        6586590658733,
        6586590691501
      ],
      "product_collections": [],
      "product_tags": [],
      "discount_type": 2,
      "discount_value": 10
    },
    {
      "name": "Discount 30%",
      "priority": 1,
      "status": 1,
      "apply_to": 0,
      "product_condition_type": 0,
      "customer_ids": [],
      "customer_tags": [],
      "product_ids": [
        6586590625965,
        6586590658733,
        6586590691501
      ],
      "product_collections": [],
      "product_tags": [],
      "discount_type": 2,
      "discount_value": 10
    }
  ]
}

Response Body:

{
  "success": true,
  "message": "Save multiple rule successfully"
}

Delete Rule

Request URL: https://b2b-solution-api.bsscommerce.com/api/v1/rule/delete
Method: POST
Content-type: application/json
Request body:

{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "id": 79
}

Response body:

{
  "success": true,
  "message": "Deleted rule successfully"
}

Get Applied Rules for Products

Request URL: https://b2b-solution-api.bsscommerce.com/api/v1/rule/get-products-applied-rules
Method: POST
Content-type: application/json
Request body:

If customer_id is null, the system will check Custom Pricing Rules which applied for all customers or not-logged-in customers.

{
  "domain": "abc.myshopify.com",
  "product_ids": [ 6586590625965, 6586590658733, 6586590691501 ],
  "customer_id": 5127974846637,
  "accessKey": "xxxx"
}

Response body:

{
   "success":true,
   "productsAppliedRule":[
      {
         "id":"6586590625965",
         "discount_type":2,
         "value":"10.00",
         "name":"Discount 30%"
      },
      {
         "id":"6586590658733",
         "discount_type":2,
         "value":"10.00",
         "name":"Discount 30%"
      },
      {
         "id":"6586590691501",
         "discount_type":2,
         "value":"10.00",
         "name":"Discount 30%"
      }
   ]
}

Get Price List of Variants based on Applied Rules

Request URL: https://b2b-solution-api.bsscommerce.com/api/v1/rule/get-variants-price-list
Method: POST
Content-type: application/json
Request body:

If customer_id is null, the system will check Custom Pricing Rules which applied for all customers or not-logged-in customers.

{
  "domain": "abc.myshopify.com",
  "product_ids": [ 6586590625965, 6586590658733, 6586590691501 ],
  "customer_id": 5127974846637,
  "accessKey": "xxx"
}

Response body:

{
   "success":true,
   "priceList":[
      {
         "id":"6586590625965",
         "discount_type":2,
         "value":"10.00",
         "name":"Discount 30%",
         "variants":[
            {
               "id":"39454422368429",
               "price":"70",
               "compareAtPrice":"85",
               "appliedRulePrice":63
            },
            {
               "id":"39454422401197",
               "price":"55",
               "compareAtPrice":"85",
               "appliedRulePrice":49.5
            }
         ]
      },
      {
         "id":"6586590658733",
         "discount_type":2,
         "value":"10.00",
         "name":"Discount 30%",
         "variants":[
            {
               "id":"39454422433965",
               "price":"40",
               "compareAtPrice":"44",
               "appliedRulePrice":36
            }
         ]
      },
      {
         "id":"6586590691501",
         "discount_type":2,
         "value":"10.00",
         "name":"Discount 30%",
         "variants":[
            {
               "id":"39454422466733",
               "price":"43",
               "compareAtPrice":"45",
               "appliedRulePrice":38.7
            }
         ]
      }
   ]
}

Product endpoints

Search products

Request URL: https://b2b-solution-api.bsscommerce.com/api/v1/product/search
Method: POST
Content-type: application/json
Request body:

Index is a cursor value, where you want to start searching. If afterIndex is null, the system will search products from the beginning. For example:

afterIndex: "eyJsYXN0X2lkIjo2NjU1NDU2Mzc5MDUzLCJsYXN0X3ZhbHVlIjo2NjU1NDU2Mzc5MDUzfQ=="
{
  "domain": "abc.myshopify.com",
  "accessKey": "Z/OVr8Poy54umr77+OqkC685KhdVptN6LhMA70dMf6g=",
  "afterIndex": null,
  "first": 20,
  "searchQuery": "ocean"
}

Response body:

{
   "success":true,
   "productList":{
      "edges":[
         {
            "node":{
               "id":"gid://shopify/Product/6586580271277",
               "title":"Ocean Blue Shirt",
               "handle":"ocean-blue-shirt",
               "productType":"",
               "totalVariants":1,
               "hasOnlyDefaultVariant":true,
               "priceRange":{
                  "minVariantPrice":{
                     "currencyCode":"VND",
                     "amount":"50.0"
                  },
                  "maxVariantPrice":{
                     "currencyCode":"VND",
                     "amount":"50.0"
                  }
               },
               "featuredImage":{
                  "transformedSrc":"https://cdn.shopify.com/s/files/1/0538/3874/1677/products/young-man-in-bright-fashion_925x_5251bcfa-6939-4d7a-9287-dd9bf058ed03.jpg?v=1616405807"
               },
               "onlineStoreUrl":null
            },
            "cursor":"eyJsYXN0X2lkIjo2NTg2NTgwMjcxMjc3LCJsYXN0X3ZhbHVlIjo2NTg2NTgwMjcxMjc3fQ=="
         },
         {
            "node":{
               "id":"gid://shopify/Product/6655456379053",
               "title":"Riri Bracelet",
               "handle":"riri-bracelet-rose",
               "productType":"women's bracelets",
               "totalVariants":1,
               "hasOnlyDefaultVariant":false,
               "priceRange":{
                  "minVariantPrice":{
                     "currencyCode":"VND",
                     "amount":"68.0"
                  },
                  "maxVariantPrice":{
                     "currencyCode":"VND",
                     "amount":"68.0"
                  }
               },
               "featuredImage":{
                  "transformedSrc":"https://cdn.shopify.com/s/files/1/0538/3874/1677/products/2015-04-20_Accessories_31_23500_21376.jpg?v=1619597977"
               },
               "onlineStoreUrl":null
            },
            "cursor":"eyJsYXN0X2lkIjo2NjU1NDU2Mzc5MDUzLCJsYXN0X3ZhbHVlIjo2NjU1NDU2Mzc5MDUzfQ=="
         }
      ],
      "pageInfo":{
         "hasNextPage":false,
         "hasPreviousPage":false
      }
   }
}

Get Product Tags

Request URL: https://b2b-solution-api.bsscommerce.com/api/v1/product/get-tags
Method: POST
Content-type: application/json
Request body:

{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx"
}

Response body:

{
   "success":true,
   "productTags":{
      "tags":[
         "cotton blouse",
         "Couch",
         "cowl",
         "cpace",
         "Crane",
         "cream",
         "crepe wool",
         "crew",
         "crew neck",
         "crewneck",
         "crisp"
      ],
      "last_cursor":"Y3Jpc3A="
   }
}

Get Products by IDs

Request URL: https://b2b-solution-api.bsscommerce.com/api/v1/product/get-by-ids
Method: POST
Content-type: application/json
Request body:

{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "ids": [ 6586590625965 ]
}

Response body:

{
   "success":true,
   "productList":[
      {
         "id":"gid://shopify/Product/6586590625965",
         "title":"Anchor Bracelet Mens",
         "handle":"leather-anchor",
         "productType":"Bracelet",
         "totalVariants":2,
         "hasOnlyDefaultVariant":false,
         "priceRange":{
            "minVariantPrice":{
               "currencyCode":"VND",
               "amount":"55.0"
            },
            "maxVariantPrice":{
               "currencyCode":"VND",
               "amount":"70.0"
            }
         },
         "featuredImage":{
            "transformedSrc":"https://cdn.shopify.com/s/files/1/0538/3874/1677/products/anchor-bracelet-mens_925x_8dcf313c-5c78-41ea-874d-59804d449315.jpg?v=1616407017"
         },
         "onlineStoreUrl":null
      }
   ]
}

Customer endpoints

Get Customer Tags

Request URL: https://b2b-solution-api.bsscommerce.com/api/v1/customer/get-tags
Method: POST
Content-type: application/json
Request body:

{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx"
}

Response body

{
   "success":true,
   "customerTags":[
      {
         "node":"wholesale",
         "cursor":"d2hvbGVzYWxl"
      }
   ]
}

Get Customers by IDs

Request URL: https://b2b-solution-api.bsscommerce.com/api/v1/customer/get-by-ids
Method: POST
Content-type: application/json
Request body:

{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "ids": [5127974846637]
}

Response body

{
   "success":true,
   "customerList":[
      {
         "id":"gid://shopify/Customer/5127974846637",
         "displayName":"nta",
         "email":"abc@gmail.com",
         "firstName":"n",
         "lastName":"ta"
      }
   ]
}

Search Customers

Request URL: https://b2b-solution-api.bsscommerce.com/api/v1/customer/search
Method: POST
Content-type: application/json
Request body:

{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "afterIndex": null,
  "first": 20,
  "searchQuery": "nta"
}

Response body

{
   "success":true,
   "customers":[
      {
         "node":{
            "id":"gid://shopify/Customer/5127974846637",
            "displayName":"nta",
            "email":"abc@gmail.com",
            "firstName":"n",
            "lastName":"ta",
            "phone":null,
            "tags":[
               "wholesale"
            ],
            "note":""
         },
         "cursor":"eyJsYXN0X2lkIjo1MTI3OTc0ODQ2NjM3LCJsYXN0X3ZhbHVlIjo1MTI3OTc0ODQ2NjM3fQ=="
      }
   ]
}

Collection endpoints

Get Collections

Request URL: https://b2b-solution-api.bsscommerce.com/api/v1/collection/get-list
Method: POST
Content-type: application/json
Request body:

{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx"
}

Response body

{
   "success":true,
   "collections":[
      {
         "id":"gid://shopify/Collection/244026966189",
         "image":null,
         "title":"Home page",
         "handle":"frontpage"
      }
   ]
}
Was this article helpful to you? Yes No

How can we help?