API – Product

General Online Reference

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/ProductService/help

 

GetProduct [GET]

The GetProduct operation retrieves a product from the shop based on a unique product number.

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • a product number (id) for the product
  • a site id

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the product number cannot be null
  • the site id cannot be null

Output

When successful the operation returns a product with basic attributes. For information on how to retrieve related data for product, see GetProductByMetadata operation.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/ProductService/help/operations/GetProduct

Code examples

C# (Console)

var key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
var endpointUrl = "http://{shopurl}/admin/webapi/Endpoints/v1_0/ProductService";
var productId = 304;
var siteId = 26;
var request = WebRequest.Create(endpointUrl + "/" + key + "/" + productId + "/" + siteId);
request.Method = "GET";
try
{
    var response = (HttpWebResponse)request.GetResponse();
    var dataStream = response.GetResponseStream();
    if (dataStream != null)
    {
        using (var reader = new StreamReader(dataStream))
        {
            var responseFromServer = reader.ReadToEnd();
            Console.Write(responseFromServer);
        }
        dataStream.Close();
    }
}
catch (WebException exception)
{
    var exceptionMessage = new StreamReader(exception.Response.GetResponseStream()).ReadToEnd();
    Console.Write(exceptionMessage);
}
Console.ReadLine();


PHP

<?php
//Endpoint url
$service_url = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/ProductService/";

//Your API key
$api_key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";

//Productnumber of existing product
$product_number = 304;

//Id of the site
$site_id = 26;

$curl = curl_init($service_url . $api_key . "/" . $product_number . "/" . $site_id);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($curl);

if ($response === false) {
 $info = curl_getinfo($curl);
 curl_close($curl);
 die('An error occured during servicecall. Info: ' . var_export($info));
}
curl_close($curl);
$decoded = json_decode($response);
var_export($decoded);
?>

GetProductsInCategory [GET]

The GetProductsInCategory operation retrieves a list of products in a product category from the shop.

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • a product category id
  • a site id

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the product category id cannot be null
  • the site id cannot be null

Output

When successful the operation returns a list of products in the product category. The response contains basic data for the products.  For information on how to retrieve related data for products, see GetProductByMetadata and GetProductsInCategoryByMetadata operations.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/ProductService/help/operations/GetProductsInCategory

Code examples

C# (Console)

var key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
var categoryNumber = "4";
var siteId = 26;
var endpointUrl = "http://{shopurl}/Admin/WebAPI/Endpoints/v1_0/ProductService/";

var request = WebRequest.Create(endpointUrl + "/" + key + "/Category/" + categoryNumber + "/" + siteId);
request.Method = "GET";
try
{
    var response = (HttpWebResponse)request.GetResponse();
    var dataStream = response.GetResponseStream();
    if (dataStream != null)
    {
        using (var reader = new StreamReader(dataStream))
        {
            var responseFromServer = reader.ReadToEnd();
            Console.Write(responseFromServer);
        }
        dataStream.Close();
    }
}
catch (WebException exception)
{
    var exceptionMessage = new StreamReader(exception.Response.GetResponseStream()).ReadToEnd();
    Console.Write(exceptionMessage);
}
Console.ReadLine();

PHP

<?php
//Endpoint url
$service_url = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/ProductService/";

//Your API key
$api_key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";

//Category id
$category_id = 4;

//Site id
$site_id = 26;

$curl = curl_init($service_url . $api_key . "/Products/" . $category_id . "/" . $site_id);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($curl);

if ($response === false) {
 $info = curl_getinfo($curl);
 curl_close($curl);
 die('An error occured during servicecall. Info: ' . var_export($info));
}
curl_close($curl);
$decoded = json_decode($response);
var_export($decoded);
?>

GetCategories [GET]

The GetCategories operation retrieves a list of main product categories from the shop.

Input

The operation takes the following input:

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the site id cannot be null

Output

When successful the operation returns a list of product categories. Only categories directly below the root category are returned.

Remarks

This operation is actually just a special case of the GetCategoriesInCategory operation, ie. a request for all subcategories in the root category (category id 0).

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/ProductService/help/operations/GetCategories

Code examples

C# (Console)

