ecomdash API

The ecomdash API allows third party software to integrate with the inventory management module of ecomdash.

Inventory - Top Selling Products by Month

Find the top selling products for a particular month/year, pass in a storefront ID to find the top selling products on a particular storefront for the month.

Try it

Request URL

Request parameters

(optional)
number

If you want the top selling products for the month across all storefronts, leave this empty.

If you want the top selling products for the month for a specific storefront, pass in the ID for the storefront. You can find the IDs for storefronts using the "Storefronts - Get List" API call.

(optional)
number

The 4-digit year you want the top selling products for. If ommitted, the year of the month prior to the current month is used.

(optional)
number

The numeric month (1-12) you want the top selling products for. If ommitted, the month prior to the current month is used.

Request headers

string

The API integration key from the ecomdash account. This can be found by an ecomdash customer in ecomdash under Administration --> Settings, on the "Tools" tab.

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

Request body

Response 200

The top 10 selling products for the month/year are returned.

{
  "status": "Success",
  "messages": [],
  "data": [
    {
      "CompanyId": 136,
      "Month": 2,
      "Year": 2017,
      "SalesChannelId": 1234,
      "ProductId": 2466886,
      "SkuNumber": "x27302",
      "Name": "Sample Product 1",
      "Rank": 1,
      "QuantitySold": 2,
      "AmountSold": 27.88
    },
    {
      "CompanyId": 136,
      "Month": 2,
      "Year": 2017,
      "SalesChannelId": 1234,
      "ProductId": 2467141,
      "SkuNumber": "x25148",
      "Name": "Sample Product 2",
      "Rank": 2,
      "QuantitySold": 2,
      "AmountSold": 17.99
    },
    {
      "CompanyId": 136,
      "Month": 2,
      "Year": 2017,
      "SalesChannelId": 1234,
      "ProductId": 2475082,
      "SkuNumber": "x235183",
      "Name": "Sample Product 3",
      "Rank": 3,
      "QuantitySold": 2,
      "AmountSold": 176.99
    },
    {
      "CompanyId": 136,
      "Month": 2,
      "Year": 2017,
      "SalesChannelId": 1234,
      "ProductId": 2484983,
      "SkuNumber": "b419953",
      "Name": "Sample Product 4",
      "Rank": 4,
      "QuantitySold": 2,
      "AmountSold": 9.99
    },
    {
      "CompanyId": 136,
      "Month": 2,
      "Year": 2017,
      "SalesChannelId": 1234,
      "ProductId": 2464521,
      "SkuNumber": "x23574",
      "Name": "Sample Product 5",
      "Rank": 5,
      "QuantitySold": 2,
      "AmountSold": 29.98
    },
    {
      "CompanyId": 136,
      "Month": 2,
      "Year": 2017,
      "SalesChannelId": 1234,
      "ProductId": 2464688,
      "SkuNumber": "x23623",
      "Name": "Sample Product 6",
      "Rank": 6,
      "QuantitySold": 2,
      "AmountSold": 17.98
    },
    {
      "CompanyId": 136,
      "Month": 2,
      "Year": 2017,
      "SalesChannelId": 1234,
      "ProductId": 2465478,
      "SkuNumber": "x24577",
      "Name": "Sample Product 7",
      "Rank": 7,
      "QuantitySold": 1,
      "AmountSold": 14.35
    },
    {
      "CompanyId": 136,
      "Month": 2,
      "Year": 2017,
      "SalesChannelId": 1234,
      "ProductId": 2465634,
      "SkuNumber": "x24337",
      "Name": "Sample Product 8",
      "Rank": 8,
      "QuantitySold": 1,
      "AmountSold": 16.99
    },
    {
      "CompanyId": 136,
      "Month": 2,
      "Year": 2017,
      "SalesChannelId": 1234,
      "ProductId": 2465649,
      "SkuNumber": "x24338",
      "Name": "Sample Product 9",
      "Rank": 9,
      "QuantitySold": 1,
      "AmountSold": 16.99
    },
    {
      "CompanyId": 136,
      "Month": 2,
      "Year": 2017,
      "SalesChannelId": 1234,
      "ProductId": 2466832,
      "SkuNumber": "x25085",
      "Name": "Sample Product 10",
      "Rank": 10,
      "QuantitySold": 1,
      "AmountSold": 15.87
    }
  ]
}
{
  "title": "ResponseListTopSellingProduct",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "status": {
      "type": "string"
    },
    "messages": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "pagination": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "CurrentPage": {
          "type": "integer",
          "format": "int32"
        },
        "TotalNumberOfEntries": {
          "type": "integer",
          "format": "int32"
        },
        "TotalNumberOfPages": {
          "type": "integer",
          "format": "int32"
        }
      }
    },
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "CompanyId": {
            "type": "number",
            "format": "decimal"
          },
          "Month": {
            "type": "integer",
            "format": "int32"
          },
          "Year": {
            "type": "integer",
            "format": "int32"
          },
          "SalesChannelId": {
            "type": "number",
            "format": "decimal"
          },
          "ProductId": {
            "type": "number",
            "format": "decimal"
          },
          "SkuNumber": {
            "type": "string"
          },
          "Name": {
            "type": "string"
          },
          "Rank": {
            "type": "integer",
            "format": "int32"
          },
          "QuantitySold": {
            "type": "integer",
            "format": "int32"
          },
          "AmountSold": {
            "type": "number",
            "format": "decimal"
          }
        }
      }
    }
  }
}

