↓ I built a game! Check it out ↓

Generate Random Images From Unsplash Without Using The API

June 24, 2018 by Andreas Wik

In case you haven’t heard already – Unsplash is the place to go when you need royalty free photos to use in your projects, whether it’s for commercial use or not. I use it myself quite often, for large background images. So does https://pixelarity.com, just to name an example.

While they do have a great API for developers, they also give you the option to simply access random images via URL’s.

Here’s an example, generating a completely random image from their massive storage:




Specific User

We can also generate a random image from a specific user. The URL format would be like so:


Click this link below to generate a random image from the user wsanter:



Specific Sizes

There’s also an option to set the size of the image you want generated. Like so:


Let’s generate a random image with the width and height of 300px:



Random Image From Search Term

This one is really cool. You can generate images from search terms. Let’s search for city and night (so fkn creative):



You place the search terms at the end of the URL, so before you could add the size if you’d like:




An Example With JavaScript

Here’s a simple CodePen I put together illustrating how you could use this dynamically with JavaScript:

See the Pen zaaXEZ by Andreas Wik (@andreaswik) on CodePen.


For a full list of features – check out the Unsplash Source documentation.

Have fun!