var key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
var endpointUrl = "http://{shopurl}/Admin/WebAPI/Endpoints/v1_0/ProductService/";
var siteId = 26;
var request = WebRequest.Create(endpointUrl + "/" + key + "/Categories/" + siteId);
request.Method = "GET";
try
{
    var response = (HttpWebResponse)request.GetResponse();
    var dataStream = response.GetResponseStream();
    if (dataStream != null)
    {
        using (var reader = new StreamReader(dataStream))
        {
            var responseFromServer = reader.ReadToEnd();
            Console.Write(responseFromServer);
        }
        dataStream.Close();
    }
}
catch (WebException exception)
{
    var exceptionMessage = new StreamReader(exception.Response.GetResponseStream()).ReadToEnd();
    Console.Write(exceptionMessage);
}
Console.ReadLine();

PHP

<?php
//Endpoint url
$service_url = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/ProductService/";

//Your API key
$api_key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";

//Site id
$site_id = 26;

$curl = curl_init($service_url . $api_key . "/Categories/" . $site_id );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($curl);

if ($response === false) {
 $info = curl_getinfo($curl);
 curl_close($curl);
 die('An error occured during servicecall. Info: ' . var_export($info));
}
curl_close($curl);
$decoded = json_decode($response);
var_export($decoded);
?>

GetSubCategories [GET]

The GetSubCategories operation retrieves a list of product subcategories in a product category from the shop.

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • a product category id
  • a site id

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the product category id cannot be null
  • the site id cannot be null

Output

When successful the operation returns a list of product categories.

Remarks

The root product category always has an id of 0, so all main categories can be retrieved with a request for subcategories in category 0.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/ProductService/help/operations/GetSubCategories

Code examples

C# (Console)

var key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
//existing category
var categoryNumbers = "4";
var endpointUrl = "http://{shopurl}/Admin/WebAPI/Endpoints/v1_0/ProductService/";
var siteId = 26;

var request = WebRequest.Create(endpointUrl + "/" + key + "/Categories/" + categoryNumber + "/" + siteId);
request.Method = "GET";
try
{
    var response = (HttpWebResponse)request.GetResponse();
    var dataStream = response.GetResponseStream();
    if (dataStream != null)
    {
        using (var reader = new StreamReader(dataStream))
        {
            var responseFromServer = reader.ReadToEnd();
            Console.Write(responseFromServer);
        }
        dataStream.Close();
    }
}
catch (WebException exception)
{
    var exceptionMessage = new StreamReader(exception.Response.GetResponseStream()).ReadToEnd();
    Console.Write(exceptionMessage);
}
Console.ReadLine();

PHP

<?php
//Endpoint url
$service_url = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/ProductService/";

//Your API key
$api_key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";

//Category id
$category_id = 4;

//Site id
$site_id = 26;

$curl = curl_init($service_url . $api_key . "/Categories/" . $category_id . "/" . $site_id);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($curl);

if ($response === false) {
 $info = curl_getinfo($curl);
 curl_close($curl);
 die('An error occured during servicecall. Info: ' . var_export($info));
}
curl_close($curl);
$decoded = json_decode($response);
var_export($decoded);
?>

GetProductByMetadata [POST]

The GetProductByMetadata operation retrieves a product from the shop based on a unique product number and a context object. The metadata object indicates which related data to the product the operation will return.

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • a product number (id) for the product
  • a context object

The Context object got the following attributes:

    {
        "siteId": 26,
        "customerId": "",
        "currencyCode": "DKK",
        "productMetadata":
            {
                "buyInfo": true,
                "categories": true,
                "currentPrice": true,
                "images": true,
                "info": true,
                "longDescriptions": true,
                "manufacturers": true,
                "prices": true,
                "related": true,
                "segments": true,
                "stockInfo": true,
                "technicalDocuments": true,
                "type": true,
                "variants": true
            }
    }

 

  • if siteId is not supplied, the shops default site will be used
  • if currencyCode is not suppled, the currency of the supplied or derived site will be used
  • if customerId is not supplied, no customer settings will be uses in the pricecalculation.

All attributes in the metadata object can be omitted or have the value true or false.

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the product number cannot be null
  • all attributes in the context object is optional

Output

When successful the operation returns a product. The output is based on the attributevalues in prooductMetadata attribute in the context object.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/ProductService/help/operations/GetProductByMetadata

Code examples

C# (Console)

