1.0.2 • Published 2 years ago

hearthstone-card-info v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

TypeScript HearthStone Card Info Library

npm npm bundle size

Module to retrieve Hearthstone information about the cards, types etc from Hearthstone API.

Installation

  • Sign up for your free API Key on Rapid API
  • Install hearthstone-card-info library with:
npm i hearthstone-card-info

Link to npm library

Usage

const HearthstoneInfo = require("hearthstone-card-info");

// Insert your RapidApi API Key:
const myApiKey = "<MYAPIKEY>";

// Instantiate a new HearthstoneInfo class
const hearthstone = new HearthstoneInfo(myApiKey);

// Use the mothods below to return you the information you want in the form of a Promise:
hearthstone.getFileInfo("info").then((data) => console.log(data));
/* 
  {
  patch: '24.4.0.150659',
    classes: [
      'Death Knight', 'Druid',
      'Hunter',       'Mage',
      'Paladin',      'Priest',
      'Rogue',        'Shaman',
      'Warlock',      'Warrior',
      'Dream',        'Neutral',
      'Whizbang',     'Demon Hunter'
    ],
    sets: [
      'Basic',
        etc....
    }
  }
*/

hearthstone
  .getSingleCard("Leeroy Jenkins")
  .then((card) => console.log(card[5]));
/*
  {
    name: 'Leeroy Jenkins',
    img: 'https://d15f34w2p8l1cc.cloudfront.net/hearthstone/cf014c0c9363f70cb7e4f7f7c4086ab42bc5d2afecf421f35b9c87c81943d9d4.png',
    flavor: 'At least he has Angry Chicken.'
  }
*/

hearthstone.getRaceCard("Pirate").then((race) => console.log(race[1]));
/*
  {
    cardId: 'LT23_803H2',
    dbfId: 87090,
    name: 'Cutthroat Willie',
    cardSet: 'Mercenaries',
    type: 'Minion',
    rarity: 'Epic',
    cost: 0,
    attack: 10,
    health: 120,
    text: 'Protectors take @ more damage.',
    race: 'Pirate',
    playerClass: 'Neutral',
    locale: 'enUS'
  }
*/

hearthstone.getTypeCard("Minion").then((type) => console.log(type[0]));
/*
  {
    cardId: 'TSC_777t25',
    dbfId: 91587,
    name: '???',
    cardSet: 'Voyage to the Sunken City',
    type: 'Minion',
    cost: 0,
    attack: 0,
    health: 1,
    text: '<b>???</b>',
    playerClass: 'Neutral',
    locale: 'enUS'
  }
*/

hearthstone
  .getFactionCard("Neutral")
  .then((faction) => console.log(faction[0]));
/*
  {
    cardId: 'BAR_753',
    dbfId: 70579,
    name: '???',
    cardSet: 'Forged in the Barrens',
    type: 'Hero Power',
    faction: 'Neutral',
    text: '<b>???</b>',
    playerClass: 'Neutral',
    locale: 'enUS'
  }
*/

Testing

To run tests:

  • Include your API key in the tests/test.js file. Then run:
npm test
1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago