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

cod-api

v4.1.0

Published

A Call of Duty Network API wrapper written in Typescript

Downloads

29

Readme

cod-api

A thin Call of Duty API wrapper written in TypeScript

Not licensed by or affiliated with Activision or Call of Duty

  • Full Black Ops 4 Support - blackout, mp, zombies
  • Get profile information - prestige, rank, xp, and more...
  • Get recent matches and stats - map, mode, win/loss, kills, deaths, SPM, K/D Ratio, and more...
  • Get leaderboard information - weekly, monthly, alltime, for all game modes

Installing

You can install via the npm package manager

npm i cod-api

Or clone the repository and install dependencies

git clone https://github.com/jakejrichards/cod-api.git

Black Ops 4

import { BO4 } from 'cod-api'

const username = 'Consisttt'; // username
const platform = 'psn'; // psn | xbl | battle

// Retrieve Raw Responses

BO4.getRawMultiplayerStats(username, platform)
    .then(multiplayerStats => {
        
    });

BO4.getRawBlackoutStats(username, platform)
    .then(blackoutStats => {
    
    });

BO4.getRawZombiesStats(username, platform)
    .then(zombiesStats => {
       
    });

const start = new Date(/*start time*/);
const end = new Date(/*end time*/);

BO4.getRawMultiplayerMatchesStats({ username, platform, start, end })
    .then(matchesStats => {
        
    });

BO4.getRawZombiesMatchesStats({ username, platform, start, end })
    .then(matchesStats => {
        
    });

BO4.getRawBlackoutMatchesStats({ username, platform, start, end })
    .then(matchesStats => {
        
    });

// Specific Methods

BO4.getLifetimeMultiplayerStats(username, platform)
    .then(lifetime => {
        const totalKills = data.all.kills;
    });

BO4.getWeeklyMultiplayerStats(username, platform)
    .then(weekly => {
        const weeklyWins = data.all.wins;
    });

BO4.getOverallZombiesStats(username, platform)
    .then(data => {
        const totalKills = data.kills;
    });

BO4.getOverallBlackoutStats(username, platform)
    .then(data => {
        const blackoutWins = data.wins;
    });

BO4.getMultiplayerMatchesStats({ username, platform, start, end })
    .then(matches => {
        const [ match ] = matches;
    })

BO4.getBlackoutMatchesStats({ username, platform, start, end })
    .then(matches => {
        const [ match ] = matches;
    })

BO4.getZombiesMatchesStats({ username, platform, start, end })
    .then(matches => {
        const [ match ] = matches;
    })

These endpoints are not yet populated with data on the official call of duty api:

  • getSoloBlackoutStats
  • getDuoBlackoutStats
  • getQuadBlackoutStats

Legacy COD Titles

Methods for titles released before Black Ops 4

Get Profile

import { LegacyCOD } from 'cod-api';

LegacyCOD.getProfile({ title, platform, username })
    .then(response => {
        // Do something...
        console.log(response);
    })
    .catch(err => {
        // Do something with this error
        console.log(err);
    });

Sample Output:

{ title: 'wwii',
platform: 'psn',
username: 'Consisttt',
mp: 
{ lifetime: { all: [Object], mode: [Object] },
    weekly: { all: [Object], mode: [Object] },
    level: 42,
    maxLevel: 0,
    levelXpRemainder: 26990,
    levelXpGained: 13010,
    prestige: 5,
    prestigeId: 0,
    maxPrestige: 0 },
zombies: 
{ lifetime: { all: {}, mode: {} },
    weekly: { all: {}, mode: {} } },
engagement: null }

Get Recent Matches

import { LegacyCOD } from 'cod-api';

LegacyCOD.getRecentMatches({ title, platform, username, days })
    .then(response => {
        // Do something...
        console.log(response);
    })
    .catch(err => {
        // Do something with this error
        console.log(err);
    });

Sample Output:

[ { utcStartSeconds: 1518474308,
    utcEndSeconds: 1518474994,
    duration: 685,
    map: 'mp_france_village',
    mode: 'hp',
    result: 'none',
    winningTeam: 'allies',
    privateMatch: false,
    gameBattle: false,
    playlistName: null,
    player: 
    { awards: [Object],
    team: 'axis',
    rank: 41,
    prestige: 5,
    loadouts: [Object]
    },
    playerStats: 
    { kills: 0,
    shotsMissed: 634,
    kdRatio: 0,
    distanceTravelled: 90335.734375,
    divisionXpMountain: 0,
    accuracy: 0.25323910482921086,
    divisionXpExpeditionary: 0,
    divisionXpInfantry: 0,
    divisionXpArmored: 0,
    shotsLanded: 215,
    divisionXpAirborne: 0,
    avgSpeed: 174.0572967529297,
    avgKillDistance: 465.7652587890625,
    score: 6900,
    totalXp: 4000,
    timePlayed: 685.9,
    headshots: 0,
    divisionXpNone: 0,
    assists: 10,
    divisionXpResistance: 0,
    shotsFired: 849,
    deaths: 0
    }
}
]

Get Summary

import { LegacyCOD } from 'cod-api';

LegacyCOD.getRecentSummary({ title, platform, username, days })
    .then(response => {
        // Do something...
        console.log(response);
    })
    .catch(err => {
        // Do something with this error
        console.log(err);
    });

Sample Output:

{ all: 
{ kills: 88,
    distanceTravelled: 529676.67578125,
    divisionXpMountain: 0,
    accuracy: 0.255205688166582,
    divisionXpExpeditionary: 0,
    losses: 1,
    shotsLanded: 1005,
    score: 30885,
    totalXp: 85200,
    headshots: 5,
    assists: 52,
    divisionXpResistance: 4275,
    scorePerMinute: 194.1486157311611,
    deaths: 50,
    wins: 4,
    shotsMissed: 2933,
    kdRatio: 1.76,
    divisionXpInfantry: 0,
    divisionXpArmored: 0,
    divisionXpAirborne: 0,
    avgSpeed: 1541.1485290527344,
    avgKillDistance: 4201.184417724609,
    timePlayed: 9544.75,
    matchesPlayed: 12,
    divisionXpNone: 0,
    shotsFired: 3938
}
}

Get Leaderboards

import { LegacyCOD } from 'cod-api';

LegacyCOD.getLeaderboards({ title, platform, time, type, mode, username })
    .then(response => {
        // Do something...
        console.log(response);
    })
    .catch(err => {
        // Do something with this error
        console.log(err);
    });

Sample Output:

{ title: 'wwii',
platform: 'psn',
leaderboardType: 'core',
gameMode: 'war',
page: 3969,
resultsRequested: 20,
totalPages: 288978,
sort: null,
columns: 
[ 'prestige',
    'totalXp',
    'kills',
    'deaths',
    'assists',
    'score',
    'timePlayed' ],
entries: 
[ { rank: 79361,
    username: 'itsESPALDINHO79',
    updateTime: 294760,
    rating: 5972,
    values: [Object] },
    { rank: 79380,
    username: 'Consisttt',
    updateTime: 7900,
    rating: 5972,
    values: [Object] } ] }

License

This project is licensed under the MIT License