//Your api key
var key = "05b4df18-6fb5-4249-9506-f376e3177280";
var endpointUrl = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/ProductService";
//Existing product number
var productNumber = 304;
//Existin site id
var siteId = 26;

var context = new
{
    siteId = siteId,
    customerId = "",
    currentcyCode = "",
    productMetadata = new
    {
        buyInfo = true,
        categories = true,
        currentPrice = true,
        images = true,
        info = true,
        longDescriptions = true,
        manufacturers = true,
        prices = true,
        related = true,
        segments = true,
        stockInfo = true,
        technicalDocuments = true,
        type = true,
        variants = true,
    },
};
            
var jSon = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(context);
var request = WebRequest.Create(endpointUrl + "/" + key + "/" + productNumber);
request.Method = "POST";
request.ContentType = "text/json";
using (var writeStream = new StreamWriter(request.GetRequestStream()))
{
    writeStream.Write(jSon);
    writeStream.Flush();
    writeStream.Close();
}
try
{
    var response = (HttpWebResponse)request.GetResponse();
    var dataStream = response.GetResponseStream();
    if (dataStream != null)
    {
        using (var reader = new StreamReader(dataStream))
        {
            var responseFromServer = reader.ReadToEnd();
            Console.Write(responseFromServer);
        }
        dataStream.Close();
    }
}
catch (WebException exception)
{
    var exceptionMessage = new StreamReader(exception.Response.GetResponseStream()).ReadToEnd();
    Console.Write(exceptionMessage);
}
Console.ReadLine();

GetProductsInCategoryByMetadata [POST]

The GetProductsInCategoryByMetadata operation retrieves a list of products in a product category from the shop.

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • a product category id
  • a context object

For further information about the context object, see the GetProductByMetadata page.

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the product category id cannot be null
  • all attributes in the context object is optional
  • if supplied, all attributes in the metadata object is optional

Output

When successful the operation returns a list of products in the product category.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/ProductService/help/operations/GetProductsInCategoryByMetadata

 


GetCategory [GET]

The GetCategory operation retrieves a category from the shop based on a unique category number.

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • a category number (id) for the category
  • a site id

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the category number cannot be null
  • the site id cannot be null

Output

When successful the operation returns a category.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/ProductService/help/operations/GetCategory

 


FindProductNumbersByKeyword [GET]

The FindProductNumbersByKeyword operation retrieves a list of product numbers matching a specified keyword.

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • a site id
  • a keyword

Optional parameters

The result can be paged by adding the following query parameters:

page_size=numberOfResultsPerPage
page=theActualPageNumberToGet

/FindProductNumbersByKeyword/myKeyword/siteId?page_size=10&page=1

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)

Output

When successful the operation returns a list of product id’s matching the specified keyword.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/ProductService/help/operations/FindProductNumbersByKeyword

 


GetProductsByBarcode[GET]

The GetProductsByBarcode operation gets all products that matches the specified barcode

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • a barcode number
  • a site Id

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the site id cannot be null

The product READ permission is required to perform this operation.

Output

The operation returns a liste of products

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/ProductService/help/operations/GetProductsByBarcode

 


GetProductsByModificationDate [GET]

The GetProductsByModificationDate operation gets all products that has been modifed since the specified date.

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • a modification date
  • a site Id

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the modification date must be valid
  • the site id cannot be null

The product READ permission is required to perform this operation.

Output

The operation returns a liste of products

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/ProductService/help/operations/GetProductsByModificationDate

 


FindProductsByProductNumbers[POST]

The FindProductsByProductNumbers operation gets products matching list of productnumbers

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • a site Id
  • a request object composed of a list of product indentifies and paging info

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the site id cannot be null

The product READ permission is required to perform this operation.

Output

The operation returns a liste of products

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/ProductService/help/operations/FindProductsByProductNumbers

 


GetProductsInModifiedInterval[GET]

The GetProductsInModifiedInterval operation gets products that has been modified between the specied start and end date.

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • a site Id
  • a start date
  • an end date

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the site id cannot be null
  • the start date must be valid
  • the end date must be valid

The product READ permission is required to perform this operation.

Output

The operation returns a liste of products

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/ProductService/help/operations/GetProductsInModifiedInterval

 


Du finder dokumentationen til Dandomain Webshop her: https://webshop-help.dandomain.dk x