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

fightcade-api

v4.0.1

Published

An unofficial TypeScript wrapper for the Fightcade API.

Downloads

92

Readme

fightcade-api

An unofficial TypeScript wrapper for the Fightcade Public API.

Installation

bun add fightcade-api
pnpm install fightcade-api
npm install fightcade-api
yarn add fightcade-api

Example usage

There are several examples provided in the source's TSDoc.

This library supports TS, ESM, and CommonJS.

ECMAScript Modules

import { Fightcade } from 'fightcade-api';

You can also import library functions individually:

import { GetUser } from 'fightcade-api';

CommonJS

const Fightcade = require('fightcade-api');

GetUser

async function GetUser(username: string): Promise<Fightcade.User>;
import { Fightcade } from 'fightcade-api';

try {
  // Print the amount of ranked matches per game for the user 'biggs'.
  const user = await Fightcade.GetUser('biggs');
  Object.entries(user.gameinfo).forEach(([gameid, gameinfo]) => {
    if (gameinfo.rank) console.log(`${gameid}: ${gameinfo.num_matches}`);
  });
} catch(e) {
  console.error(e);
}

GetReplay

async function GetReplay(quarkid: string): Promise<Fightcade.Replay>;
import { Fightcade } from 'fightcade-api';

try {
  // Print the date of the replay '1638725293444-1085'
  const replay = await Fightcade.GetReplay('1638725293444-1085');
  const date = new Date(replay.date);
  console.log(date.toString());
} catch(e) {
  console.error(e);
}

GetReplays

async function GetReplays(): Promise<Fightcade.Replay[]>;
async function GetReplays(args: {gameid?: string, limit?: number, offset?: number, best?: boolean, since?: number, ranked?: boolean}): Promise<Fightcade.Replay[]>;
async function GetReplays(args = {}): Promise<Fightcade.Replay[]>;
import { Fightcade } from 'fightcade-api';

try {
  // Print the game channel names of the 15 most recent replays.
  const replays = await Fightcade.GetReplays();
  replays.forEach(replay => console.log(replay.channelname));
} catch(e) {
  console.error(e);
}

GetUserReplays

async function GetUserReplays(username: string): Promise<Fightcade.Replay[]>;
async function GetUserReplays(username: string, args: {limit?: number, offset?: number, best?: boolean, since?: number, ranked: boolean}): Promise<Fightcade.Replay[]>;
async function GetUserReplays(username: string, args = {}): Promise<Fightcade.Replay[]>;
import { Fightcade } from 'fightcade-api';

try {
  // Print the game channel names of the 15 most recent replays belonging to the user 'biggs'.
  const replays = await Fightcade.GetUserReplays('biggs');
  replays.forEach(replay => console.log(replay.channelname));
} catch(e) {
  console.error(e);
}

GetReplayURL

function GetReplayURL(replay: Fightcade.Replay): string;
import { Fightcade } from 'fightcade-api';

try {
  // Print the replay URLs of the 15 most recent replays belonging to the user 'biggs'.
  const user_replays = await Fightcade.GetUserReplays('biggs');
  user_replays.forEach(replay => console.log(Fightcade.GetReplayURL(replay)));
} catch(e) {
  console.error(e);
}

GetRankings

async function GetRankings(gameid: string): Promise<Fightcade.Player[]>;
async function GetRankings(gameid: string, args: {limit?: number, offset?: number, byElo?: boolean, recent?: boolean}): Promise<Fightcade.Player[]>;
async function GetRankings(gameid: string, args = {}): Promise<Fightcade.Player[]>;
import { Fightcade } from 'fightcade-api';

try {
  // Print the top 15 recent ranked UMK3 players and their ranks.
  const gameid = 'umk3';
  const rankings = await Fightcade.GetRankings(gameid);
  rankings.forEach(player => {
    if (player.gameinfo && player.gameinfo[gameid].rank) {
      console.log(`${Fightcade.Rank[player.gameinfo[gameid].rank]}: ${player.name}`);
    }
  });
} catch(e) {
  console.log(e);
}

GetGame

async function GetGame(gameid: string): Promise<Fightcade.Game>;
import { Fightcade } from 'fightcade-api';

try {
  // Prints the publisher of the game 'umk3'.
  const game = await Fightcade.GetGame('umk3');
  console.log(game.publisher);
} catch(e) {
  console.log(e);
}

GetEvents

async function GetEvents(args: {gameid?: string, limit?: number, offset?: number} = {}): Promise<Fightcade.Event[]>;
import { Fightcade } from 'fightcade-api';

try {
  // Print the 15 most recent active events for all games.
  const events = await Fightcade.GetEvents();
  events.forEach(event => console.log(event));
} catch(e) {
  console.log(e);
}

Deprecated Functions

GetVideoURL() and GetVideoURLs() have been deprecated because https://fightcadevids.com is currently abandoned.

GetVideoURL

async function GetVideoURL(replay: string): Promise<string>;
async function GetVideoURL(replay: Fightcade.Replay): Promise<string>;
async function GetVideoURL(replay: string | Fightcade.Replay): Promise<string>;
import { Fightcade } from 'fightcade-api';

try {
  // Print the Replay's FightcadeVids URL.
  const replay = await Fightcade.GetReplay('1638725293444-1085');
  const url = await Fightcade.GetVideoURL(replay);
  console.log(url ?? 'Replay not found.');
} catch(e) {
  console.error(e);
}

GetVideoURLs

async function GetVideoURLs(replays: string[]): Promise<Fightcade.VideoURLs>;
async function GetVideoURLs(replays: Replay[]): Promise<Fightcade.VideoURLs>;
async function GetVideoURLs(replays: string[] | Replay[]): Promise<Fightcade.VideoURLs>;
import { Fightcade } from 'fightcade-api';

try {
  // Print the replay's FightcadeVids URLs if there are any.
  const replays = await Fightcade.GetReplays();
  const urls = await Fightcade.GetVideoURLs(replays);
  Object.values(urls).forEach(url => console.log(url));
} catch(e) {
  console.error(e);
}

Links