XyloCode.ThirdPartyServices.YandexMarket 1.0.0

Prefix Reserved
dotnet add package XyloCode.ThirdPartyServices.YandexMarket --version 1.0.0                
NuGet\Install-Package XyloCode.ThirdPartyServices.YandexMarket -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XyloCode.ThirdPartyServices.YandexMarket" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add XyloCode.ThirdPartyServices.YandexMarket --version 1.0.0                
#r "nuget: XyloCode.ThirdPartyServices.YandexMarket, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install XyloCode.ThirdPartyServices.YandexMarket as a Cake Addin
#addin nuget:?package=XyloCode.ThirdPartyServices.YandexMarket&version=1.0.0

// Install XyloCode.ThirdPartyServices.YandexMarket as a Cake Tool
#tool nuget:?package=XyloCode.ThirdPartyServices.YandexMarket&version=1.0.0                

Yandex.Market Content API Client

An unofficial client library for accessing the Yandex.Market Content API via ApiSystem.

The service allows you to get lists of product categories, product features and their images and reviews.

The class structure is based on the official Yandex documentation and was created in 2020.

Yandex.Market

Yandex Market (Russian: Яндекс Маркет, tr. Yandeks Market; stylised as Yandex.Market) is a Russian online service for the selection of goods and shopping. The service was launched on November 30, 2000 by Yandex. Since 2016, it is a separate company.

The service has a daily audience of over 4 million users and monthly audience of 20 million.

Official website:

ApiSystem

After Sberbank bought Yandex.Market in 2020 and launched the Beru marketplace, the official content API was closed.

At the moment, access is possible through the ApiSystem proxy service.

Official website:

How to use

using System.Text;
using XyloCode.ThirdPartyServices.YandexMarket;
using XyloCode.ThirdPartyServices.YandexMarket.Enum;
using XyloCode.ThirdPartyServices.YandexMarket.QueryModels;
using XyloCode.ThirdPartyServices.YandexMarket.ResponseModels;


namespace YandexMarketConsoleApp
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string server = "http://market.apisystem.name/";
            string apiKey = "Get a token on the site https://www.apisystem.name/";
            var market = new YandexMarketConnection(server, apiKey);

            string jsonContent;

            #region Regions
            var childRegionQueue = new Queue<int>();
            var parentRegionQueue = new Queue<int>();

            RegionListResponseModel regionListResponse;
            RegionChildrenListResponseModel regionChildrenListResponse;


            var regionsRootRequest = new RegionListQueryModel()
            {
                count = 30,
                page = 0,
                fields = RegionFields.ALL,
            };

            do
            {
                regionsRootRequest.page++;
                regionListResponse = market.Request<RegionListQueryModel, RegionListResponseModel>(regionsRootRequest, out jsonContent);
                SaveToFile(jsonContent, $"RegionList_root_{regionsRootRequest.page}.json");

                foreach (var region in regionListResponse.Regions)
                {
                    if (region.ChildCount > 0)
                    {
                        childRegionQueue.Enqueue(region.Id);
                    }

                    if (region.ParentId > 0)
                    {
                        parentRegionQueue.Enqueue(region.ParentId.Value);
                    }
                }

                
            } while (regionsRootRequest.page < regionListResponse.Context.Page.Total);


            while (childRegionQueue.Count > 0)
            {
                var parent = childRegionQueue.Dequeue();
                var childRegionRequest = new RegionChildrenListQueryModel(parent)
                {
                    count = 30,
                    page = 0,
                    fields = RegionFields.ALL,
                };

                do
                {
                    childRegionRequest.page++;
                    regionChildrenListResponse = market.Request<RegionChildrenListQueryModel, RegionChildrenListResponseModel>(childRegionRequest, out jsonContent);
                    SaveToFile(jsonContent, $"RegionList_ChildOf_{parent}_{childRegionRequest.page}.json");

                    foreach (var region in regionListResponse.Regions)
                    {
                        if (region.ChildCount > 0)
                        {
                            childRegionQueue.Enqueue(region.Id);
                        }
                    }
                } while (childRegionRequest.page < regionChildrenListResponse.Context.Page.Total);
            }

            while (parentRegionQueue.Count > 0)
            {
                // like childRegionQueue
                break;
            }
            #endregion Regions


            #region Categories
            CategoryListResponseModel categoryListResponse;
            CategoryChildrenListResponseModel categoryChildrenListResponse;

            int example_region_id = 2;
            var categoryListRequest = new CategoryListQueryModel(example_region_id)
            {
                count = 30,
                page = 0,
                fields = CategoryFields.ALL,
            };

            // next like Regions
            #endregion Categories


            #region Top Models
            ModelPopularListResponseModel popularListResponse;
            
            int exampleCategoryId = 123;
            var popularListRequest = new ModelPopularListQueryModel(exampleCategoryId)
            {
                count = 30,
                page = 0,
                fields = ModelFields.STANDARD,
            };

            do
            {
                popularListRequest.page++;
                popularListResponse = market.Request<ModelPopularListQueryModel, ModelPopularListResponseModel>(popularListRequest, out jsonContent);
                SaveToFile(jsonContent, $"PopModels_Category_{exampleCategoryId}_{popularListRequest.page}.json");

            } while (popularListRequest.page < popularListResponse.Context.Page.Total);
            #endregion Top Models


            Console.Beep();
            Console.WriteLine("End!");
        }


        public static void SaveToFile(string jsonContent, string fileName)
        {

            var sw = new StreamWriter($"{fileName}", false, Encoding.UTF8);
            sw.WriteLine(jsonContent);
            sw.Close();
        }
    }
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 172 5/21/2023