Bart Simons

Bart Simons


Thoughts, stories and ideas.

Bart Simons
Author

Share


Tags


.net .net core Apache C# CentOS LAMP NET Framework Pretty URLs Windows Server WireGuard WireGuard.io access log add analysis android api at the same time authentication authorization automate automation azure azurerm backup bash basics batch bootstrap build capture cheat sheet chromium chroot class cli click to close code snippet command line commands compile compiling compression containers control controller controlling convert cpu usage create credentials csv csvparser curl data dd deployment desktop detect devices disable diskpart dism distributed diy docker dom changes dotnet core drivers ease of access encryption example export file transfer files fix folders generalize getting started ghost ghost.org gui guide gunicorn gzip html html tables icewarp igd imagex import inotify install installation interactive ios iphone itunes java javascript jquery json kiosk kotlin linux live load data loading screen lock screen loopback audio lxc lxd lxml macos manage manually message messages minio mirrored mod_rewrite monitor monitoring mutationobserver mysql nexmo nginx no oobe node node.js nodejs not installing notification notifications object storage on desktop one command openssl owncloud parallels parallels tools parse perfect philips hue play port forwarding portainer.io powershell processing ps-spotify python quick raspberry pi record rip ripping rsync rtmp save save data sbapplication scraping script scripting scriptingbridge scripts security send server service sharedpreferences sms songs sonos spotify spotify api spotlight ssh stack streaming streamlink studio sudo swarm swift sync sysprep system audio systemd tables terminal tracking tutorial twilio ubiquiti ubuntu ubuntu 18.04 ui code unifi unlock unsplash source upnp uptime usb tethering wallpapers wasapi website websites webview windows windows 10 without itunes without oobe workaround xaml

Getting started with Unsplash Source on Node.JS

What is Unsplash?

Unsplash is a dream that has come true to me - a free platform where free really means free: the artwork available on Unsplash is free-to-use for private and commercial use, without the need to citate the author (although it is respected if you do). Func fact: I also use Unsplash for my website's titles since January 2018.

So now that you know what Unsplash is: did you know that they have an API available with libraries for the most used programming languages? In this post I am going to dive deeper into the Node.JS module and the possibilities with it.

Colorful blue and pink powder and chalk dust across the floor
Photo by Nathan Roser / Unsplash

More about the API

The API of Unsplash is pretty cool: they have two APIs available:

The biggest difference between these two APIs is that the last one doesn't require you to authenticate, this makes it ideal to be used in for example client-side JavaScript applications.

I am going to discuss both APIs though, so I've got you covered on all the topics.

Using the Unsplash Source API

The Unsplash Source API is very simple and limited. As said before, it is only meant for fetching images and doing some simple inline editing tasks as well. Here's a list of what we can do with the API:

Of course there are more use cases, but these are 4 examples of what the possibilities are with this API.

A while ago, I found a JavaScript library that functions as a wrapper around the REST functionality of Unsplash Source. The bad news however is that it is meant to run in the browser, and not on Node.

So I forked to repository and implement the needed module export. My repository is available at https://github.com/bmsimons/unsplash-source-node-js.

unsplash-source-in-action

The returned URL is where your photo is located at, in my case it redirects to a random photo by Bernard Hermant on each visit.

You can read the readme markdown file in my repository for documentation and stuff. I have also included some more use cases over there.

Is the software provided in my repo helpful for your project? Don't forget to star it on GitHub to show your support 😉

Bart Simons
Author

Bart Simons

View Comments