All Products
Search
Document Center

Image Search:SDK for .Net

Last Updated:Apr 22, 2024

This topic describes how to use Image Search SDK for .NET and provides sample code.

Methods

Method

Description

Add

Adds an image.

SearchImageByPic

Searches for similar images based on an image.

SearchImageByName

Searches for similar images based on the name of an existing image in the image gallery.

Delete

Removes one or more images.

UpdateImage

Updates an image.

Detail

Queries the information about an instance.

DumpMeta

Creates a task to export metadata.

DumpMetaList

Queries a list of tasks that are used to export metadata.

BatchTask

Creates a batch task.

BatchTaskList

Queries a list of tasks that are used to perform batch operations.

Preparations

Before you install and use an Alibaba Cloud SDK, make sure that you have created an Alibaba Cloud account and obtained the AccessKey pair of the Alibaba Cloud account. For more information, see Obtain an AccessKey pair.

  1. In Solution Explorer, right-click your project and select Manage NuGet Packages.

  2. On the page that appears, click the Browse tab and enter AlibabaCloud.SDK.ImageSearch20201214.

  3. Click Install.

Add

  • Sample code

    using AlibabaCloud.OpenApiClient.Models;
    using AlibabaCloud.SDK.ImageSearch20201214.Models;
    using AlibabaCloud.SDK.ImageSearch20201214;
    using AlibabaCloud.TeaUtil.Models;
    using System;
    using System.IO;
    namespace Test
    {
        class Add
        {
            static void Main(string[] args)
            {
                // Console.WriteLine("Hello World!");
                // For information about how to create an AccessKey pair, see "Create an AccessKey pair" at https://www.alibabacloud.com/help/en/resource-access-management/latest/accesskey-pairs-create-an-accesskey-pair-for-a-ram-user.
                Config config = new Config();
                // The AccessKey pair of an Alibaba Cloud account has the permissions to call all API operations. We recommend that you use the AccessKey pair of a Resource Access Management (RAM) user to call API operations or perform routine O&M. 
                // We recommend that you do not hard code your AccessKey ID or AccessKey secret in your project code. Otherwise, the AccessKey pair may be leaked and the security of all resources within your account is compromised. 
                // In this example, the AccessKey ID and AccessKey secret are saved as environment variables. You can also save the AccessKey ID and AccessKey secret to a configuration file based on your business requirements. 
                IDictionary environmentVariables = Environment.GetEnvironmentVariables();
                foreach (DictionaryEntry de in environmentVariables)
                {
                    if (de.Key.Equals("CC_AK_ENV")) {
                        config.AccessKeyId = (string)de.Value;
                    }
                    if (de.Key.Equals("CC_SK_ENV"))
                    {
                        config.AccessKeySecret = (string)de.Value;
                    }
                }
                config.Endpoint = "imagesearch.cn-shanghai.aliyuncs.com";
                config.RegionId = "cn-shanghai";
                config.Type = "access_key"; 
    
                // The following sample code provides an example on how to use a virtual private cloud (VPC) endpoint to call the Image Search API.
                // Note: You can use a VPC endpoint to call the Image Search API only from Elastic Compute Service (ECS) instances or resources that reside in the same region. For example, if your Image Search instance resides in the China (Shanghai) region, you can use a VPC endpoint to call the Image Search API only from the ECS instances or resources that reside in the China (Shanghai) region. Otherwise, the API operation fails to be called. In case of a failed API call, check whether your ECS instances or resources are in the same region as your Image Search instance before you call the Image Search API. 
                // config.EndpointType = "internal";  // If you want to use a VPC endpoint to call the Image Search API, you must specify the EndpointType parameter and set the value to internal.
                // config.Endpoint = "imagesearch-vpc.cn-shanghai.aliyuncs.com"; // The VPC endpoint that is used to call the Image Search API. Replace the value with the VPC endpoint in the region in which your Image Search instance resides. For example, if your Image Search instance resides in the China (Hangzhou) region, set the Endpoint parameter to imagesearch-vpc.cn-hangzhou.aliyuncs.com.
                
                Client client = new Client(config);
                FileStream fs = File.OpenRead("D:/111.jpg");
                AddImageAdvanceRequest request = new AddImageAdvanceRequest();
                // Required. The name of the image. The name can be up to 512 characters in length. 
                 // 1. An image is uniquely identified by the values of the ProductId and PicName parameters. 
               // 2. If you add an image whose product ID (ProductId) and image name (PicName) are the same as those of an existing image, the newly added image overwrites the existing image.
                request.PicName = "xusong.jpg";
                // Required. The ID of the product. The ID can be up to 512 characters in length. 
                // A product ID can correspond to multiple image names. 
                request.ProductId = "1001";
                // Required. The name of the Image Search instance. Enter the instance name instead of the instance ID. After an Image Search instance is purchased, you can view the instance name on the instance list page of the Image Search console at https://imagesearch.console.aliyun.com/overview.
                request.InstanceName = "XXXXXXXXXXXXXXXXXXXXXXXXX";
                // The image. The image cannot exceed 4 MB in size. The transmission timeout period cannot exceed 5 seconds. Only the following image formats are supported: PNG, JPG, JPEG, BMP, GIF, WebP, TIFF, and PPM.
                // For product and generic image searches, the length and the width of an image must range from 100 pixels to 4,096 pixels.
                 // For fabric image search, the length and the width of an image must range from 448 pixels to 4,096 pixels.
                // The image cannot contain rotation properties.
                request.PicContentObject = fs;
                // Optional. The attribute of the INT type. The attribute can be used to filter images during image searches. If you specify this parameter, the response includes this parameter and its value. 
                // For example, you can set different attributes for images from different sites or different users. This way, users can filter images by attribute and obtain more accurate search results.
                request.IntAttr = 99;
                 // Optional. The attribute of the STRING type. The value can be up to 128 characters in length. The attribute can be used to filter images during image searches. If you specify this parameter, the response includes this parameter and its value. 
                request.StrAttr = "aliyun.com";
                // Optional. The ID of the product category. 
                // 1. Product image search: If a category is specified, the specified category prevails. If no category is specified, the system predicts and selects a category. The category selected by the system is included in the response. 
                // 2. Generic image search: The category ID is set to 88888888 regardless of whether a category is specified. 
                request.CategoryId = 5;
                // Optional. Specifies whether to identify the subject in the image. Default value: true. 
               // 1. If you set this parameter to true, the system identifies the subject in the image and searches for images based on the identified subject. The response includes the identification result. 
                // The area specified by the Region parameter cannot cross the boundary of the image. 
               // 2. If you set this parameter to false, the system searches for images based on the entire image without subject identification. 
                request.Crop = true;
                // Optional. The subject area of the image, in the format of x1,x2,y1,y2. Specifically, x1 and y1 specify the upper-left point, and x2 and y2 specify the lower-right point. 
               // If you specify the Region parameter, the search is conducted based on the value of the Region parameter regardless of the value of the Crop parameter. 
                request.Region = "66,333,97,356";
                RuntimeOptions runtimeObject = new RuntimeOptions();
                try
                {
                    AddImageResponse response = client.AddImageAdvance(request, runtimeObject);
                    Console.WriteLine("result:" + Newtonsoft.Json.JsonConvert.SerializeObject(response));
                }
                catch (TeaUnretryableException e)
                {
                    Console.WriteLine("Returned InnerException:" + e.InnerException.Message);
                    Console.WriteLine("Returned data:" + e.Data);
                    Console.WriteLine("Returned message:" + e.Message);
                    Console.WriteLine("Returned string:" + e.ToString());
                }
            }
        }
    }
  • Sample response

    result:{"Headers":{"date":"Mon, 11 Jan 2021 06:57:16 GMT","connection":"keep-alive","access-control-allow-origin":"*","access-control-allow-methods":"POST, GET, OPTIONS","access-control-allow-headers":"X-Requested-With, X-Sequence, _aop_secret, _aop_signature","access-control-max-age":"172800","x-acs-request-id":"6D32C931-D584-4927-938A-6053AE9B630D"},"Body":{"Message":"success","RequestId":"6D32C931-D584-4927-938A-6053AE9B630D","Code":0,"PicInfo":{"Region":"112,440,76,387","CategoryId":88888888},"Success":true}}

