Skip to content

Latest commit

 

History

History
56 lines (37 loc) · 1.17 KB

README.md

File metadata and controls

56 lines (37 loc) · 1.17 KB

PexelsNet

PexelsNet is a .NET class library that provides an easy-to-use interface for the Pexels API

Nuget

https://www.nuget.org/packages/PexelsNet/

Initializing

var client = new PexelsClient("<Your Api key>");

Methods

Search

The following example will grab all images for the term business using the default pagination (15 images).

var results = client.SearchAsync("business").Result; 

foreach (var image in results.Photos)
{
    Console.WriteLine(image.Src.Medium);
}

Popular

The following example will grab all popular images using the default pagination (15 images).

var results = client.PopularAsync().Result; 

foreach (var image in results.Photos)
{
    Console.WriteLine(image.Src.Medium);
}

Pagination

By default, pexels will return 15 images but you can specify your own pagination.

The following example will grab 20 images from the 2nd page for the term business.

var page = client.SearchAsync("business", 2, 20).Result; 

The following example will grab 20 popular images from the 2nd page.

var page = client.PopularAsync(2, 20).Result;