npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@esponjosin/pokeapi.js

v0.0.2

Published

pokeapi.js is a module that obtains the data from the page https://pokeapi.co and that allows the user to interact with the page in an easier way

Downloads

3

Readme

PokeApi.js

npm i @esponjosin/pokeapi.js

Spanish

Info

/**
 * @param {string} [dir] Path where the cache will be stored
 */

const PokeClient = new (require('pokeapi.js'))(dir)

findPoke

/**
 * @param {string/number} [poke] Name or id of the pokemon to search
 */

const PokeClient = new (require('pokeapi.js'))(__dirname)

PokeClient.findPoke('1')

/**
Expected Promise Output
{<Pokemon> class}
 */

findMove

/**
 * @param {string/number} [move] Name or id of the move to search
 */

const PokeClient = new (require('pokeapi.js'))(__dirname)

PokeClient.findMove('1')

/**
Expected Promise Output
{<Move> class}
 */

findType

/**
 * @param {string/number} [type] Name or id of the type to search
 */

const PokeClient = new (require('pokeapi.js'))(__dirname)

PokeClient.findType('1')

/**
Expected Promise Output
{<Type> class}
 */

findAbility

/**
 * @param {string/number} [ability] Name or id of the ability to search
 */

const PokeClient = new (require('pokeapi.js'))(__dirname)

PokeClient.findAbility('1')

/**
Expected Promise Output
{<Ability> class}
 */

Example with discord.js

const Discord = require('discord.js');
const PokeClient = new (require('pokeapi.js'))(__dirname)
 
const client = new Discord.Client();
 
const settings = {
  prefix: '!',
  token: 'YOURTOKEN'
}
 
client.on('message', async message => {
 
  var command = message.content.toLowerCase().slice(settings.prefix.length).split(' ')[0];
 
  var args = message.content.split(' ').slice(1);
 
  if (!message.content.startsWith(settings.prefix) || message.author.bot) return;
 
  if (command === 'pokemon') {
      
      if(!args[0]) return message.channel.send(':x: | You need to enter the name of a pokemon or its id')

      let Pokemon = await PokeClient.findPoke(args[0]).catch(e => false)

      if(!Pokemon) return message.channel.send(':x: | The pokemon was not found')

      let moves = Pokemon.getMoves()
      let abilities = Pokemon.getAbilities()
      let types = Pokemon.getTypes()

      message.channel.send(`**${Pokemon.getID()}** ${Pokemon}
Moves: ${moves.map(x => `\`${x}\``).join(', ')}
Abilities: ${abilities.map(x => `\`${x}\``).join(', ')}
Types: ${types.map(x => `\`${x}\``).join(', ')}`)

  }
  else if(command == 'move') {

    if(!args[0]) return message.channel.send(':x: | You need to enter the name of a move or its id')

    let Move = await PokeClient.findMove(args[0]).catch(e => false)

    if(!Move) return message.channel.send(':x: | The move was not found')

    let info = await Move.getInfo()
    
    message.channel.send(`**${info.id}** ${info.name}
Accuracy: \`${info.accuracy || 0}\`
Power: \`${info.power || 0}\`
PP: \`${info.pp || 0}\`
Class: \`${info.class || 'None'}\`
Target: \`${info.target || 'None'}\`
Effect: \`${info.effect || 'None'}\`
Flavor effect: \`${info.flavor_effect || 'None'}\``)

  }
  else if(command == 'ability') {

    if(!args[0]) return message.channel.send(':x: | You need to enter the name of a move or its id')

    let Ability = await PokeClient.findAbility(args[0]).catch(e => false)

    if(!Ability) return message.channel.send(':x: | The move was not found')

    let info = await Ability.getInfo()
    
    message.channel.send(`**${info.id}** ${info.name}
Accuracy: \`${info.accuracy || 0}\`
Effect: \`${info.effect || 'None'}\`
Flavor effect: \`${info.flavor_effect || 'None'}\``)

  }
  else if(command == 'type') {

    if(!args[0]) return message.channel.send(':x: | You need to enter the name of a type or its id')

    let Type = await PokeClient.findType(args[0]).catch(e => false)

    if(!Type) return message.channel.send(':x: | The type was not found')

    let info = await Type.getInfo()

    message.channel.send(`**${info.id}** ${info.name}
Moves: \`${info.moves.join(', ')}\`
Take double damage from: \`${info.double_damage_from ? info.double_damage_from.length > 0 ? info.double_damage_from.join(', ') : 'None' : 'None'}\`
Does double damage to: \`${info.double_damage_to ? info.double_damage_to.length > 0 ? info.double_damage_to.join(', ') : 'None' : 'None'}\`
Take half damage from: \`${info.half_damage_from ? info.half_damage_from.length > 0 ? info.half_damage_from.join(', ') : 'None' : 'None'}\`
Does half damage to: \`${info.half_damage_to ? info.half_damage_to.length > 0 ? info.half_damage_to.join(', ') : 'None' : 'None'}\`
Does not take damage from: \`${info.no_damage_from ? info.no_damage_from.length > 0 ? info.no_damage_from.join(', ') : 'None' : 'None'}\`
It doesn't hurt: \`${info.no_damage_to ? info.no_damage_to.length > 0 ? info.no_damage_to.join(', ') : 'None' : 'None'}\``)

  }

})

client.login(settings.token)