SearchImageByPic

  • Sample code

    using AlibabaCloud.OpenApiClient.Models;
    using AlibabaCloud.SDK.ImageSearch20201214.Models;
    using AlibabaCloud.SDK.ImageSearch20201214;
    using AlibabaCloud.TeaUtil.Models;
    using System;
    using System.IO;
    namespace Test
    {
        class SearchImageByPic
        {
            static void Main(string[] args)
            {
                Config config = new Config();
                // For information about how to create an AccessKey pair, see "Create an AccessKey pair" at https://www.alibabacloud.com/help/en/resource-access-management/latest/accesskey-pairs-create-an-accesskey-pair-for-a-ram-user.
                // The AccessKey pair of an Alibaba Cloud account has the permissions to call all API operations. We recommend that you use the AccessKey pair of a RAM user to call API operations or perform routine O&M. 
                // We recommend that you do not hard code your AccessKey ID or AccessKey secret in your project code. Otherwise, the AccessKey pair may be leaked and the security of all resources within your account is compromised. 
                // In this example, the AccessKey ID and AccessKey secret are saved as environment variables. You can also save the AccessKey ID and AccessKey secret to a configuration file based on your business requirements. 
                IDictionary environmentVariables = Environment.GetEnvironmentVariables();
                foreach (DictionaryEntry de in environmentVariables)
                {
                    if (de.Key.Equals("CC_AK_ENV")) {
                        config.AccessKeyId = (string)de.Value;
                    }
                    if (de.Key.Equals("CC_SK_ENV"))
                    {
                        config.AccessKeySecret = (string)de.Value;
                    }
                }
                config.Endpoint = "imagesearch.cn-shanghai.aliyuncs.com";
                config.RegionId = "cn-shanghai";
                config.Type = "access_key";
    
                // The following sample code provides an example on how to use a VPC endpoint to call the Image Search API.
                // Note: You can use a VPC endpoint to call the Image Search API only from ECS instances or resources that reside in the same region. For example, if your Image Search instance resides in the China (Shanghai) region, you can use a VPC endpoint to call the Image Search API only from the ECS instances or resources that reside in the China (Shanghai) region. Otherwise, the API operation fails to be called. In case of a failed API call, check whether your ECS instances or resources are in the same region as your Image Search instance before you call the Image Search API. 
                // config.EndpointType = "internal";  // If you want to use a VPC endpoint to call the Image Search API, you must specify the EndpointType parameter and set the value to internal.
                // config.Endpoint = "imagesearch-vpc.cn-shanghai.aliyuncs.com"; // The VPC endpoint that is used to call the Image Search API. Replace the value with the VPC endpoint in the region in which your Image Search instance resides. For example, if your Image Search instance resides in the China (Hangzhou) region, set the Endpoint parameter to imagesearch-vpc.cn-hangzhou.aliyuncs.com.
                
                Client client = new Client(config);
                FileStream fs = File.OpenRead("D:/123.jpg");
                SearchImageByPicAdvanceRequest request = new SearchImageByPicAdvanceRequest();
                // Optional. The ID of the product category. 
                // 1. Product image search: If a category is specified, the specified category prevails. If no category is specified, the system predicts and selects a category. The category selected by the system is included in the response. 
                // 2. Generic image search: The category ID is set to 88888888 regardless of whether a category is specified. 
                request.CategoryId = 5;
                // The image. The image cannot exceed 4 MB in size. The transmission timeout period cannot exceed 5 seconds. Only the following image formats are supported: PNG, JPG, JPEG, BMP, GIF, WebP, TIFF, and PPM.
                // For product, trademark, and generic image searches, the length and the width of an image must range from 100 pixels to 4,096 pixels.        
                // For fabric image search, the length and the width of an image must range from 448 pixels to 4,096 pixels.        
                // The image cannot contain rotation properties.
                request.PicContentObject = fs;
                // Optional. Specifies whether to identify the subject in the image. Default value: true. 
                // 1. If you set this parameter to true, the system identifies the subject in the image and searches for images based on the identified subject. The response includes the identification result. 
                // 2. If you set this parameter to false, the system searches for images based on the entire image without subject identification. 
                request.Crop = true;
                // Optional. The filter conditions.
                // int_attr supports the following operators: >, >=, <, <=, and =. str_attr supports the = and != operators. You can set the logical operator between conditions to AND or OR. 
                // Examples:
                // 1. Filter images based on the attribute of the INT type: int_attr>=100.
                // 2. Filter images based on the attribute of the STRING type: str_attr!="value1".
                // 3. Filter images based on the attributes of the INT and STRING types: int_attr=1000 AND str_attr="value1".
                request.Filter = "int_attr=99";
                // Optional. The subject area of the image, in the format of x1,x2,y1,y2. Specifically, x1 and y1 specify the upper-left point, and x2 and y2 specify the lower-right point. 
                // The area specified by the Region parameter cannot cross the boundary of the image. 
                // If you specify the Region parameter, the search is conducted based on the value of the Region parameter regardless of the value of the Crop parameter. 
                request.Region = "66,333,98,356";
                // Required. The name of the Image Search instance. Enter the instance name instead of the instance ID. After an Image Search instance is purchased, you can view the instance name on the instance list page of the Image Search console at https://imagesearch.console.aliyun.com/overview.
                request.InstanceName = "XXXXXX";
                RuntimeOptions runtimeObject = new RuntimeOptions();
                try
                {
                    SearchImageByPicResponse response = client.SearchImageByPicAdvance(request, runtimeObject);
                    String result = Newtonsoft.Json.JsonConvert.SerializeObject(response);
                    Console.WriteLine("result:" + result);
                    }
                catch (TeaUnretryableException e)
                {
                    Console.WriteLine("Returned InnerException:" + e.InnerException.Message);
                    Console.WriteLine("Returned data:" + e.Data);
                    Console.WriteLine("Returned message:" + e.Message);
                    Console.WriteLine("Returned string:" + e.ToString());
                }
            }
        }
    }
  • Sample response

    result:
    {
        "RequestId":"632814A0-F34D-46FB-882D-81D74E7C3290",
        "Success":true,
        "Code":0,
        "Msg":"success",
        "Auctions":[
            {
                "CategoryId":0,
                "ProductId":"test",
                "PicName":"test.jpg",
                "CustomContent":null,
                "Score":1.0
                "SortExprValues":"7.33136443711219;0",
                "IntAttr":null,
                "StrAttr":null
            },
            {......}
            ],
        "Head":{
            "DocsReturn":4,
            "DocsFound":4,
            "SearchTime":155
        },
        "PicInfo":{
            "CategoryId":0,
            "Region":"202,596,155,637",
            "AllCategories":[{"Id":0,"Name":"Tops"},{.....}],
            "MultiRegion":[
                {"Region":"112,440,76,387"}
            ]
         }
    }

