Get All Products By Saved View - Sellercloud API Docs

Get All Products By Saved View

Overview

This endpoint is used for getting products in bulk, using a saved view. A saved view for catalogs must be created from manage catalog page in the new SellerCloud UI.

The advantages of using this endpoint for getting catalogs are as follows:

In order to get information for products by saved view, you can consume the endpoint presented in this article. However in order to do that, you must:

  1. Be an authenticated user. For information on how you can authenticate, see: Authentication. As soon as you authenticate and receive a valid token, it needs to be passed on this call for getting products.
  2. Have a valid ID of a currently existing saved view. For information on how you can get existing saved views, see Saved Views

Endpoint

The endpoint for the TT server would be:

https://tt.api.sellercloud.com/rest/api/catalog/getallbyview?request.ViewID=100&request.pageNumber=1&request.pageSize=50

For your server, the endpoint will be:

https://{your_server_id}.api.sellercloud.com/rest/api/catalog/GetAllByView?request.ViewID=100&request.pageNumber=1&request.pageSize=50

Request

Information about expected request parameters can be found on swagger UI https://tt.api.sellercloud.com/rest/swagger.

Parameters Data Type Description Is Required
pageNumber integer Page number Yes
pageSize integer Number of products per page.
NOTE:
Maximum number of products that can be pulled with a single call is 50.
Yes
viewID integer ID of existing catalog saved view Yes

Response

Different status codes can be found in this section here: https://developer.sellercloud.com/dev-category/resources/

Demo in c#

string baseUri = "http://{server_id}.api.sellercloud.com/rest";
string url = $"{baseUri}/api/catalog/GetAllByView?request.ViewID=1&request.pageNumber=1&request.pageSize=50";
string username = "{your_username}";
string password = "{your_password}";

IAuthenticationClient authenticationClient = new AuthenticationClient();

string token = authenticationClient.Login(baseUri, new LoginRequest(username, password));

using (var client = new HttpClient())
{
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
    var responseMessage = client.GetAsync(url).Result;
    var content = responseMessage.Content.ReadAsStringAsync().Result;
    return JsonConvert.DeserializeObject<GetAllResponse>(content);
}
public class AuthenticationClient : IAuthenticationClient
{
    public string Login(string baseUri, LoginRequest loginRequest)
    {
        using (var client = new HttpClient())
        using (var request = new HttpRequestMessage(HttpMethod.Post, $"{baseUri}/api/token"))
        {
            var json = JsonConvert.SerializeObject(loginRequest);
            using (var stringContent = new StringContent(json, Encoding.UTF8, "application/json"))
            {
                request.Content = stringContent; 
                var responseMessage = client.SendAsync(request).Result;
                var content = responseMessage.Content.ReadAsStringAsync().Result;
                var response = JsonConvert.DeserializeObject(content);
                return response.access_token;
            }
        }
    }
}
public class LoginResponse
{
    public string token_type { get; set; }
    public string access_token { get; set; }
    public DateTime? validFrom { get; set; }
    public DateTime? validTo { get; set; }
}
public interface IAuthenticationClient
{
    string Login(string baseUri, LoginRequest request);
}
public class LoginRequest
{
    public LoginRequest(string username, string password)
    {
        this.Username = username;
        this.Password = password;
    }
    public string Username { get; }
    public string Password { get; }
}