O'Reilly logo

Learning Microsoft Cognitive Services - Second Edition by Leif Larsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Searching for images

For our example, we will only be executing the image search based on user queries. To allow this, we will need to add a function in the BingSearch class. Call the function SearchImages, and let it accept a string as parameter. The function should return Task<ImageSearchResponse> and be marked as async. ImageSearchResponse will, in this case, be a data contract object, with data deserialized from our response:

public async Task<ImageSearchResponse> SearchImages(string query) 
{ 
    string endpoint = string.Format("{0}{1}",    "https://api.cognitive.microsoft.com/bing/v5.0/images/search?q=", query); 

 

We start by constructing our endpoint. In this case, we only specify the query parameter, q. This is a required parameter.

Apart ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required