SearchImageByName

  • Sample code

    using AlibabaCloud.OpenApiClient.Models;
    using AlibabaCloud.SDK.ImageSearch20201214.Models;
    using AlibabaCloud.SDK.ImageSearch20201214;
    using AlibabaCloud.TeaUtil.Models;
    using System;
    using System.IO;
    namespace Test
    {
        class SearchImageByName
        {
            static void Main(string[] args)
            {
                Config config = new Config();
                // For information about how to create an AccessKey pair, see "Create an AccessKey pair" at https://www.alibabacloud.com/help/en/resource-access-management/latest/accesskey-pairs-create-an-accesskey-pair-for-a-ram-user.
                // The AccessKey pair of an Alibaba Cloud account has the permissions to call all API operations. We recommend that you use the AccessKey pair of a RAM user to call API operations or perform routine O&M. 
                // We recommend that you do not hard code your AccessKey ID or AccessKey secret in your project code. Otherwise, the AccessKey pair may be leaked and the security of all resources within your account is compromised. 
                // In this example, the AccessKey ID and AccessKey secret are saved as environment variables. You can also save the AccessKey ID and AccessKey secret to a configuration file based on your business requirements. 
                IDictionary environmentVariables = Environment.GetEnvironmentVariables();
                foreach (DictionaryEntry de in environmentVariables)
                {
                    if (de.Key.Equals("CC_AK_ENV")) {
                        config.AccessKeyId = (string)de.Value;
                    }
                    if (de.Key.Equals("CC_SK_ENV"))
                    {
                        config.AccessKeySecret = (string)de.Value;
                    }
                }
                config.Endpoint = "imagesearch.cn-shanghai.aliyuncs.com";
                config.RegionId = "cn-shanghai";
                config.Type = "access_key";
    
                // The following sample code provides an example on how to use a VPC endpoint to call the Image Search API.
                // Note: You can use a VPC endpoint to call the Image Search API only from ECS instances or resources that reside in the same region. For example, if your Image Search instance resides in the China (Shanghai) region, you can use a VPC endpoint to call the Image Search API only from the ECS instances or resources that reside in the China (Shanghai) region. Otherwise, the API operation fails to be called. In case of a failed API call, check whether your ECS instances or resources are in the same region as your Image Search instance before you call the Image Search API. 
                // config.EndpointType = "internal";  // If you want to use a VPC endpoint to call the Image Search API, you must specify the EndpointType parameter and set the value to internal.
                // config.Endpoint = "imagesearch-vpc.cn-shanghai.aliyuncs.com"; // The VPC endpoint that is used to call the Image Search API. Replace the value with the VPC endpoint in the region in which your Image Search instance resides. For example, if your Image Search instance resides in the China (Hangzhou) region, set the Endpoint parameter to imagesearch-vpc.cn-hangzhou.aliyuncs.com.
    
                Client client = new Client(config);            
                SearchImageByNameRequest request = new SearchImageByNameRequest();
                // Optional. The ID of the product category. 
                // 1. Product image search: If a category is specified, the specified category prevails. If no category is specified, the system predicts and selects a category. The category selected by the system is included in the response. 
                // 2. Generic image search: The category ID is set to 88888888 regardless of whether a category is specified. 
                request.CategoryId = 5;
                // Required. The name of the Image Search instance. Enter the instance name instead of the instance ID. After an Image Search instance is purchased, you can view the instance name on the instance list page of the Image Search console at https://imagesearch.console.aliyun.com/overview.
                request.InstanceName = "XXXXXXXXXX";
                // Required. The name of the image. The name can be up to 512 characters in length. 
                // An image is uniquely identified by the values of the ProductId and PicName parameters.
                request.PicName = "xusong.jpg";
                // Required. The ID of the product. The ID can be up to 512 characters in length. 
                // A product ID can correspond to multiple image names. 
                request.ProductId = "1001";
                try
                {
                    SearchImageByNameResponse response = client.SearchImageByName(request);
                    String result = Newtonsoft.Json.JsonConvert.SerializeObject(response);
                    Console.WriteLine("result:" + result);
                }
                catch (TeaUnretryableException e)
                {
                    Console.WriteLine("Returned InnerException:" + e.InnerException.Message);
                    Console.WriteLine("Returned data:" + e.Data);
                    Console.WriteLine("Returned message:" + e.Message);
                    Console.WriteLine("Returned string:" + e.ToString());
                }
            }
        }
    }
  • Sample response

    result:
    {
        "RequestId":"5B16E5CD-FE8A-4A4E-A90B-02A5C9F8BD81",
        "Success":true,
        "Code":0,
        "Msg":"success",
        "Auctions":[
            {
                "CategoryId":0,
                "ProductId":"test",
                "PicName":"test.jpg",
                "CustomContent":null,
                "Score":1.0
                "SortExprValues":"7.33136443711219;0",
                "IntAttr":null,
                "StrAttr":null
            },
            {....}
        ],
        "Head":{
            "DocsReturn":4,
            "DocsFound":4,
            "SearchTime":50
        },
        "PicInfo":{
            "CategoryId":0,
            "Region":null,
            "AllCategories":[
                {"Id":0,"Name":"Tops"},
                {...}
            ],
           "MultiRegion":[
                {"Region":"112,440,76,387"}
           ]
        }
    }

