Products

API change history

List stores, categories, and items configured in the Direct Scale Commission Engine.

Get Top-selling Products

Return a list of top-selling items in a particular category. Optional filter parameters will limit translations, prices, and products returned.

NOTE: This call runs a sales query to fetch the top-selling products, which is then cached and kept for 4 hours, for each category/region/etc. The first time this call is made, it could take several seconds, but subsequently should only take milliseconds for cache retrieval (until the 4 hours pass).

You can get the Request Parameters at these calls:

categoryId

  • Get Categories

CurrencyCode

  • Get Regions displays the country/state codes of the warehouses. If you are concerned about having the proper CurrencyCode, then this will allow you to know what region warehouse support team to call to get the confirmed CurrencyCode.

LanguageCode

  • Get Item by Id
  • Get Items
  • Get Items by Filter

RegionID

  • Get Regions

PriceGroup

  • Order: Get Price Group(s)

StoreID

  • Get Stores

Try it

Request

Request URL

Request parameters

  • string

    The Id of the Category whose Items are to be retrieved.

  • int

    The number of top products to retrieve

  • string

    The 3-character ISO currency code indicating pricing to be returned.

  • string

    The 2-character ISO language code indicating language of translations.

  • int

    The Region ID, fetched using "Get Regions"

  • int

    The Price Group ID, fetched using "Get Price Groups"

  • int

    The Store ID, fetched using "Get Stores"

  • (optional)
    string

    The Country Code, fetched using "Get Regions"

Request headers

  • string
    Subscription key which provides access to this API. Found in your Profile.

Request body

Responses

200 OK

Returns an array of requested top-selling item objects. If the category selected is empty the array will be empty.

Representations

