npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

unsplash-source-es6

v1.2.1

Published

A minimal ES6 ready Javascript wrapper for Unsplash Source API https://source.unsplash.com/

Downloads

4

Readme

Unsplash Source ES6

Build Status npm npm

A minimal ES6 ready Javascript wrapper for Unsplash Source API https://source.unsplash.com/ :camera:

Just install and make use of Unsplash's powerful API without any API keys or client IDs.

Installation

Unsplash Source ES6 is available as a node package. Get it via yarn or npm:

yarn add unsplash-source-es6

-or-

npm install unsplash-source-es6

If using npm, you might want to save to your package.json:

npm install --save unsplash-source-es6

Usage

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.

API examples

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:

unsplash.fetch();

Simply a random image:

unsplash.fetch();

A random image in particular dimensions 1980x1080 here:

unsplash.size(1980, 1080).fetch();

A random image related to music and guitar:

unsplash.search(['music', 'guitar']).fetch();

An image which changes daily in particular dimensions:

unsplash.frequency('daily').size(1980, 1080).fetch();

A liked image by a user in particular dimensions:

unsplash.liked('divyanshu013').size(1980, 1080).fetch();

An image from a category further filtered for the provided tag(s) in particular dimensions:

unsplash.category('technology').search(['music']).size(1980, 1080).fetch();

Many other combinations are possible with the below mentioned APIs, happy hacking! :smiley_cat:

APIs

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.

id(photoId)

Sets the photoId to retrieve a particular image:

unsplash.id('xyz').fetch();

category(categoryName)

Get a random image url for a particular category:

  • buildings
  • food
  • nature
  • people
  • technology
  • objects
unsplash.category('technology').fetch();

user(username)

Get a random image url from a particular user:

unsplash.user('divyanshu013').fetch();

liked(username)

Get a random liked image url from a particular user:

unsplash.liked('divyanshu013').fetch();

collection(collectionId)

Get a random image url from a particular collection:

unsplash.collection('abc').fetch();

size(width, height)

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:

unsplash.size(1920, 1080).fetch();

frequency(freq)

Sets the image change frequency:

  • daily
  • weekly
unsplash.frequency('daily').fetch();

search([...tags])

Takes an array of tags as parameter and returns a url with the added tags:

unsplash.search(['music', 'guitar']).fetch();

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.

Extending functionality

The library is quite extensible and can be modified according to your needs. Feel free to clone the repo and send in pull requests.

Contributing

Clone the project and run the following commands using yarn or npm.

Install dependencies:

yarn install

Build library:

yarn build:watch

Run tests (maybe in a new terminal window):

yarn test:watch

When adding new functionality to the library tests are run from /test/library.spec.js.