Delete

  • Sample code

    using AlibabaCloud.OpenApiClient.Models;
    using AlibabaCloud.SDK.ImageSearch20201214.Models;
    using AlibabaCloud.SDK.ImageSearch20201214;
    using AlibabaCloud.TeaUtil.Models;
    using System;
    using System.IO;
    namespace Test
    {
        class Delete
        {
            static void Main(string[] args)
            {
                Config config = new Config();
                // For information about how to create an AccessKey pair, see "Create an AccessKey pair" at https://www.alibabacloud.com/help/en/resource-access-management/latest/accesskey-pairs-create-an-accesskey-pair-for-a-ram-user.
                // The AccessKey pair of an Alibaba Cloud account has the permissions to call all API operations. We recommend that you use the AccessKey pair of a RAM user to call API operations or perform routine O&M. 
                // We recommend that you do not hard code your AccessKey ID or AccessKey secret in your project code. Otherwise, the AccessKey pair may be leaked and the security of all resources within your account is compromised. 
                // In this example, the AccessKey ID and AccessKey secret are saved as environment variables. You can also save the AccessKey ID and AccessKey secret to a configuration file based on your business requirements. 
                IDictionary environmentVariables = Environment.GetEnvironmentVariables();
                foreach (DictionaryEntry de in environmentVariables)
                {
                    if (de.Key.Equals("CC_AK_ENV")) {
                        config.AccessKeyId = (string)de.Value;
                    }
                    if (de.Key.Equals("CC_SK_ENV"))
                    {
                        config.AccessKeySecret = (string)de.Value;
                    }
                }
                config.Endpoint = "imagesearch.cn-shanghai.aliyuncs.com";
                config.RegionId = "cn-shanghai";
                config.Type = "access_key";
    
                // The following sample code provides an example on how to use a VPC endpoint to call the Image Search API.
                // Note: You can use a VPC endpoint to call the Image Search API only from ECS instances or resources that reside in the same region. For example, if your Image Search instance resides in the China (Shanghai) region, you can use a VPC endpoint to call the Image Search API only from the ECS instances or resources that reside in the China (Shanghai) region. Otherwise, the API operation fails to be called. In case of a failed API call, check whether your ECS instances or resources are in the same region as your Image Search instance before you call the Image Search API. 
                // config.EndpointType = "internal";  // If you want to use a VPC endpoint to call the Image Search API, you must specify the EndpointType parameter and set the value to internal.
                // config.Endpoint = "imagesearch-vpc.cn-shanghai.aliyuncs.com"; // The VPC endpoint that is used to call the Image Search API. Replace the value with the VPC endpoint in the region in which your Image Search instance resides. For example, if your Image Search instance resides in the China (Hangzhou) region, set the Endpoint parameter to imagesearch-vpc.cn-hangzhou.aliyuncs.com.
    
                Client client = new Client(config);
                DeleteImageRequest request = new DeleteImageRequest();
                // Required. The name of the Image Search instance. Enter the instance name instead of the instance ID. After an Image Search instance is purchased, you can view the instance name on the instance list page of the Image Search console at https://imagesearch.console.aliyun.com/overview.
                request.InstanceName = "XXXXXXXXXXX";
                // Required. The name of the image. The name can be up to 512 characters in length. 
                // An image is uniquely identified by the values of the ProductId and PicName parameters. 
                request.PicName = "xusong.jpg";
                // Optional. The name of the image. If you do not specify this parameter, the system removes all the images that are related to the specified product ID. If you specify this parameter, the system removes only the image that is specified by the ProductId and PicName parameters. 
                request.ProductId = "1001";
                try
                {
                    DeleteImageResponse response = client.DeleteImage(request);
                    Console.WriteLine("RequestId:" + response.Body.RequestId);
                    Console.WriteLine("Message:" + response.Body.Message);
                    Console.WriteLine("Code:" + response.Body.Code);
                }
                catch (TeaUnretryableException e)
                {
                    Console.WriteLine("Returned InnerException:" + e.InnerException.Message);
                    Console.WriteLine("Returned data:" + e.Data);
                    Console.WriteLine("Returned message:" + e.Message);
                    Console.WriteLine("Returned string:" + e.ToString());
                }
            }
        }
    }
  • Sample response

    RequestId:D9BDEAE0-674C-4126-9D76-A79F0BE9E881
    Message:success
    Code:0

