ProductsFindPage Endpoint

Overview

Grabbing a list of products by page is probably one of the most common things that you might think to do.  This endpoint allows you to find a paged list of all products in your store.

Requirements

The following pre-requisites will be necessary to accomplish the goals of this article:

  • General understanding of REST and API’s
  • Understanding of C# and/or JavaScript
  • Visual Studio 2012 or newer

Getting Started

You should already have a project open and ready to accept code to allow you to use this REST API endpoint.  You should also have one or more products created so that you can successfully find one or more in a list.

ProductsFindPage

This REST API endpoint allows you to find a paged listing of all products in your store. 

Example URL

This is what the REST endpoint will look like if you are calling it using JavaScript.  See our REST API URL documentation for more information.

http://yourdomain.com/DesktopModules/Hotcakes/API/rest/v1/products/?key=[YOURKEY]&page=[PAGE]&pagesize=[PAGESIZE]

HTTP Method

GET

Parameters

Parameter Description
page Put in the page number of results that you wish to return. If this is a first request, then 1 would be appropriate to return the first page of results.
pagesize The size of the page will dictate how many products are returned for each page. You should keep this value consistent for every request.

Returns

If successful, this endpoint will return a populated PageOfProducts object in JSON format.  Otherwise, you should have one or more errors returned.  

Example Code

The following code will allow you to successfully call this endpoint, provided that you have enabled it.

Project References

  • Hotcakes.CommerceDTO

Import Namespaces

  • Hotcakes.CommerceDTO.v1
  • Hotcakes.CommerceDTO.v1.Catalog
  • Hotcakes.CommerceDTO.v1.Client

 

string url = "http://YOURDOMAIN.COM";
string key = "YOUR-API-KEY";

Api proxy = new Api(url, key);

// specify the page number to retrieve
var page = 1;

// specify the number of results per page
var pageSize = 2; // if you want all products, then use int.MaxValue here

// call the API to find all products in the store matching the page criteria
ApiResponse<PageOfProducts> response = proxy.ProductsFindPage(page, pageSize);
// your domain name
var url = "http://YOURDOMAIN.COM"; 
// the path where the API is
var apiPath = "/DesktopModules/Hotcakes/API/rest/v1/";  
// endpoint as shown in the documentation
var endPoint = "products";  
// get this from the store admin
var apiKey = "YOUR-API-KEY";

$(document).ready(function() {

    // specify the page number to retrieve
    var page = 1;

    // specify the number of results per page
    var pageSize = 2; // if you want all products, then use int.MAX_VALUE here

    // call the API to find all products in the store matching the page criteria
    $.ajax({
        dataType: "json",
        url: url + apiPath + endPoint + "?key=" + apiKey + "&page=" + page + "&pagesize=" + pageSize,
        type: 'GET',
        success: function (data) {
            // do something
        },
        error: function (jqXHR, textStatus) {
           // do something else
        }
    });

});
{
   "Errors":[

   ],
   "Content":{
      "Products":[
         {
            "Bvin":"142034eb-dc7b-4e20-989b-2efedca66150",
            "Sku":"SAMPLE001",
            "ProductName":"Blue Bracelet",
            "ProductTypeId":"",
            "CustomProperties":[
               {
                  "DeveloperId":"hcc",
                  "Key":"swatchpath",
                  "Value":""
               }
            ],
            "ListPrice":0.0000000000,
            "SitePrice":42.9500000000,
            "SitePriceOverrideText":"",
            "SiteCost":0.0000000000,
            "MetaKeywords":"Blue,Bracelet,Sample,Demo",
            "MetaDescription":"Sample Blue Bracelet for Demonstration",
            "MetaTitle":"Sample Blue Bracelet",
            "TaxExempt":false,
            "TaxSchedule":-1,
            "ShippingDetails":{
               "IsNonShipping":false,
               "ExtraShipFee":0.0000000000,
               "Weight":2.0000000000,
               "Length":6.0000000000,
               "Width":6.0000000000,
               "Height":3.0000000000,
               "ShippingSource":1,
               "ShippingSourceId":"",
               "ShipSeparately":false
            },
            "ShippingMode":1,
            "Status":1,
            "ImageFileSmall":"BraceletBlue.png",
            "ImageFileSmallAlternateText":"Blue Bracelet SAMPLE001",
            "ImageFileMedium":"BraceletBlue.png",
            "ImageFileMediumAlternateText":"Blue Bracelet SAMPLE001",
            "CreationDateUtc":"\/Date(1398071723923)\/",
            "MinimumQty":1,
            "ShortDescription":"",
            "LongDescription":"An incredible blue bracelet sample product. This item is not actually for sale. It is a sample product to demonstrate how your store may look with products loaded",
            "ManufacturerId":"",
            "VendorId":"",
            "GiftWrapAllowed":false,
            "GiftWrapPrice":0.0000000000,
            "Keywords":"bracelett",
            "PreContentColumnId":"",
            "PostContentColumnId":"",
            "UrlSlug":"blue-bracelet",
            "InventoryMode":100,
            "IsAvailableForSale":true,
            "Featured":true,
            "AllowReviews":true,
            "Tabs":[
               {
                  "Bvin":"711cbc90-0d7b-4682-a769-c8226b1db3b3",
                  "TabTitle":"Sustainability",
                  "HtmlData":"\u003cp\u003eAll of our jewelry products are recycled and made in sustainable eco-friendly environments\u003c/p\u003e",
                  "SortOrder":1
               }
            ],
            "StoreId":1
         },
         {
            "Bvin":"e4ef52ac-086c-4986-856d-c17a054b69ca",
            "Sku":"SAMPLE004",
            "ProductName":"Brown Fedora",
            "ProductTypeId":"",
            "CustomProperties":[
               {
                  "DeveloperId":"hcc",
                  "Key":"swatchpath",
                  "Value":""
               }
            ],
            "ListPrice":0.0000000000,
            "SitePrice":59.8700000000,
            "SitePriceOverrideText":"",
            "SiteCost":0.0000000000,
            "MetaKeywords":"",
            "MetaDescription":"",
            "MetaTitle":"",
            "TaxExempt":false,
            "TaxSchedule":-1,
            "ShippingDetails":{
               "IsNonShipping":false,
               "ExtraShipFee":0.0000000000,
               "Weight":20.0000000000,
               "Length":12.0000000000,
               "Width":12.0000000000,
               "Height":10.0000000000,
               "ShippingSource":1,
               "ShippingSourceId":"",
               "ShipSeparately":false
            },
            "ShippingMode":1,
            "Status":1,
            "ImageFileSmall":"indiana-jones-hat.jpg",
            "ImageFileSmallAlternateText":"Brown Fedora SAMPLE004",
            "ImageFileMedium":"indiana-jones-hat.jpg",
            "ImageFileMediumAlternateText":"Brown Fedora SAMPLE004",
            "CreationDateUtc":"\/Date(1398071726013)\/",
            "MinimumQty":1,
            "ShortDescription":"",
            "LongDescription":"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum",
            "ManufacturerId":"",
            "VendorId":"",
            "GiftWrapAllowed":false,
            "GiftWrapPrice":0.0000000000,
            "Keywords":"",
            "PreContentColumnId":"",
            "PostContentColumnId":"",
            "UrlSlug":"brown-fedora",
            "InventoryMode":100,
            "IsAvailableForSale":true,
            "Featured":true,
            "AllowReviews":true,
            "Tabs":[

            ],
            "StoreId":1
         }
      ],
      "TotalProductCount":0
   }
}
Have more questions? Submit a request

Need More Help?

Do you need more assistance with this article? Please review your support options.