1.0.1 • Published 6 years ago

@leandrino/pexels-wrapper v1.0.1

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

Pexels Wrapper

Unofficial simple pexels photos wrapper.

Installation

$ npm install @leandrino/pexels-wrapper --save

How to use

ES6

// to import a specific method
import PexelsWrapper from 'pexels-wrapper';

const pexels = new PexelsWrapper({
  apiUrl: 'https://api.pexels.com/v1'  ,
  apiKey: 'YOUR_TOKEN_HERE'
});

// using  method
pexels.searchPhotos.default('dogs')

CommonJS

const PexelsWrapper = require('pexels-wrapper');

const pexels = new PexelsWrapper({
  apiUrl: 'https://api.pexels.com/v1'  ,
  apiKey: 'YOUR_TOKEN_HERE'
});

UMD in Browser

<script src="main.js"></script>

After that the library will be available to the Global as `PexelsWrapper`. Follow an example:

```js
const pexels = new Pexels.PexelsWrapper({
  apiUrl: 'https://api.pexels.com/v1'  
  apiKey: 'YOUR_TOKEN_HERE'
});

const dogs = pexels.searchPhotos.default('dogs');

Methods

Follow the methods that the library provides.

searchPhotos.default(query)

Search photos with provided query.

Arguments

ArgumentTypeOptions
querystring'Get photos related to this query'

Example

pexels.searchPhotos.default('dogs')
  .then(data => {
    // do what you want with the data
  })

searchPhotos.withPagination(query, perPage, page)

Search photos with provided query and pagination.

Arguments

ArgumentTypeOptions
querystringGet photos related to this query'
perPagenumber'Defines the number of results per page'
querystring'Defines the number of the page'

Example

pexels.searchPhotos.withPagination('dogs', 20, 1)
  .then(data => {
    // do what you want with the data
  })

License

This project is licensed under the MIT License