Hi marouane,
I have created a sample that you can refer and modify it as per your requirement.
You need to first register and get the clientId using the below link.
https://unsplash.com/join
For documentation refer below link.
https://unsplash.com/documentation#search-photos
For converting the json result returned from the api i have used JSON.Net library.
For more details refer below article.
HTML
<asp:Image ID="imgCity" Height="200px" Width="200px" runat="server" />
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
string clientId = "<Your Client Id>";
string city = "Mumbai";
string url = string.Format("https://api.unsplash.com/search/photos/?client_id={0}&page=1&query={1}&per_page=1", clientId, city);
System.Net.ServicePointManager.Expect100Continue = true;
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
string json = (new System.Net.WebClient()).DownloadString(url);
Image image = Newtonsoft.Json.JsonConvert.DeserializeObject<Image>(json);
imgCity.ImageUrl = image.results[0].urls.small;
}
public class Image
{
public Result[] results { get; set; }
}
public class Result
{
public Urls urls { get; set; }
}
public class Urls
{
public string raw { get; set; }
public string small { get; set; }
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim clientId As String = "<Your Client Id>"
Dim city As String = "Mumbai"
Dim url As String = String.Format("https://api.unsplash.com/search/photos/?client_id={0}&page=1&query={1}&per_page=1", clientId, city)
Net.ServicePointManager.Expect100Continue = True
Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Tls12
Dim json As String = (New Net.WebClient()).DownloadString(url)
Dim image As Image = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Image)(json)
imgCity.ImageUrl = image.results(0).urls.small
End Sub
Public Class Image
Public Property results As Result()
End Class
Public Class Result
Public Property urls As Urls
End Class
Public Class Urls
Public Property raw As String
Public Property small As String
End Class
Screenshot
![](https://i.imgur.com/wV43MH5.jpg)