UpdateImage

  • Sample code

    using AlibabaCloud.OpenApiClient.Models;
    using AlibabaCloud.SDK.ImageSearch20201214.Models;
    using AlibabaCloud.SDK.ImageSearch20201214;
    using AlibabaCloud.TeaUtil.Models;
    using System;
    using System.IO;
    namespace Test
    {
        class UpdateImage
        {
            static void Main(string[] args)
            {
                Config config = new Config();
                // For information about how to create an AccessKey pair, see "Create an AccessKey pair" at https://www.alibabacloud.com/help/en/resource-access-management/latest/accesskey-pairs-create-an-accesskey-pair-for-a-ram-user.
                // The AccessKey pair of an Alibaba Cloud account has the permissions to call all API operations. We recommend that you use the AccessKey pair of a RAM user to call API operations or perform routine O&M. 
                // We recommend that you do not hard code your AccessKey ID or AccessKey secret in your project code. Otherwise, the AccessKey pair may be leaked and the security of all resources within your account is compromised. 
                // In this example, the AccessKey ID and AccessKey secret are saved as environment variables. You can also save the AccessKey ID and AccessKey secret to a configuration file based on your business requirements. 
                IDictionary environmentVariables = Environment.GetEnvironmentVariables();
                foreach (DictionaryEntry de in environmentVariables)
                {
                    if (de.Key.Equals("CC_AK_ENV")) {
                        config.AccessKeyId = (string)de.Value;
                    }
                    if (de.Key.Equals("CC_SK_ENV"))
                    {
                        config.AccessKeySecret = (string)de.Value;
                    }
                }
                config.Endpoint = "imagesearch.cn-shanghai.aliyuncs.com";
                config.RegionId = "cn-shanghai";
                config.Type = "access_key";
    
                // The following sample code provides an example on how to use a VPC endpoint to call the Image Search API.
                // Note: You can use a VPC endpoint to call the Image Search API only from ECS instances or resources that reside in the same region. For example, if your Image Search instance resides in the China (Shanghai) region, you can use a VPC endpoint to call the Image Search API only from the ECS instances or resources that reside in the China (Shanghai) region. Otherwise, the API operation fails to be called. In case of a failed API call, check whether your ECS instances or resources are in the same region as your Image Search instance before you call the Image Search API. 
                // config.EndpointType = "internal";  // If you want to use a VPC endpoint to call the Image Search API, you must specify the EndpointType parameter and set the value to internal.
                // config.Endpoint = "imagesearch-vpc.cn-shanghai.aliyuncs.com"; // The VPC endpoint that is used to call the Image Search API. Replace the value with the VPC endpoint in the region in which your Image Search instance resides. For example, if your Image Search instance resides in the China (Hangzhou) region, set the Endpoint parameter to imagesearch-vpc.cn-hangzhou.aliyuncs.com.
    
                Client client = new Client(config);
                UpdateImageRequest request = new UpdateImageRequest();
                // Required. The name of the Image Search instance. Enter the instance name instead of the instance ID. After an Image Search instance is purchased, you can view the instance name on the instance list page of the Image Search console at https://imagesearch.console.aliyun.com/overview.
                request.InstanceName = "XXXXXXXXXXX";
                // Required. The ID of the product. The product ID cannot be changed. 
                request.ProductId = "1";
                // Required. The name of the image. The image name cannot be changed. 
                request.PicName = "1";
                // Optional. The attribute of the INT type. The attribute can be used to filter images during image searches. If you specify this parameter, the response includes this parameter and its value. 
                request.IntAttr = 1;
                // Optional. The attribute of the STRING type. The value can be up to 128 characters in length. The attribute can be used to filter images during image searches. If you specify this parameter, the response includes this parameter and its value. 
                request.StrAttr = "test";
                // Optional. The user-defined content. The value can be up to 4,096 characters in length. 
                request.CustomContent ="This is a sample description";
                try
                {
                    UpdateImageResponse response = client.UpdateImage(request);
                    String result = Newtonsoft.Json.JsonConvert.SerializeObject(response.Body);
                    Console.WriteLine("result:" + result);
                }
                catch (TeaUnretryableException e)
                {
                    Console.WriteLine("Returned InnerException:" + e.InnerException.Message);
                    Console.WriteLine("Returned data:" + e.Data);
                    Console.WriteLine("Returned message:" + e.Message);
                    Console.WriteLine("Returned string:" + e.ToString());
                }
            }
        }
    }
  • Sample response

    result:{"Code":0,"Message":null,"RequestId":"4F66A9C0-9D36-152A-B5DB-C0B3624D3331","Success":true}

Detail

  • Sample code

    using AlibabaCloud.OpenApiClient.Models;
    using AlibabaCloud.SDK.ImageSearch20201214.Models;
    using AlibabaCloud.SDK.ImageSearch20201214;
    using AlibabaCloud.TeaUtil.Models;
    using System;
    using System.IO;
    namespace Test
    {
        class Detail
        {
            static void Main(string[] args)
            {
                Config config = new Config();
                // For information about how to create an AccessKey pair, see "Create an AccessKey pair" at https://www.alibabacloud.com/help/en/resource-access-management/latest/accesskey-pairs-create-an-accesskey-pair-for-a-ram-user.
                // The AccessKey pair of an Alibaba Cloud account has the permissions to call all API operations. We recommend that you use the AccessKey pair of a RAM user to call API operations or perform routine O&M. 
                // We recommend that you do not hard code your AccessKey ID or AccessKey secret in your project code. Otherwise, the AccessKey pair may be leaked and the security of all resources within your account is compromised. 
                // In this example, the AccessKey ID and AccessKey secret are saved as environment variables. You can also save the AccessKey ID and AccessKey secret to a configuration file based on your business requirements. 
                IDictionary environmentVariables = Environment.GetEnvironmentVariables();
                foreach (DictionaryEntry de in environmentVariables)
                {
                    if (de.Key.Equals("CC_AK_ENV")) {
                        config.AccessKeyId = (string)de.Value;
                    }
                    if (de.Key.Equals("CC_SK_ENV"))
                    {
                        config.AccessKeySecret = (string)de.Value;
                    }
                }
                config.Endpoint = "imagesearch.cn-shanghai.aliyuncs.com";
                config.RegionId = "cn-shanghai";
                config.Type = "access_key";
    
                // The following sample code provides an example on how to use a VPC endpoint to call the Image Search API.
                // Note: You can use a VPC endpoint to call the Image Search API only from ECS instances or resources that reside in the same region. For example, if your Image Search instance resides in the China (Shanghai) region, you can use a VPC endpoint to call the Image Search API only from the ECS instances or resources that reside in the China (Shanghai) region. Otherwise, the API operation fails to be called. In case of a failed API call, check whether your ECS instances or resources are in the same region as your Image Search instance before you call the Image Search API. 
                // config.EndpointType = "internal";  // If you want to use a VPC endpoint to call the Image Search API, you must specify the EndpointType parameter and set the value to internal.
                // config.Endpoint = "imagesearch-vpc.cn-shanghai.aliyuncs.com"; // The VPC endpoint that is used to call the Image Search API. Replace the value with the VPC endpoint in the region in which your Image Search instance resides. For example, if your Image Search instance resides in the China (Hangzhou) region, set the Endpoint parameter to imagesearch-vpc.cn-hangzhou.aliyuncs.com.
    
                Client client = new Client(config);
                DetailRequest request = new DetailRequest();
                // Required. The name of the Image Search instance. Enter the instance name instead of the instance ID. After an Image Search instance is purchased, you can view the instance name on the instance list page of the Image Search console at https://imagesearch.console.aliyun.com/overview.
                request.InstanceName = "XXXXXXXXXXX";
                try
                {
                    DetailResponse response = client.Detail(request);
                    String result = Newtonsoft.Json.JsonConvert.SerializeObject(response.Body);
                    Console.WriteLine("result:" + result);
                }
                catch (TeaUnretryableException e)
                {
                    Console.WriteLine("Returned InnerException:" + e.InnerException.Message);
                    Console.WriteLine("Returned data:" + e.Data);
                    Console.WriteLine("Returned message:" + e.Message);
                    Console.WriteLine("Returned string:" + e.ToString());
                }
            }
        }
    }
  • Sample response

    {
      RequestId=046913C5-942A-1DD2-959F-7CECD790ADB2,
      Instance={
        UtcExpireTime=1649692800000,
        TotalCount=225320,
        UtcCreate=1633936585000,
        Capacity=250,
        Qps=5,
        ServiceType=0,
        Region=cn-shanghai,
        Name=xxxx
      },
      Success=true
    }

