Unsplash Source ES6
Just install and make use of Unsplash's powerful API without any API keys or client IDs.
Unsplash Source ES6 is available as a node package. Get it via
yarn add unsplash-source-es6
npm install unsplash-source-es6
npm, you might want to save to your
npm install --save unsplash-source-es6
Import the Unsplash Source ES6 library:
import UnsplashSourceES6 from 'unsplash-source-es6';
Create an object:
let unsplash = new UnsplashSourceES6();
This object can be used for various API calls.
You can easily chain different API calls to suit your needs in any order as long as you call
fetch() at the end of the chain to get the correct image url. Here are a few use cases:
Simply a random image:
Simply a random image:
A random image in particular dimensions 1980x1080 here:
A random image related to music and guitar:
An image which changes daily in particular dimensions:
A liked image by a user in particular dimensions:
An image from a category further filtered for the provided tag(s) in particular dimensions:
Many other combinations are possible with the below mentioned APIs, happy hacking!
In order to fetch the url you can chain methods in any order but remember to call
fetch() at the end of method chain. The
fetch() call will return the url which you can use in your own preferred way such as by using the Fetch API which returns a promise.
Sets the photoId to retrieve a particular image:
Get a random image url for a particular category:
Get a random image url from a particular user:
Get a random liked image url from a particular user:
Get a random image url from a particular collection:
Sets the image dimensions for the image url. If only width is passed, height will be defaulted to the value of width to return a 1:1 size url:
Sets the image change frequency:
Takes an array of tags as parameter and returns a url with the added tags:
All the API calls can be chained in any interesting way to meet your needs. Just remember to call
fetch() at the end of the chain.
The library is quite extensible and can be modified according to your needs. Feel free to clone the repo and send in pull requests.
Clone the project and run the following commands using
Run tests (maybe in a new terminal window):
When adding new functionality to the library tests are run from