Laravel: Using Unsplash API with a Service Layer and DTOs

Luís Nóbrega
6 min readOct 17, 2020

In this tutorial, I will show you a way of architecture a Service Layer in Laravel, to interact with the Unsplash API. The Service Layer using DTOs, won’t have any concerns about validating data. Let’s see how.

What is Unsplash?

Photo by Alexander Sinn on Unsplash

Unsplash is probably the most popular stock photography website, and it has a very big reason to be so popular.

All the photos are very good and entirely free to use, even for commercial uses.

Unsplash also has an API, unlimited, and free to use.

Websites like this one, Medium, and Trello, among others, use it to provide free quality photos for their users.

Medium, for example, allows his writers to add beautiful photos from Unsplash, in his articles, in his article editor.

Register as a developer and installing SDK

Photo by Chris Ried on Unsplash

You can register as a developer here and have access to their API.

This way you will have access to an access key, which is required to programmatically interact with the API.

--

--

Luís Nóbrega
Luís Nóbrega

Written by Luís Nóbrega

Web Developer at 25friday. Likes to travel, write and being a father.