DumpMeta

  • Sample code

    using AlibabaCloud.OpenApiClient.Models;
    using AlibabaCloud.SDK.ImageSearch20201214.Models;
    using AlibabaCloud.SDK.ImageSearch20201214;
    using AlibabaCloud.TeaUtil.Models;
    using System;
    using System.IO;
    namespace Test
    {
        class DumpMeta
        {
            static void Main(string[] args)
            {
                Config config = new Config();
                // For information about how to create an AccessKey pair, see "Create an AccessKey pair" at https://www.alibabacloud.com/help/en/resource-access-management/latest/accesskey-pairs-create-an-accesskey-pair-for-a-ram-user.
                // The AccessKey pair of an Alibaba Cloud account has the permissions to call all API operations. We recommend that you use the AccessKey pair of a RAM user to call API operations or perform routine O&M. 
                // We recommend that you do not hard code your AccessKey ID or AccessKey secret in your project code. Otherwise, the AccessKey pair may be leaked and the security of all resources within your account is compromised. 
                // In this example, the AccessKey ID and AccessKey secret are saved as environment variables. You can also save the AccessKey ID and AccessKey secret to a configuration file based on your business requirements. 
                IDictionary environmentVariables = Environment.GetEnvironmentVariables();
                foreach (DictionaryEntry de in environmentVariables)
                {
                    if (de.Key.Equals("CC_AK_ENV")) {
                        config.AccessKeyId = (string)de.Value;
                    }
                    if (de.Key.Equals("CC_SK_ENV"))
                    {
                        config.AccessKeySecret = (string)de.Value;
                    }
                }
                config.Endpoint = "imagesearch.cn-shanghai.aliyuncs.com";
                config.RegionId = "cn-shanghai";
                config.Type = "access_key";
    
                // The following sample code provides an example on how to use a VPC endpoint to call the Image Search API.
                // Note: You can use a VPC endpoint to call the Image Search API only from ECS instances or resources that reside in the same region. For example, if your Image Search instance resides in the China (Shanghai) region, you can use a VPC endpoint to call the Image Search API only from the ECS instances or resources that reside in the China (Shanghai) region. Otherwise, the API operation fails to be called. In case of a failed API call, check whether your ECS instances or resources are in the same region as your Image Search instance before you call the Image Search API. 
                // config.EndpointType = "internal";  // If you want to use a VPC endpoint to call the Image Search API, you must specify the EndpointType parameter and set the value to internal.
                // config.Endpoint = "imagesearch-vpc.cn-shanghai.aliyuncs.com"; // The VPC endpoint that is used to call the Image Search API. Replace the value with the VPC endpoint in the region in which your Image Search instance resides. For example, if your Image Search instance resides in the China (Hangzhou) region, set the Endpoint parameter to imagesearch-vpc.cn-hangzhou.aliyuncs.com.
    
                Client client = new Client(config);
                DumpMetaRequest request = new DumpMetaRequest();
                // Required. The name of the Image Search instance. Enter the instance name instead of the instance ID. After an Image Search instance is purchased, you can view the instance name on the instance list page of the Image Search console at https://imagesearch.console.aliyun.com/overview.
                request.InstanceName = "XXXXXXXXXXX";
                try
                {
                    DumpMetaResponse response = client.DumpMeta(request);
                    String result = Newtonsoft.Json.JsonConvert.SerializeObject(response.Body);
                    Console.WriteLine("result:" + result);
                }
                catch (TeaUnretryableException e)
                {
                    Console.WriteLine("Returned InnerException:" + e.InnerException.Message);
                    Console.WriteLine("Returned data:" + e.Data);
                    Console.WriteLine("Returned message:" + e.Message);
                    Console.WriteLine("Returned string:" + e.ToString());
                }
            }
        }
    }
  • Sample response

    {
      RequestId=FC4191AA-1D5B-1001-9A70-18FBB2BD265B,
      Data={
        DumpMetaStatus=PROCESSING,
        Id=567
      },
      Success=true
    }