[
  {
    "ItemID": 1,
    "Quantity": 1,
    "Cost": 0,
    "ExtendedPrice": 10,
    "ExtendedOriginalPrice": 10,
    "ExtendedBonus": 0,
    "ExtendedCV": 5,
    "ExtendedQV": 4,
    "ExtendedRewardPoints": 0,
    "ExtendedCost": 0,
    "ProductName": "Test Item",
    "Description": "<p>Test Item (description)</p>",
    "Specifications": "<p>Test Item (specs)</p>",
    "SEO": null,
    "LanguageCode": "en",
    "SKU": "DRTSCL",
    "Category": "Test Category",
    "CategoryId": 1,
    "ChargeShipping": true,
    "Custom": {
      "ItemId": 0,
      "Field1": "",
      "Field2": "",
      "Field3": "",
      "Field4": "",
      "Field5": ""
    },
    "Height": 0,
    "ImageUrl": "/testitem.jpg",
    "Length": 0,
    "LengthUOM": "cm",
    "MPN": "",
    "PackCount": 0,
    "PackageGroupID": 1,
    "TaxClassID": 0,
    "UnitOfMeasure": "",
    "UPC": "",
    "Weight": 1,
    "WeightUOM": "kg",
    "Width": 0,
    "FlagBirthDefects": false,
    "HasKitGroups": false,
    "FlagCancer": false,
    "PriceGroup": 1,
    "Price": 10,
    "CurrencyCode": "usd",
    "OriginalPrice": 10,
    "OutOfStockStatus": 1,
    "Bonus": 0,
    "CV": 5,
    "QV": 4,
    "RewardPoints": 0,
    "StoreId": 0,
    "HasOptions": true,
    "PriceGroups": [
      1
    ],
    "StockLevels": [
      {
        "WarehouseId": 1,
        "ItemId": 1,
        "Avaliable": 100,
        "Committed": 100,
        "OnHand": 200,
        "OnOrder": 0,
        "OutOfStock": false,
        "TrackStock": 1
      }
    ],
    "KitGroups": [
      {
        "Name": "Kit Group 1",
        "Items": [
          {
            "ItemId": 22,
            "Name": "Kit 1 Item 1",
            "Quantity": 2
          },
          {
            "ItemId": 19,
            "Name": "Kit 1 Item 2",
            "Quantity": 1
          },
          {
            "ItemId": 97,
            "Name": "Kit 1 Item 3",
            "Quantity": 2
          }
        ]
      },
      {
        "Name": "Kit Group 2",
        "Items": [
          {
            "ItemId": 20,
            "Name": "Kit 2 Item 1",
            "Quantity": 1
          },
          {
            "ItemId": 21,
            "Name": "Kit 2 Item 2",
            "Quantity": 3
          }
        ]
      }
    ],
    "Images": [
      {
        "Description": "/testitem.jpg",
        "Path": "/testitem.jpg"
      }
    ],
    "Prices": [
      {
        "PriceGroupId": 1,
        "Price": 10,
        "PriceCurrency": "usd",
        "OriginalPrice": 10,
        "Bonus": 0,
        "CV": 5,
        "QV": 4,
        "RewardPoints": 0
      }
    ],
    "ItemOptions": [
      {
        "OptionId": 3,
        "Option": "Color",
        "OptionType": 1,
        "Values": [
          {
            "Option": "Blue",
            "SkuExt": "-B"
          },
          {
            "Option": "Green",
            "SkuExt": "-G"
          },
          {
            "Option": "Red",
            "SkuExt": "-R"
          }
        ]
      },
      {
        "OptionId": 4,
        "Option": "Size",
        "OptionType": 1,
        "Values": [
          {
            "Option": "Lage",
            "SkuExt": "-L"
          },
          {
            "Option": "Medium",
            "SkuExt": "-M"
          },
          {
            "Option": "Small",
            "SkuExt": "-S"
          }
        ]
      }
    ],
    "Languages": [
      {
        "Description": "<p>Test Item (desc)</p>",
        "LanguageCode": "en",
        "ProductName": "Test Item",
        "SeoKeywords": "",
        "Specifications": "<p>Test Item (specs)</p>"
      }
    ],
    "OptionsMap": [
      {
        "Key": "Red|Small",
        "Checked": true,
        "ItemId": 154,
        "Image": "",
        "ExtSku": "-R-S",
        "StockLevels": []
      },
      {
        "Key": "Red|Medium",
        "Checked": true,
        "ItemId": 155,
        "Image": "",
        "ExtSku": "-R-M",
        "StockLevels": []
      },
      {
        "Key": "Red|Lage",
        "Checked": true,
        "ItemId": 156,
        "Image": "",
        "ExtSku": "-R-L",
        "StockLevels": []
      },
      {
        "Key": "Green|Small",
        "Checked": true,
        "ItemId": 157,
        "Image": "",
        "ExtSku": "-G-S",
        "StockLevels": []
      },
      {
        "Key": "Green|Medium",
        "Checked": true,
        "ItemId": 158,
        "Image": "",
        "ExtSku": "-G-M",
        "StockLevels": []
      },
      {
        "Key": "Green|Lage",
        "Checked": true,
        "ItemId": 159,
        "Image": "",
        "ExtSku": "-G-L",
        "StockLevels": []
      },
      {
        "Key": "Blue|Small",
        "Checked": true,
        "ItemId": 160,
        "Image": "",
        "ExtSku": "-B-S",
        "StockLevels": []
      },
      {
        "Key": "Blue|Medium",
        "Checked": true,
        "ItemId": 161,
        "Image": "",
        "ExtSku": "-B-M",
        "StockLevels": []
      },
      {
        "Key": "Blue|Lage",
        "Checked": true,
        "ItemId": 162,
        "Image": "",
        "ExtSku": "-B-L",
        "StockLevels": []
      }
    ],
    "BillOfMaterials": [
      {
        "ItemId": 19,
        "Name": "BOM Item 1",
        "Quantity": 1
      },
      {
        "ItemId": 23,
        "Name": "BOM Item 2",
        "Quantity": 1
      }
    ]
  }
]
{
  "type": "array",
  "items": {
    "required": [
      "ItemID",
      "Quantity",
      "Cost",
      "ExtendedPrice",
      "ExtendedOriginalPrice",
      "ExtendedBonus",
      "ExtendedCV",
      "ExtendedQV",
      "ExtendedRewardPoints",
      "ExtendedCost",
      "ProductName",
      "Description",
      "Specifications",
      "SEO",
      "LanguageCode",
      "SKU",
      "Category",
      "CategoryId",
      "ChargeShipping",
      "Custom",
      "Height",
      "ImageUrl",
      "Length",
      "LengthUOM",
      "MPN",
      "PackCount",
      "PackageGroupID",
      "TaxClassID",
      "UnitOfMeasure",
      "UPC",
      "Weight",
      "WeightUOM",
      "Width",
      "FlagBirthDefects",
      "HasKitGroups",
      "FlagCancer",
      "PriceGroup",
      "Price",
      "CurrencyCode",
      "OriginalPrice",
      "OutOfStockStatus",
      "Bonus",
      "CV",
      "QV",
      "RewardPoints",
      "StoreId",
      "HasOptions",
      "PriceGroups",
      "StockLevels",
      "KitGroups",
      "Images",
      "Prices",
      "ItemOptions",
      "Languages",
      "OptionsMap",
      "BillOfMaterials"
    ],
    "type": "object",
    "properties": {
      "ItemID": {
        "type": "integer"
      },
      "Quantity": {
        "type": "integer"
      },
      "Cost": {
        "type": "integer"
      },
      "ExtendedPrice": {
        "type": "integer"
      },
      "ExtendedOriginalPrice": {
        "type": "integer"
      },
      "ExtendedBonus": {
        "type": "integer"
      },
      "ExtendedCV": {
        "type": "integer"
      },
      "ExtendedQV": {
        "type": "integer"
      },
      "ExtendedRewardPoints": {
        "type": "integer"
      },
      "ExtendedCost": {
        "type": "integer"
      },
      "ProductName": {
        "type": "string"
      },
      "Description": {
        "type": "string"
      },
      "Specifications": {
        "type": "string"
      },
      "SEO": {},
      "LanguageCode": {
        "type": "string"
      },
      "SKU": {
        "type": "string"
      },
      "Category": {
        "type": "string"
      },
      "CategoryId": {
        "type": "integer"
      },
      "ChargeShipping": {
        "type": "boolean"
      },
      "Custom": {
        "type": "object",
        "properties": {
          "ItemId": {
            "type": "integer"
          },
          "Field1": {
            "type": "string"
          },
          "Field2": {
            "type": "string"
          },
          "Field3": {
            "type": "string"
          },
          "Field4": {
            "type": "string"
          },
          "Field5": {
            "type": "string"
          }
        }
      },
      "Height": {
        "type": "integer"
      },
      "ImageUrl": {
        "type": "string"
      },
      "Length": {
        "type": "integer"
      },
      "LengthUOM": {
        "type": "string"
      },
      "MPN": {
        "type": "string"
      },
      "PackCount": {
        "type": "integer"
      },
      "PackageGroupID": {
        "type": "integer"
      },
      "TaxClassID": {
        "type": "integer"
      },
      "UnitOfMeasure": {
        "type": "string"
      },
      "UPC": {
        "type": "string"
      },
      "Weight": {
        "type": "integer"
      },
      "WeightUOM": {
        "type": "string"
      },
      "Width": {
        "type": "integer"
      },
      "FlagBirthDefects": {
        "type": "boolean"
      },
      "HasKitGroups": {
        "type": "boolean"
      },
      "FlagCancer": {
        "type": "boolean"
      },
      "PriceGroup": {
        "type": "integer"
      },
      "Price": {
        "type": "integer"
      },
      "CurrencyCode": {
        "type": "string"
      },
      "OriginalPrice": {
        "type": "integer"
      },
      "OutOfStockStatus": {
        "type": "integer"
      },
      "Bonus": {
        "type": "integer"
      },
      "CV": {
        "type": "integer"
      },
      "QV": {
        "type": "integer"
      },
      "RewardPoints": {
        "type": "integer"
      },
      "StoreId": {
        "type": "integer"
      },
      "HasOptions": {
        "type": "boolean"
      },
      "PriceGroups": {
        "type": "array",
        "items": {
          "type": "integer"
        }
      },
      "StockLevels": {
        "type": "array",
        "items": {
          "required": [
            "WarehouseId",
            "ItemId",
            "Avaliable",
            "Committed",
            "OnHand",
            "OnOrder",
            "OutOfStock",
            "TrackStock"
          ],
          "type": "object",
          "properties": {
            "WarehouseId": {
              "type": "integer"
            },
            "ItemId": {
              "type": "integer"
            },
            "Avaliable": {
              "type": "integer"
            },
            "Committed": {
              "type": "integer"
            },
            "OnHand": {
              "type": "integer"
            },
            "OnOrder": {
              "type": "integer"
            },
            "OutOfStock": {
              "type": "boolean"
            },
            "TrackStock": {
              "type": "integer"
            }
          }
        }
      },
      "KitGroups": {
        "type": "array",
        "items": {
          "required": [
            "Name",
            "Items"
          ],
          "type": "object",
          "properties": {
            "Name": {
              "type": "string"
            },
            "Items": {
              "type": "array",
              "items": {
                "required": [
                  "ItemId",
                  "Name",
                  "Quantity"
                ],
                "type": "object",
                "properties": {
                  "ItemId": {
                    "type": "integer"
                  },
                  "Name": {
                    "type": "string"
                  },
                  "Quantity": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      },
      "Images": {
        "type": "array",
        "items": {
          "required": [
            "Description",
            "Path"
          ],
          "type": "object",
          "properties": {
            "Description": {
              "type": "string"
            },
            "Path": {
              "type": "string"
            }
          }
        }
      },
      "Prices": {
        "type": "array",
        "items": {
          "required": [
            "PriceGroupId",
            "Price",
            "PriceCurrency",
            "OriginalPrice",
            "Bonus",
            "CV",
            "QV",
            "RewardPoints"
          ],
          "type": "object",
          "properties": {
            "PriceGroupId": {
              "type": "integer"
            },
            "Price": {
              "type": "integer"
            },
            "PriceCurrency": {
              "type": "string"
            },
            "OriginalPrice": {
              "type": "integer"
            },
            "Bonus": {
              "type": "integer"
            },
            "CV": {
              "type": "integer"
            },
            "QV": {
              "type": "integer"
            },
            "RewardPoints": {
              "type": "integer"
            }
          }
        }
      },
      "ItemOptions": {
        "type": "array",
        "items": {
          "required": [
            "OptionId",
            "Option",
            "OptionType",
            "Values"
          ],
          "type": "object",
          "properties": {
            "OptionId": {
              "type": "integer"
            },
            "Option": {
              "type": "string"
            },
            "OptionType": {
              "type": "integer"
            },
            "Values": {
              "type": "array",
              "items": {
                "required": [
                  "Option",
                  "SkuExt"
                ],
                "type": "object",
                "properties": {
                  "Option": {
                    "type": "string"
                  },
                  "SkuExt": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      },
      "Languages": {
        "type": "array",
        "items": {
          "required": [
            "Description",
            "LanguageCode",
            "ProductName",
            "SeoKeywords",
            "Specifications"
          ],
          "type": "object",
          "properties": {
            "Description": {
              "type": "string"
            },
            "LanguageCode": {
              "type": "string"
            },
            "ProductName": {
              "type": "string"
            },
            "SeoKeywords": {
              "type": "string"
            },
            "Specifications": {
              "type": "string"
            }
          }
        }
      },
      "OptionsMap": {
        "type": "array",
        "items": {
          "required": [
            "Key",
            "Checked",
            "ItemId",
            "Image",
            "ExtSku",
            "StockLevels"
          ],
          "type": "object",
          "properties": {
            "Key": {
              "type": "string"
            },
            "Checked": {
              "type": "boolean"
            },
            "ItemId": {
              "type": "integer"
            },
            "Image": {
              "type": "string"
            },
            "ExtSku": {
              "type": "string"
            },
            "StockLevels": {
              "type": "array"
            }
          }
        }
      },
      "BillOfMaterials": {
        "type": "array",
        "items": {
          "required": [
            "ItemId",
            "Name",
            "Quantity"
          ],
          "type": "object",
          "properties": {
            "ItemId": {
              "type": "integer"
            },
            "Name": {
              "type": "string"
            },
            "Quantity": {
              "type": "integer"
            }
          }
        }
      }
    }
  }
}

404 Not Found

A Category with the given Category ID was not found.

500 Internal Server Error

Something went wrong... Here are some possible reasons for this error:

  • Is the model being sent to the API incorrect?
  • Did you forget a required field?
  • Is the API marked as deprecated, and the date has expired?

If the answer is "No" to all of these questions, DirectScale could be experiencing technical difficulties. Please contact your DirectScale representative if the issue persists.

Code samples

@ECHO OFF

curl -v -X GET "https://dsapi.directscale.com/v1/products/categories/{categoryId}/topproducts?numberOfProducts={numberOfProducts}&CurrencyCode={CurrencyCode}&LanguageCode={LanguageCode}&RegionID={RegionID}&PriceGroup={PriceGroup}&StoreID={StoreID}?CountryCode=US"
-H "Ocp-Apim-Subscription-Key: {subscription key}"

--data-ascii "{body}" 
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;

namespace CSHttpClientSample
{
    static class Program
    {
        static void Main()
        {
            MakeRequest();
            Console.WriteLine("Hit ENTER to exit...");
            Console.ReadLine();
        }
        
        static async void MakeRequest()
        {
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            // Request headers
            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");

            // Request parameters
            queryString["CountryCode"] = "US";
            var uri = "https://dsapi.directscale.com/v1/products/categories/{categoryId}/topproducts?numberOfProducts={numberOfProducts}&CurrencyCode={CurrencyCode}&LanguageCode={LanguageCode}&RegionID={RegionID}&PriceGroup={PriceGroup}&StoreID={StoreID}&" + queryString;

            var response = await client.GetAsync(uri);
        }
    }
}	
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class JavaSample 
{
    public static void main(String[] args) 
    {
        HttpClient httpclient = HttpClients.createDefault();

        try
        {
            URIBuilder builder = new URIBuilder("https://dsapi.directscale.com/v1/products/categories/{categoryId}/topproducts?numberOfProducts={numberOfProducts}&CurrencyCode={CurrencyCode}&LanguageCode={LanguageCode}&RegionID={RegionID}&PriceGroup={PriceGroup}&StoreID={StoreID}");

            builder.setParameter("CountryCode", "US");

            URI uri = builder.build();
            HttpGet request = new HttpGet(uri);
            request.setHeader("Ocp-Apim-Subscription-Key", "{subscription key}");


            // Request body
            StringEntity reqEntity = new StringEntity("{body}");
            request.setEntity(reqEntity);

            HttpResponse response = httpclient.execute(request);
            HttpEntity entity = response.getEntity();

            if (entity != null) 
            {
                System.out.println(EntityUtils.toString(entity));
            }
        }
        catch (Exception e)
        {
            System.out.println(e.getMessage());
        }
    }
}

<!DOCTYPE html>
<html>
<head>
    <title>JSSample</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>

<script type="text/javascript">
    $(function() {
        var params = {
            // Request parameters
            "CountryCode": "US",
        };
      
        $.ajax({
            url: "https://dsapi.directscale.com/v1/products/categories/{categoryId}/topproducts?numberOfProducts={numberOfProducts}&CurrencyCode={CurrencyCode}&LanguageCode={LanguageCode}&RegionID={RegionID}&PriceGroup={PriceGroup}&StoreID={StoreID}&" + $.param(params),
            beforeSend: function(xhrObj){
                // Request headers
                xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
            },
            type: "GET",
            // Request body
            data: "{body}",
        })
        .done(function(data) {
            alert("success");
        })
        .fail(function() {
            alert("error");
        });
    });
</script>
</body>
</html>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
    NSString* path = @"https://dsapi.directscale.com/v1/products/categories/{categoryId}/topproducts?numberOfProducts={numberOfProducts}&CurrencyCode={CurrencyCode}&LanguageCode={LanguageCode}&RegionID={RegionID}&PriceGroup={PriceGroup}&StoreID={StoreID}";
    NSArray* array = @[
                         // Request parameters
                         @"entities=true",
                         @"CountryCode=US",
                      ];
    
    NSString* string = [array componentsJoinedByString:@"&"];
    path = [path stringByAppendingFormat:@"?%@", string];

    NSLog(@"%@", path);

    NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
    [_request setHTTPMethod:@"GET"];
    // Request headers
    [_request setValue:@"{subscription key}" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];
    // Request body
    [_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
    
    NSURLResponse *response = nil;
    NSError *error = nil;
    NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];

    if (nil != error)
    {
        NSLog(@"Error: %@", error);
    }
    else
    {
        NSError* error = nil;
        NSMutableDictionary* json = nil;
        NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
        NSLog(@"%@", dataString);
        
        if (nil != _connectionData)
        {
            json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
        }
        
        if (error || !json)
        {
            NSLog(@"Could not parse loaded json with error:%@", error);
        }
        
        NSLog(@"%@", json);
        _connectionData = nil;
    }
    
    [pool drain];

    return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';

$request = new Http_Request2('https://dsapi.directscale.com/v1/products/categories/{categoryId}/topproducts?numberOfProducts={numberOfProducts}&CurrencyCode={CurrencyCode}&LanguageCode={LanguageCode}&RegionID={RegionID}&PriceGroup={PriceGroup}&StoreID={StoreID}');
$url = $request->getUrl();

$headers = array(
    // Request headers
    'Ocp-Apim-Subscription-Key' => '{subscription key}',
);

$request->setHeader($headers);

$parameters = array(
    // Request parameters
    'CountryCode' => 'US',
);

$url->setQueryVariables($parameters);

$request->setMethod(HTTP_Request2::METHOD_GET);

// Request body
$request->setBody("{body}");

try
{
    $response = $request->send();
    echo $response->getBody();
}
catch (HttpException $ex)
{
    echo $ex;
}

?>
########### Python 2.7 #############
import httplib, urllib, base64

headers = {
    # Request headers
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.urlencode({
    # Request parameters
    'CountryCode': 'US',
})

try:
    conn = httplib.HTTPSConnection('dsapi.directscale.com')
    conn.request("GET", "/v1/products/categories/{categoryId}/topproducts?numberOfProducts={numberOfProducts}&CurrencyCode={CurrencyCode}&LanguageCode={LanguageCode}&RegionID={RegionID}&PriceGroup={PriceGroup}&StoreID={StoreID}&%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################

########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64

headers = {
    # Request headers
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.parse.urlencode({
    # Request parameters
    'CountryCode': 'US',
})

try:
    conn = http.client.HTTPSConnection('dsapi.directscale.com')
    conn.request("GET", "/v1/products/categories/{categoryId}/topproducts?numberOfProducts={numberOfProducts}&CurrencyCode={CurrencyCode}&LanguageCode={LanguageCode}&RegionID={RegionID}&PriceGroup={PriceGroup}&StoreID={StoreID}&%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################
require 'net/http'

uri = URI('https://dsapi.directscale.com/v1/products/categories/{categoryId}/topproducts?numberOfProducts={numberOfProducts}&CurrencyCode={CurrencyCode}&LanguageCode={LanguageCode}&RegionID={RegionID}&PriceGroup={PriceGroup}&StoreID={StoreID}')

query = URI.encode_www_form({
    # Request parameters
    'CountryCode' => 'US'
})

if uri.query && uri.query.length > 0
    uri.query += '&' + query
else
    uri.query = query
end

request = Net::HTTP::Get.new(uri.request_uri)
# Request headers
request['Ocp-Apim-Subscription-Key'] = '{subscription key}'
# Request body
request.body = "{body}"

response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
    http.request(request)
end

puts response.body