Response 403

If you have provided an invalid "ecd-subscription-key", you will receive a 403 FORBIDDEN response. This will happen for the following reasons:

  • The "ecd-subscription-key" was missing or it not found in the ecomdash databases
  • The "ecd-subscription-key" was found, but the company attached to it does not have a current ecomdash subscription.
  • The provided "ecd-subscription-key" is associated with an AppStore subscription, but the associated "application-id" header was either missing or not the same one associated with the " ecd-subscription-key".

{
  "Message": "The provided 'ecd-subscription-key' / 'application-id' combination is not valid or does not belong to a company with a current ecomdash subscription."
}

Code samples

@ECHO OFF

curl -v -X GET "https://ecomdash.azure-api.net/api/Inventory/TopSelling?storefrontId={number}&year={number}&month={number}"
-H "ecd-subscription-key: "
-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("ecd-subscription-key", "");
            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");

            // Request parameters
            queryString["storefrontId"] = "{number}";
            queryString["year"] = "{number}";
            queryString["month"] = "{number}";
            var uri = "https://ecomdash.azure-api.net/api/Inventory/TopSelling?" + 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://ecomdash.azure-api.net/api/Inventory/TopSelling");

            builder.setParameter("storefrontId", "{number}");
            builder.setParameter("year", "{number}");
            builder.setParameter("month", "{number}");

            URI uri = builder.build();
            HttpGet request = new HttpGet(uri);
            request.setHeader("ecd-subscription-key", "");
            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
            "storefrontId": "{number}",
            "year": "{number}",
            "month": "{number}",
        };
      
        $.ajax({
            url: "https://ecomdash.azure-api.net/api/Inventory/TopSelling?" + $.param(params),
            beforeSend: function(xhrObj){
                // Request headers
                xhrObj.setRequestHeader("ecd-subscription-key","");
                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://ecomdash.azure-api.net/api/Inventory/TopSelling";
    NSArray* array = @[
                         // Request parameters
                         @"entities=true",
                         @"storefrontId={number}",
                         @"year={number}",
                         @"month={number}",
                      ];
    
    NSString* string = [array componentsJoinedByString:@"&"];
    path = [path stringByAppendingFormat:@"?%@", string];

    NSLog(@"%@", path);

    NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
    [_request setHTTPMethod:@"GET"];
    // Request headers
    [_request setValue:@"" forHTTPHeaderField:@"ecd-subscription-key"];
    [_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://ecomdash.azure-api.net/api/Inventory/TopSelling');
$url = $request->getUrl();

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

$request->setHeader($headers);

$parameters = array(
    // Request parameters
    'storefrontId' => '{number}',
    'year' => '{number}',
    'month' => '{number}',
);

$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
    'ecd-subscription-key': '',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.urlencode({
    # Request parameters
    'storefrontId': '{number}',
    'year': '{number}',
    'month': '{number}',
})

try:
    conn = httplib.HTTPSConnection('ecomdash.azure-api.net')
    conn.request("GET", "/api/Inventory/TopSelling?%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
    'ecd-subscription-key': '',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.parse.urlencode({
    # Request parameters
    'storefrontId': '{number}',
    'year': '{number}',
    'month': '{number}',
})

try:
    conn = http.client.HTTPSConnection('ecomdash.azure-api.net')
    conn.request("GET", "/api/Inventory/TopSelling?%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://ecomdash.azure-api.net/api/Inventory/TopSelling')

query = URI.encode_www_form({
    # Request parameters
    'storefrontId' => '{number}',
    'year' => '{number}',
    'month' => '{number}'
})

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['ecd-subscription-key'] = ''
# 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