pikax / swgoh

Unofficial node library for swgoh.gg
MIT License
17 stars 4 forks source link
swgoh

Build Status npm version Coverage Status dependencies Status devDependencies Status Discord Known Vulnerabilities

changelog

INFORMATION 2018-09-16

swgoh is providing an API at https://swgoh.gg/api/, I strongly recommend using that, because this library currently is scrapping data from HTML. I will probably move this library to use swgoh.gg API, but that will be a breaking change and not backwards compatible because the interface contract will change aka the data return will be different.

Synopsis

Node library to get information of swgoh parsing swgoh.gg, you can get profile, characters, guild members, ships, units and mods.

Code Example

import

const swgoh = require("swgoh").swgoh
//or
import {swgoh} from 'swgoh';
const username= "pikax";
swgoh.profile(username).then(function (p) {
  console.log(p);

  return swgoh.guild(p.guildUrl);
}).then(console.log);
swgoh.collection(username).then(console.log);
swgoh.ship(username).then(console.log);

const allyCode= "495616697";
swgoh.profileAlly(allyCode).then(console.log);
swgoh.collectionAlly(allyCode).then(console.log);
swgoh.shipAlly(allyCode).then(console.log);
swgoh.modsAlly(allyCode).then(console.log);

const guild = "/g/232/requiem/"; // or {id:232}
swgoh.units(guild).then(console.log);

swgoh.guild(guild).then(console.log);

swgoh.mods(username).then(console.log);

// login
const user = {
    username: 'pikax',
    password: 'MySuperSecurePassword'
}

swgoh.login(user.username, user.password); //Promise<boolean>

//cached characters & ships
import {getCharacters, getShips} from 'swgoh';

Get swogh.gg assets

The asset location by default is to swogh/static/img, but you can reset to swgoh.gg using the environment config USE_SWGOH_ASSET=1

in code:

process.env.USE_SWGOH_ASSET = 1;

import {swgoh} from 'swgoh';

Get custom asset location

You can set a custom asset location by specifying it using environment config SWGOH_ASSET_LOCATION={assetpath}

in code

process.env.SWGOH_ASSET_LOCATION = "https://assets.mysupawebsite.web/swgoh";

import {swgoh} from 'swgoh';

Motivation

With TB just released, this library provides easy way to get data from swgoh.gg

Installation

yarn add swgoh
npm i swgoh

Changelog

All notable changes to this project will be documented in this file.

KNOWN issues

swgoh.gg is capping the number of mods you can get in your profile, I can't fix this without making breaking changes, you should use swoghApi.

[Unreleased]

[0.8.0] 2018-10-30

[0.7.1] 2018-09-16

[0.7.0] 2018-09-15

[0.6.0] 2018-08-26

[0.5.11] 2018-07-14

[0.4.10] 2018-06-29

[0.4.9] 2018-05-26

[0.4.8] 2018-05-17

[0.4.7] 2018-04-26

[0.4.6] 2018-04-12

[0.4.5] 2018-02-10

[0.4.4] 2018-02-10

[0.4.2] 2018-02-08

[0.4.1] 2018-01-07

[0.3.2] 2017-12-02

[0.3.1] 2017-09-28

[0.2.1] 2017-09-22

[0.1.3] 2017-09-20

[0.1.2] 2017-09-20

[0.1.1] 2017-08-19

[0.1.0] 2017-08-19

License

MIT

Disclaimer

The developer of this application does not have any affiliation with the Capital Games, Disney, Lucasfilm Limited or swgoh.gg.