Giter VIP home page Giter VIP logo

pexels-api-wrapper's Introduction

Pexels API

A simple wrapper to use the Pexels API. Please refer to the API docs to undestand the inputs and expected results.

Installation

Install the package

$ cd /path/to/app
$ npm install --save pexels-api-wrapper

Usage

//In NodeJS App

//Require Wrapper Library
const PexelsAPI = require('pexels-api-wrapper');

//Create Client instance by passing in API key
var pexelsClient = new PexelsAPI("<API_KEY>");

//Search API
pexelsClient.search("food", 10, 1)
    .then(function(result){
        console.log(result);
    }).
    catch(function(e){
        console.err(e);
    });

//Get Popular Photos
pexelsClient.getPopularPhotos(10, 1)
    .then(function(result){
        console.log(result);
    }).
    catch(function(e){
        console.err(e);
    });

//Get Curated Photos (undocumented Endpoint)
pexelsClient.getCuratedPhotos(10, 1)
    .then(function(result){
        console.log(result);
    }).
    catch(function(e){
        console.err(e);
    });

API

Search

Promise factory to interact with Pexels Search API

Param Type Description
query string The search term to query the API with
per_page number The number of results to return per page (Defaults to 10)
page number The page number to return (Defaults to 1)
PexelsAPI.search(query, per_page, page);

Popular

Promise factory to interact with Pexels Popular Photos API

Param Type Description
per_page number The number of results to return per page (Defaults to 10)
page number The page number to return (Defaults to 1)
PexelsAPI.getPopularPhotos(per_page, page);

Curated

Promise factory to interact with Pexels Curated Photos API

Param Type Description
per_page number The number of results to return per page (Defaults to 10)
page number The page number to return (Defaults to 1)
PexelsAPI.getCuratedPhotos(per_page, page);

Test

Before Testing against the Pexels API please place your personal API key in the ``ìndex.test.js```file.

const API_KEY = 'YOUR_API_KEY_HERE'

Then run the test scripts:

npm test

Acknowledgements

Thanks, Pexels for creating a great platform for great images. Always rooting for you.

Made with ❤️ at Shopalyst

pexels-api-wrapper's People

Contributors

alexclaes avatar

Watchers

 avatar

Forkers

luciditydesign

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.