DumpMetaList

  • Sample code

    using AlibabaCloud.OpenApiClient.Models;
    using AlibabaCloud.SDK.ImageSearch20201214.Models;
    using AlibabaCloud.SDK.ImageSearch20201214;
    using AlibabaCloud.TeaUtil.Models;
    using System;
    using System.IO;
    namespace Test
    {
        class DumpMetaList
        {
            static void Main(string[] args)
            {
                Config config = new Config();
                // For information about how to create an AccessKey pair, see "Create an AccessKey pair" at https://www.alibabacloud.com/help/en/resource-access-management/latest/accesskey-pairs-create-an-accesskey-pair-for-a-ram-user.
                // The AccessKey pair of an Alibaba Cloud account has the permissions to call all API operations. We recommend that you use the AccessKey pair of a RAM user to call API operations or perform routine O&M. 
                // We recommend that you do not hard code your AccessKey ID or AccessKey secret in your project code. Otherwise, the AccessKey pair may be leaked and the security of all resources within your account is compromised. 
                // In this example, the AccessKey ID and AccessKey secret are saved as environment variables. You can also save the AccessKey ID and AccessKey secret to a configuration file based on your business requirements. 
                IDictionary environmentVariables = Environment.GetEnvironmentVariables();
                foreach (DictionaryEntry de in environmentVariables)
                {
                    if (de.Key.Equals("CC_AK_ENV")) {
                        config.AccessKeyId = (string)de.Value;
                    }
                    if (de.Key.Equals("CC_SK_ENV"))
                    {
                        config.AccessKeySecret = (string)de.Value;
                    }
                }
                config.Endpoint = "imagesearch.cn-shanghai.aliyuncs.com";
                config.RegionId = "cn-shanghai";
                config.Type = "access_key";
    
                // The following sample code provides an example on how to use a VPC endpoint to call the Image Search API.
                // Note: You can use a VPC endpoint to call the Image Search API only from ECS instances or resources that reside in the same region. For example, if your Image Search instance resides in the China (Shanghai) region, you can use a VPC endpoint to call the Image Search API only from the ECS instances or resources that reside in the China (Shanghai) region. Otherwise, the API operation fails to be called. In case of a failed API call, check whether your ECS instances or resources are in the same region as your Image Search instance before you call the Image Search API. 
                // config.EndpointType = "internal";  // If you want to use a VPC endpoint to call the Image Search API, you must specify the EndpointType parameter and set the value to internal.
                // config.Endpoint = "imagesearch-vpc.cn-shanghai.aliyuncs.com"; // The VPC endpoint that is used to call the Image Search API. Replace the value with the VPC endpoint in the region in which your Image Search instance resides. For example, if your Image Search instance resides in the China (Hangzhou) region, set the Endpoint parameter to imagesearch-vpc.cn-hangzhou.aliyuncs.com.
    
                Client client = new Client(config);
                DumpMetaListRequest request = new DumpMetaListRequest();
                // Required. The name of the Image Search instance. Enter the instance name instead of the instance ID. After an Image Search instance is purchased, you can view the instance name on the instance list page of the Image Search console at https://imagesearch.console.aliyun.com/overview.
                request.InstanceName = "XXXXXXXXXXX";
                // Optional. The ID of the task that is used to export metadata. 
                request.Id = 567;
                // Optional. The page number. Default value: 1. 
                request.PageNumber = 1;
                // Optional. The number of entries per page. Default value: 20. 
                request.PageSize = 1;
                try
                {
                    DumpMetaListResponse response = client.DumpMetaList(request);
                    String result = Newtonsoft.Json.JsonConvert.SerializeObject(response.Body);
                    Console.WriteLine("result:" + result);
                }
                catch (TeaUnretryableException e)
                {
                    Console.WriteLine("Returned InnerException:" + e.InnerException.Message);
                    Console.WriteLine("Returned data:" + e.Data);
                    Console.WriteLine("Returned message:" + e.Message);
                    Console.WriteLine("Returned string:" + e.ToString());
                }
            }
        }
    }
  • Sample response

    {
      RequestId=850DFBD9-A179-12FB-B193-2D08ACEA586B,
      Data={
        TotalCount=1,
        PageSize=1,
        PageNumber=1,
        DumpMetaList=[
          {
            Status=SUCCESS,
            Msg=success,
            MetaUrl=https: //****.com/x?Expires=x,
            UtcCreate=1639969113000,
            UtcModified=1639969140000,
            Id=567,
            Code=0
          }
        ]
      }
    }

BatchTask

  • Sample code

                // For information about how to create an AccessKey pair, see "Create an AccessKey pair" at https://www.alibabacloud.com/help/en/resource-access-management/latest/accesskey-pairs-create-an-accesskey-pair-for-a-ram-user.
                // The AccessKey pair of an Alibaba Cloud account has the permissions to call all API operations. We recommend that you use the AccessKey pair of a RAM user to call API operations or perform routine O&M. 
                // We recommend that you do not hard code your AccessKey ID or AccessKey secret in your project code. Otherwise, the AccessKey pair may be leaked and the security of all resources within your account is compromised. 
                // In this example, the AccessKey ID and AccessKey secret are saved as environment variables. You can also save the AccessKey ID and AccessKey secret to a configuration file based on your business requirements. 
                IDictionary environmentVariables = Environment.GetEnvironmentVariables();
                foreach (DictionaryEntry de in environmentVariables)
                {
                    if (de.Key.Equals("CC_AK_ENV")) {
                        config.AccessKeyId = (string)de.Value;
                    }
                    if (de.Key.Equals("CC_SK_ENV"))
                    {
                        config.AccessKeySecret = (string)de.Value;
                    }
                }
                config.Endpoint = "imagesearch.cn-shanghai.aliyuncs.com";
                config.RegionId = "cn-shanghai";
                config.Type = "access_key";
    
                // The following sample code provides an example on how to use a VPC endpoint to call the Image Search API.
                // Note: You can use a VPC endpoint to call the Image Search API only from ECS instances or resources that reside in the same region. For example, if your Image Search instance resides in the China (Shanghai) region, you can use a VPC endpoint to call the Image Search API only from the ECS instances or resources that reside in the China (Shanghai) region. Otherwise, the API operation fails to be called. In case of a failed API call, check whether your ECS instances or resources are in the same region as your Image Search instance before you call the Image Search API. 
                // config.EndpointType = "internal";  // If you want to use a VPC endpoint to call the Image Search API, you must specify the EndpointType parameter and set the value to internal.
                // config.Endpoint = "imagesearch-vpc.cn-shanghai.aliyuncs.com"; // The VPC endpoint that is used to call the Image Search API. Replace the value with the VPC endpoint in the region in which your Image Search instance resides. For example, if your Image Search instance resides in the China (Hangzhou) region, set the Endpoint parameter to imagesearch-vpc.cn-hangzhou.aliyuncs.com.
    
                Client client = new Client(config);
                IncreaseInstanceRequest request = new IncreaseInstanceRequest();
                // Required. The name of the Image Search instance. Enter the instance name instead of the instance ID. After an Image Search instance is purchased, you can view the instance name on the instance list page of the Image Search console at https://imagesearch.console.aliyun.com/overview.
                request.InstanceName = "XXXXXXXXXXX";
                // Required. If images are stored in an Object Storage Service (OSS) bucket, enter the bucket name. 
                request.BucketName = "bucketName";
                // Required. The path in which the images are stored. The path must start with a forward slash (/) and cannot end with a forward slash (/). 
                // Create a file named increment.meta in the path in which the images are stored. For more information, see "Perform batch operations" in User Guide. 
                request.Path = "/public/xx";
                // Optional. The callback URL if the API call is successful. The URL must start with http:// or https://. 
                request.CallbackAddress = "xxx";
                try
                {
                    IncreaseInstanceResponse response = client.IncreaseInstance(request);
                    String result = Newtonsoft.Json.JsonConvert.SerializeObject(response.Body);
                    Console.WriteLine("result:" + result);
                }
                catch (TeaUnretryableException e)
                {
                    Console.WriteLine("Returned InnerException:" + e.InnerException.Message);
                    Console.WriteLine("Returned data:" + e.Data);
                    Console.WriteLine("Returned message:" + e.Message);
                    Console.WriteLine("Returned string:" + e.ToString());
                }
            }
        }
    }
  • Sample response

    {
      RequestId=F9BAD635-3031-1EBB-BE9E-E9FCB318A28C,
      Data={
        IncrementStatus=PROCESSING,
        Id=1470
      },
      Success=true
    }

