0.3.2 • Published 8 years ago

corpstats v0.3.2

Weekly downloads
21
License
-
Repository
github
Last release
8 years ago

corpstats

Build Status

corpstats is a small library for fetching data from ZKillboard or EVE-Kill(Not tested yet, but theoretically). Data is then wrapped into Javascript class objects. Fancy!

Dependencies

The only dependency is node-fetch.

Install

npm install corpstats --save

Usage

import corpstats from 'corpstats';

gives you access to class objects:

class Alliance { ID, Name }
class Character { ID, Name }
class Corporation { ID, Name }
class Faction { ID, Name }

class Item { Flag, Singleton, TypeID, QtyDropped, QtyDestroyed }
class Position { X, Y, Z }
class ZKB { LocationID, Hash, TotalValue, Points }

class Attacker { Alliance, Character, Corporation, Faction, DamageDone, FinalBlow, SecurityStatus, ShipTypeID, WeaponTypeID }
class Victim { Alliance, Character, Corporation, Faction, DamageTaken, ShipTypeID }

class Kill { Attackers[Attacker], Items[Item], Position, Victim, ZKB, KillID, KillTime, MoonID, SolarSystemID }

and access to object API, which returns API URLs:

  const API
  {
  	Alliance(id) =>
    {
    	Kills(year, month) => page => {
        	URL, Model: Kill
        },
        // NOT IMPLEMENTED YET
        Losses(year, month) => page => {
        	URL, Model: Loss
        }
    },
    Character(id) =>
    {
    	Kills(year, month) => page => {
        	URL, Model: Kill
        },
        // NOT IMPLEMENTED YET
        Losses(year, month) => page => {
        	URL, Model: Loss
        }
    },
    Corporation(id) =>
    {
    	Kills(year, month) => page => {
        	URL, Model: Kill
        },
        // NOT IMPLEMENTED YET
        Losses(year, month) => page => {
        	URL, Model: Loss
        }
    }
  };

and finally function Pull:

function Pull(path, options)
	return Promise

with default options:

const options = {
  apiUrl: 'https://zkillboard.com/api/',
  debug: false,
  maxEntriesPerPage: 200,
  startPage: 1,
  userAgent: `corpstats v${pkg.version} (bosektom@gmail.com) public`,
};

example:

import { API, Pull } from 'corpstats';

Pull(API.Alliance(99005770).Kills(2016, 2)).then(kills => {
  console.log(`Wingspan deliveries in february 2016: ${kills.length}`);
});
> Wingspan deliveries in february 2016: 1419

See this example on Tonic

Todo

Parsing for Losses endpoint.

Licence

The MIT License (MIT)

Copyright (c) 2016 Tomas Bosek bosektom@gmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago