Skip to content

Image Search

Shows how to search Google Images for image results.

This example assumes using Serper; is in scope and apiKey contains your Serper API key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
using var client = new SerperClient(apiKey);

// Search Google Images for images matching a query.
var response = await client.ImageSearchAsync(new BaseSearchRequest
{
    Q = "northern lights aurora borealis",
    Num = 5,
});

// The response contains image results with URLs, dimensions, and source info.

foreach (var image in response.Images)
{
    Console.WriteLine($"{image.Title}");
    Console.WriteLine($"    {image.ImageUrl} ({image.ImageWidth}x{image.ImageHeight})");
    Console.WriteLine($"    Source: {image.Domain}");
}