UnsplashSharp 1.0.0

dotnet add package UnsplashSharp --version 1.0.0                
NuGet\Install-Package UnsplashSharp -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="UnsplashSharp" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add UnsplashSharp --version 1.0.0                
#r "nuget: UnsplashSharp, 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 UnsplashSharp as a Cake Addin
#addin nuget:?package=UnsplashSharp&version=1.0.0

// Install UnsplashSharp as a Cake Tool
#tool nuget:?package=UnsplashSharp&version=1.0.0                

UnsplashSharp

A .NET client wrapper for https://unsplash.com written in .NET Standard 2.0

Installation

Install the package via NuGet.

Usage

First you need to get a free API key from unsplash.com. You can create a new account and navigate to the Unsplash Developer Portal. Here you can create a new application and you will find your API key.

You need to create a new instance of UnsplashpService passing in the API key. There is also an interface available, if you are using Dependency Injection.

/// <summary>
///     The application ID provided by Unsplash.
/// </summary>
string ApplicationId { get; }

/// <summary>
///     The maximum request limit for the client.
/// </summary>
int MaxRateLimit { get; }

/// <summary>
///     The number of remaining requests the client can make.
/// </summary>
int RateLimitRemaining { get; }

/// <summary>
///     Get a list of photo collections.
/// </summary>
Task<Collection> GetCollectionAsync(
    string id);

/// <summary>
///     Get a single photo collection.
/// </summary>
Task<List<Collection>> GetCollectionsAsync(
    int page = 1, 
    int perPage = 10);

/// <summary>
///     Get a list of photos from a specific collection.
/// </summary>
Task<List<Photo>> GetPhotosOfCollectionAsync(
    string id, 
    int page = 1, 
    int perPage = 10, 
    Orientation orientation = Orientation.All);

/// <summary>
///     Gets a list of collections related to a specific collection.
/// </summary>
Task<List<Collection>> GetRelatedCollectionsAsync(
    string id);


/// <summary>
///     Retrieves the total statistics object from Unsplash.
/// </summary>
Task<TotalStats> GetTotalStatsAsync();

/// <summary>
///     Retrieves the monthly statistics object from Unsplash.
/// </summary>
Task<MonthlyStats> GetMonthlyStatsAsync();


/// <summary>
///     Gets a single photo.
/// </summary>
Task<Photo> GetPhotoAsync(
    string id);

/// <summary>
///     Gets a list of random photos.
/// </summary>
Task<List<Photo>> GetRandomPhotosAsync(
    int count = 1, 
    string[] collections = null, 
    string[] topics = null, 
    string username = "", 
    string query = "", 
    Orientation orientation = Orientation.All, 
    ContentFilter contentFilter = ContentFilter.Low);

/// <summary>
///     Gets statistics for a specific photo.
/// </summary>
Task<PhotoStats> GetPhotoStatsAsync(
    string id, 
    int quantity = 30);

/// <summary>
///     Gets a download link for a specific photo.
/// </summary>
Task<string> GetPhotoDownloadLinkAsync(
    string id);

/// <summary>
///     Gets a list of photos.
/// </summary>
Task<List<Photo>> GetPhotosAsync(
    int page = 1, 
    int perPage = 10, 
    PhotoOrderBy orderBy = PhotoOrderBy.Latest);


/// <summary>
///     Searches for photos on Unsplash based on the given query string and search parameters.
/// </summary>
Task<List<Photo>> SearchPhotosAsync(
    string query, 
    int page = 1, 
    int perPage = 10, 
    PhotoOrderBy orderBy = PhotoOrderBy.Latest, 
    string[] collectionIds = null, 
    ContentFilter contentFilter = ContentFilter.Low, 
    UnsplashColor color = UnsplashColor.All, 
    Orientation orientation = Orientation.All);

/// <summary>
///     Searches for collections on Unsplash based on the given query string and search parameters. 
/// </summary>
Task<List<Collection>> SearchCollectionsAsync(
    string query, 
    int page = 1, 
    int perPage = 10);

/// <summary>
/// Searches for users on Unsplash based on the given query string and search parameters.
/// </summary>
Task<List<User>> SearchUsersAsync(
    string query, 
    int page = 1, 
    int perPage = 10);


/// <summary>
///     Retrieves a list of topics from Unsplash, filtered by ID and sorted by position, with pagination.
/// </summary>
Task<List<Topic>> GetTopicsAsync(
    string[] ids = null, 
    int page = 1, 
    int perPage = 10, 
    TopicOrderBy orderBy = TopicOrderBy.Position);

/// <summary>
///     Retrieves a topic from Unsplash by ID.
/// </summary>
Task<Topic> GetTopicAsync(
    string id);

/// <summary>
///     Retrieves a list of photos from Unsplash related to a given topic ID.
/// </summary>
Task<List<Photo>> GetPhotosOfTopicAsync(
    string id, 
    int page = 1, 
    int perPage = 10, 
    Orientation orientation = Orientation.All, 
    PhotoOrderBy orderBy = PhotoOrderBy.Latest);


/// <summary>
///     Retrieves a user object from Unsplash by username.
/// </summary>
Task<User> GetUserAsync(
    string username);

/// <summary>
///     Retrieves the portfolio link of a user with the specified username.
/// </summary>
Task<string> GetUserPorfolioLinkAsync(
    string username);

/// <summary>
///     Retrieves a list of photos uploaded by a user with the specified username. 
/// </summary>
Task<List<Photo>> GetUserPhotosAsync(
    string username, 
    int page = 1, 
    int perPage = 10, 
    PhotoOrderBy orderBy = PhotoOrderBy.Latest, 
    bool stats = false, 
    int quantity = 30, 
    Orientation orientation = Orientation.All);

/// <summary>
///     Retrieves a list of photos liked by a user with the specified username.
/// </summary>
Task<List<Photo>> GetUserLikedPhotosAsync(
    string username, 
    int page = 1, 
    int perPage = 10, 
    PhotoOrderBy orderBy = PhotoOrderBy.Latest, 
    Orientation orientation = Orientation.All);

/// <summary>
///     Retrieves a list of collections created by a user with the specified username.
/// </summary>
Task<List<Collection>> GetUserCollectionsAsync(
    string username, 
    int page = 1, 
    int perPage = 10);

/// <summary>
///     Retrieves statistics for a user with the specified username.
/// </summary>
Task<UserStats> GetUserStatsAsync(
    string username, 
    int quantity = 30);

Sample

Here are screenshots of a .NET MAUI application using the NuGet package to get some images.

Android

Android

Windows

Windows0

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 283 10/8/2023

- First Release