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

chess-com

v1.3.1

Published

A wrapper to access information from the public chess.com API

Downloads

27

Readme

About

Interact with chess.com API

chess-com is a Node.js module written in TypeScript that allows you to interact with chess.com public APIs and retrieve informations such as:

  • Users' general profile info
  • Users' ratings and winrates
  • All user's matches
  • Matches' move sequences and results
  • All daily puzzles

Installation

Node.js and npm required!

Run into your project's terminal:

npm install chess-com

Examples

Importing the package:

import chess from 'chess-com';

Getting a player's information

import chess from 'chess-com';

async function run() {
    const player = await chess.getPlayer('davipccunha');
    if (!player) return;

    console.log(player.profile.joined); //1614884411
    console.log(player.stats.getStats('rapid').rating); //1202
}

run();

Getting a random daily puzzle

import chess from 'chess-com';

async function run() {
    const puzzle = await chess.getDailyPuzzle(true);
    if (!puzzle) return;

    console.log(puzzle.fen); // 2r5/5Npk/4p2p/8/3P4/3pP2P/5PP1/R5K1 b - - 0 1
    console.log(puzzle.solution); // 1...d2 2.Rd1 Rc1 3.Kf1 Rxd1+ 4.Ke2 Rf1 5.Kxd2 Rxf2+
}

run();

Getting the number of games the player played the French Defense opening

import chess from 'chess-com';
import { ArchivesGame } from 'chess-com';

async function run() {
    const player = await chess.getPlayer('davipccunha');
    if (!player) return;

    const archives = await player.games.getArchivedGames();
    if (!archives) return;

    const frenchGames = archives.filter((game: ArchivesGame) => game.moves.startsWith('1. e4 e6'));

    console.log(frenchGames.length); // 361
}

run();

Found a problem?

Please let me know of any problems found by filing an issue in GitHub issue. If you have any suggestion or just want to contact me, please send an email to [email protected]

Known issues

Here is the list of already known problems that I'm working on a fix:

Donations

If you are feeling generous and/or would like to support this and other future open-source projects, you can make a donation at my Buy me a coffee page