fast-poke-fetch

2.4.3 • Public • Published

Pokémon API Client

npm version

This is a simple Node.js client for fetching data from the PokéAPI. It provides functions to retrieve information about Pokémon, moves, and items. Additionally, it includes caching functionality to improve performance and reduce the number of API requests.

Installation

To use this Pokémon API client, you can install it using npm:

`npm install fast-poke-fetch`

Usage

Import the module

const { Pokemon, PokeItem, PokeMove } = require('fast-poke-fetch');

Fetch Pokemon Data

const pikachuData = await  Pokemon('pikachu'); console.log(pikachuData);

Example Return

{  "id":  25,  "name":  "pikachu",  "height":  4,  "weight":  60,  "types":  ["electric"],  "abilities":  ["static",  "lightning-rod"],  "sprites":  {  "front_shiny":  "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/shiny/25.png"  }  }

Fetch Item Data

const potionData = await  PokeItem('potion'); console.log(potionData);

Example Return

{  "id":  1,  "name":  "potion",  "effect_entries":  [  {  "effect":  "Heals a Pokémon by 20 HP.",  "short_effect":  "Heals by 20 HP."  }  ],  "sprites":  {  "front_shiny":  "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/items/shiny/1.png"  }  }

Fetch Move Data

const tackleData = await  PokeMove('tackle'); console.log(tackleData);

Example Return

{  "id":  33,  "name":  "tackle",  "pp":  35,  "effect_entries":  [  {  "effect":  "Inflicts regular damage with no additional effects.",  "short_effect":  "Inflicts damage."  }  ]  }

Caching Data

This client uses caching to reduce the number of API requests and speed up return time. Cached data is stored for a default of 900 seconds (15 minutes). It is periodically checked every 300 seconds for stale data. You can configure the caching settings by modifying the cache object in the code.

Dependents (0)

Package Sidebar

Install

npm i fast-poke-fetch

Weekly Downloads

1

Version

2.4.3

License

ISC

Unpacked Size

30.5 kB

Total Files

11

Last publish

Collaborators

  • eg-school