Skip to content

Node.js client library for querying Pixabay API featuring strict parameter validation and automatic URL encoding.

License

Notifications You must be signed in to change notification settings

mattborja/node-pixabayclient.nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pixabay Client for Node.js

Client library for querying Pixabay API featuring strict parameter validation and automatic URL encoding.

Usage

To install:

npm install node-pixabayclient

The client library is capable of supporting any endpoint under the same API key by accepting a direct apiUrl option as a constructor "argument" as demonstrated below (see also demo.js).

For a complete list of API endpoints, please see https://pixabay.com/api/docs/.

const PixabayApi = require('node-pixabayclient');
const PixabayPhotos = new PixabayApi({ apiUrl: "https://pixabay.com/api/" });

var params = {
  key: "YOUR-PIXABAY_API_KEY_HERE",
  q: "yellow flowers", // automatically URL-encoded
  image_type: "photo",
};

PixabayPhotos.query(params, function(errors, res, req) {
  if (errors) {
    console.log('One or more errors were encountered:');
    console.log('- ' + errors.join('\n- '));
    return;
  }

  console.log('Photos request:');
  console.log(req);

  console.log('Photos API response:');
  console.log(res);
});
const PixabayApi = require('node-pixabayclient');
const PixabayVideos = new PixabayApi({ apiUrl: "https://pixabay.com/api/videos/" });

var params = {
  key: "YOUR-PIXABAY_API_KEY_HERE",
  q: "yellow flowers", // automatically URL-encoded
};

PixabayVideos.query(params, function(errors, res, req) {
  if (errors) {
    console.log('One or more errors were encountered:');
    console.log('- ' + errors.join('\n- '));
    return;
  }

  console.log('Videos request:');
  console.log(req);

  console.log('Videos API response:');
  console.log(res);
});

About

Node.js client library for querying Pixabay API featuring strict parameter validation and automatic URL encoding.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published