Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
pexels-api-wrapper
Advanced tools
A simple wrapper to use the Pexels API. Please refer to the API docs to undestand the inputs and expected results.
Install the package
$ cd /path/to/app
$ npm install --save pexels-api-wrapper
//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
pexelsClient.getCuratedPhotos(10, 1)
.then(function(result){
console.log(result);
}).
catch(function(e){
console.err(e);
});
//Get Photo by ID
pexelsClient.getPhoto(123456)
.then(function(result){
console.log(result);
}).
catch(function(e){
console.err(e);
});
//Search Video API
pexelsClient.searchVideos("food", 10, 1)
.then(function(result){
console.log(result);
}).
catch(function(e){
console.err(e);
});
//Get Popular Videos
pexelsClient.getPopularVideos(10, 1)
.then(function(result){
console.log(result);
}).
catch(function(e){
console.err(e);
});
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);
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);
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);
Promise factory to fetch a single photo from Pexels Photos API
Param | Type | Description |
---|---|---|
id | number | The ID of the photo |
PexelsAPI.getPhoto(id);
Promise factory to interact with Pexels Videos 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) |
min_width | number | The minimum width in pixels of the returned videos. (optional) |
max_width | number | The maximum width in pixels of the returned videos. (optional) |
min_duration | number | The minimum duration in seconds of the returned videos. (optional) |
max_duration | number | The maximum duration in seconds of the returned videos. (optional) |
PexelsAPI.searchVideos(query, per_page, page, min_width, max_width, min_duration, max_duration);
Promise factory to interact with Pexels Popular Videos 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) |
min_width | number | The minimum width in pixels of the returned videos. (optional) |
max_width | number | The maximum width in pixels of the returned videos. (optional) |
min_duration | number | The minimum duration in seconds of the returned videos. (optional) |
max_duration | number | The maximum duration in seconds of the returned videos. (optional) |
PexelsAPI.getPopularVideos(per_page, page, min_width, max_width, min_duration, max_duration);
Version | Changes |
---|---|
v1.0.8 | First published version |
v1.1.1 | Extended library to accommodate new APIs: getCuratedPhotos getPhoto searchVideos getPopularVideos , Base URL uses HTTPS by default |
v1.1.2 | Extended library to accommodate new parameters for width and duration |
apiKey
and useHttps
as options to start with which can drive whether the client uses HTTP or HTTPS. This will also create a structure which can allow future extensibility by adding keys to the options object.node-fetch
and use an isomorphic version instead. The current version, as it stands, is not optimal to be used on the browser.Thanks, Pexels for creating a great platform for great images. Always rooting for you.
I'd like to thank all the folks taking the time out to keep this library in sync with the Pexels API. Power to you!
Shout out to: @fcrespo82, @jeffski and jbuchmann-coosto for their pull requests which has kept the library in sync with the changes in the API.
FAQs
A simple promise wrapper for the Pexels API
The npm package pexels-api-wrapper receives a total of 137 weekly downloads. As such, pexels-api-wrapper popularity was classified as not popular.
We found that pexels-api-wrapper demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.