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

@pokelib/pokemon-tcg-sdk-typescript

v2.1.4

Published

Typescript SDK for the PokemonTCG API (https://pokemontcg.io)

Downloads

11

Readme

Pokémon TCG TypeScript SDK

pokemontcg-developers on discord pokemon-tcg-sdk-typescript build status

This is the TypeScript SDK for the Pokémon Trading Card Game API.

The original SDK project seems abandoned some years already. In order to have a cleaner repository I decided not to fork the old project, but to start a ne repository. But credits to the original project as well as all it's contributors (whose names are still mentioned here in the contributors ection!).

Installation

npm

npm install @pokelib/pokemon-tcg-sdk-typescript

yarn

yarn add @pokelib/pokemon-tcg-sdk-typescript

Configuration

The SDK works out of the box! Simply import the SDK, and you're ready to go:

import { PokemonTCG } from 'pokemon-tcg-sdk-typescript';

PokemonTCG.findCardByID('xy7-54').then((card: PokemonTCG.Card) => {
  console.log(card.name); // Gardevoir
});

It is recommended to use an API key for version 2 of the API. By default, requests are limited to 20,000/day. Requests are rate limited to 1000 requests a day, and a maximum of 30 per minute.

To use the SDK with an API key, create an account at https://dev.pokemontcg.io to grab an API key. Then set your API key to the environment variable POKEMONTCG_API_KEY in a .env file. Make sure to use this exact environment variable, otherwise the SDK will not be able to read the API key.

Usage

All function calls return generic promises like Promise<T> or Promise<T[]>

Card Methods

Set Methods

findCardByID()

Returns a single Pokémon card given an ID.

import { PokemonTCG } from 'pokemon-tcg-sdk-typescript';

PokemonTCG.findCardByID('xy7-54').then((card: PokemonTCG.Card) => {
  console.log(card.name); // Gardevoir
});

findCardByQueries()

Returns an array of cards filtered through a search query.

import { PokemonTCG } from 'pokemon-tcg-sdk-typescript';

const params: PokemonTCG.Query[] = { q: 'id:xy7-54' };

PokemonTCG.findCardsByQueries(params).then((cards: PokemonTCG.Card[]) => {
  console.log(card[0].name); // Gardevoir
});

getAllCards()

Returns all Pokémon cards available through recursive pagination.

import { PokemonTCG } from 'pokemon-tcg-sdk-typescript';

PokemonTCG.getAllCards();

getTypes()

Returns all Energy Types

import { PokemonTCG } from 'pokemon-tcg-sdk-typescript';

PokemonTCG.getTypes();

getSupertypes()

Returns all Super Types

import { PokemonTCG } from 'pokemon-tcg-sdk-typescript';

PokemonTCG.getSupertypes();

getSubtypes()

Returns all Sub Types

import { PokemonTCG } from 'pokemon-tcg-sdk-typescript';

PokemonTCG.getSubtypes();

getRarities()

Returns all card Rarities

import { PokemonTCG } from 'pokemon-tcg-sdk-typescript';

PokemonTCG.getRarities();

findSetByID()

Returns a single Pokémon card given an ID.

import { PokemonTCG } from 'pokemon-tcg-sdk-typescript';

PokemonTCG.findSetByID('base1').then((set: PokemonTCG.Set) => {
  console.log(set.name); // Base
});

findSetByQueries()

Returns an array of cards filtered through a search query.

import { PokemonTCG } from 'pokemon-tcg-sdk-typescript';

const params: PokemonTCG.Query[] = { q: 'name:Base' };

PokemonTCG.findSetsByQueries(params).then((sets: PokemonTCG.Set[]) => {
  console.log(sets[0].name); // Base
});

getAllSets()

Returns all Pokémon sets available through recursive pagination.

import { PokemonTCG } from 'pokemon-tcg-sdk-typescript';

PokemonTCG.getAllSets();

Contributing

Contributions are welcome! If you want to contribute, feel free to fork the repository, open and issue, then submit a pull request. ESLint and Prettier are used to enforce a consistent coding style.

Setup

Raring to code your heart out? Awesome! Here's how to get started:

  1. Open and issue with a bug or feature. Ensure the change is not already being worked on.
  2. Fork and clone the repository from the master branch.
  3. Create a feature branch.
  4. Run npm ci to install exact versions specified in the package-lock.json.
  5. Code your heart out!
  6. Run npm run test to run ESLint and Jest tests.
  7. (OPTIONAL) Test your changes in a project of yours:
    1. Create a link with npm or yarn (depending on what tool you installed this SDK with)
    2. In your project that uses the SDK, install the linked package with yarn/npm link pokemon-tcg-sdk-typescript
    3. Verify the SDK behaves as expected, and your changes took effect
  8. Submit a pull request! 🎉