0.0.2 • Published 8 years ago

astrobinapi v0.0.2

Weekly downloads
8
License
VUL
Repository
github
Last release
8 years ago

AstroBinAPI

Node.js AstroBin API library.

Installation

Download and install via npm package manager (stable):

npm install astrobinapi

Or clone fresh code directly from git:

git clone https://github.com/kosmodrey/AstroBinAPI.git
cd AstroBinAPI
npm install

Usage

'use strict';

const AstroBinAPI = require('astrobinapi');

// Set a new object with your API keys
const astrobin = new AstroBinAPI({
  key: '0000000000000000000000000000000000000000',
  secret: '0000000000000000000000000000000000000000'
});

// Get Image Of The Day
astrobin.imageOTD({ limit: 1 }).then(result => {
  for (let image of result) {
    console.log('IOTD:', image);
  }
}).catch(error => console.log('Error:', error));

// Find images
astrobin.find({ title: 'luna', limit: 2 }).then(result => {
  for (let image of result) {
    console.log('Find:', image);
  }
  // Get next images
  return result.next();
}).then(result => {
  console.log('Next find:', result.objects);
}).catch(error => console.log('Error:', error));

// Get image
astrobin.image(148462).then(image => {
  console.log('Image:', image);
}).catch(error => console.log('Error:', error));