Coder Social home page Coder Social logo

unsplash-search's Introduction

Unsplash Search Wrapper (Typescript)

Coverage Status Build Status

Unsplash? Beautiful, free photos brought to you by the world’s most generous community of photographers. With this module, you can search on Unsplash, access the credits and download high-resoulution version. (even raw)

You can integrate it to the admin panel, use in web page, electron app or in node app.

Features

  • Search in
    • all Unsplash photos
    • only landscapes
    • only portraits
    • only squarish (Instagram ready)
  • Result includes
    • Author credits
    • Links (raw, download, full-size, thumbnail)
    • Related color
    • Dimension
    • Likes

Requirements

Getting Started

Installation:

npm install unsplash-search

Basic Usage

Create an instance with a valid API access key (see Requirements) A working demo on mnfy.me/unsplash-search-demo (Made with React) Demo source code also avialable on https://github.com/arifaydogmus/unsplash-search-demo

import UnsplashSearch from 'unsplash-search';

const accessKey = '<your api access key>';
const provider = new UnsplashSearch(acessKey);

// Search 'berlin' and get 3rd page
provider
  .searchAll('berlin', 3)
  .then(data => {
    console.log('Total images in result:', data.totalImages);
    console.log('Total pages', data.totalPages);

    data.images.forEach(image => {
      console.log(
        `Taken by ${image.author.name} and download on ${image.urls.full}`
      );
    });
  })
  .catch(error => error);

Demo screen shot


API Methods

Following methods available names and paramters (if available) describe it self.

searchAll(keyword, page)

Searches in all available photos

searchLandscapes(keyword, page)

Searches only landscape oriented photos

searchPortraits(keyword, page)

Searches only portrait oriented photos

searchSquares(keyword, page)

Searches only square size photos

getQueryLimit()

Returns your API query limit

getRemaingQuery()

Returns your remaining API call

getItemsPerPage()

Returns active setting for how many images will be in result. Default is 10.

setItemsPerPage(limit)

Set setting for how many images will be in result Max is 30 according to Unsplash API.

Warnings

  • Unsplash official API has orient base search but the images in result may not be your selection.
  • Obviously the wrapper uses the Unsplash API so, respect to API query limitations.

License

ISC License - Arif Aydogmus

unsplash-search's People

Contributors

arifaydogmus avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.