BatchTaskList

  • Sample code

    using AlibabaCloud.OpenApiClient.Models;
    using AlibabaCloud.SDK.ImageSearch20201214.Models;
    using AlibabaCloud.SDK.ImageSearch20201214;
    using AlibabaCloud.TeaUtil.Models;
    using System;
    using System.IO;
    namespace Test
    {
        class BatchTaskList
        {
            static void Main(string[] args)
            {
                Config config = new Config();
                // For information about how to create an AccessKey pair, see "Create an AccessKey pair" at https://www.alibabacloud.com/help/en/resource-access-management/latest/accesskey-pairs-create-an-accesskey-pair-for-a-ram-user.
                // The AccessKey pair of an Alibaba Cloud account has the permissions to call all API operations. We recommend that you use the AccessKey pair of a RAM user to call API operations or perform routine O&M. 
                // We recommend that you do not hard code your AccessKey ID or AccessKey secret in your project code. Otherwise, the AccessKey pair may be leaked and the security of all resources within your account is compromised. 
                // In this example, the AccessKey ID and AccessKey secret are saved as environment variables. You can also save the AccessKey ID and AccessKey secret to a configuration file based on your business requirements. 
                IDictionary environmentVariables = Environment.GetEnvironmentVariables();
                foreach (DictionaryEntry de in environmentVariables)
                {
                    if (de.Key.Equals("CC_AK_ENV")) {
                        config.AccessKeyId = (string)de.Value;
                    }
                    if (de.Key.Equals("CC_SK_ENV"))
                    {
                        config.AccessKeySecret = (string)de.Value;
                    }
                }
                config.Endpoint = "imagesearch.cn-shanghai.aliyuncs.com";
                config.RegionId = "cn-shanghai";
                config.Type = "access_key";
    
                // The following sample code provides an example on how to use a VPC endpoint to call the Image Search API.
                // Note: You can use a VPC endpoint to call the Image Search API only from ECS instances or resources that reside in the same region. For example, if your Image Search instance resides in the China (Shanghai) region, you can use a VPC endpoint to call the Image Search API only from the ECS instances or resources that reside in the China (Shanghai) region. Otherwise, the API operation fails to be called. In case of a failed API call, check whether your ECS instances or resources are in the same region as your Image Search instance before you call the Image Search API. 
                // config.EndpointType = "internal";  // If you want to use a VPC endpoint to call the Image Search API, you must specify the EndpointType parameter and set the value to internal.
                // config.Endpoint = "imagesearch-vpc.cn-shanghai.aliyuncs.com"; // The VPC endpoint that is used to call the Image Search API. Replace the value with the VPC endpoint in the region in which your Image Search instance resides. For example, if your Image Search instance resides in the China (Hangzhou) region, set the Endpoint parameter to imagesearch-vpc.cn-hangzhou.aliyuncs.com.
    
                Client client = new Client(config);
                IncreaseListRequest request = new IncreaseListRequest();
                // Required. The name of the Image Search instance. Enter the instance name instead of the instance ID. After an Image Search instance is purchased, you can view the instance name on the instance list page of the Image Search console at https://imagesearch.console.aliyun.com/overview.
                request.InstanceName = "XXXXXXXXXXX";
                // Optional. The ID of the task that is used to export metadata. 
                request.Id = 567;
                // Required. If images are stored in an OSS bucket, enter the bucket name. 
                request.BucketName = "bucketName";
                // Required. The path in which the images are stored. The path must start with a forward slash (/) and cannot end with a forward slash (/). 
                request.Path = "/public/xx";
                // Optional. The page number. Default value: 1. 
                request.PageNumber = 1;
                // Optional. The number of entries per page. Default value: 20. 
                request.PageSize = 1;
                try
                {
                    IncreaseListResponse response = client.IncreaseList(request);
                    String result = Newtonsoft.Json.JsonConvert.SerializeObject(response.Body);
                    Console.WriteLine("result:" + result);
                }
                catch (TeaUnretryableException e)
                {
                    Console.WriteLine("Returned InnerException:" + e.InnerException.Message);
                    Console.WriteLine("Returned data:" + e.Data);
                    Console.WriteLine("Returned message:" + e.Message);
                    Console.WriteLine("Returned string:" + e.ToString());
                }
            }
        }
    }
  • Sample response

    {
      RequestId=56E7E6CC-64AB-17CA-A7CD-1948FB953B8C,
      Data={
        TotalCount=1,
        PageSize=1,
        PageNumber=1,
        Increments={
          Instance=[
            {
              Msg=success,
              Status=NORMAL,
              Path=/xx/xx,
              BucketName=bucketName,
              UtcCreate=1639107872000,
              ErrorUrl=https: //example.com/xxx?Expires=1670661540&xxx=xx,
              UtcModified=1639125540000,
              Id=1464,
              CallbackAddress=null,
              Code=0
            }
          ]
        }
      }
    }