GithubHelp home page GithubHelp logo

luisramirez-m / node-callofduty Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lierrmm/node-callofduty

0.0 1.0 0.0 196 KB

Node Wrapper for the "private" Call Of Duty API.

License: MIT License

JavaScript 100.00%

node-callofduty's Introduction

https://npmjs.org/package/call-of-duty-api https://www.github.com/sponsors/lierrmm https://www.paypal.me/liammm

MAJOR CHANGES

You will now have to login to the API before making any requests. This means you will need a call of duty account. Simply call:

 const API = require('call-of-duty-api')();
 API.login("<email>", "<password>").then(<?>).catch(<?>);

Reasons for this is to bypass a rate limitting issue.

I have also implemented axios-rate-limit incase you want to implement your own rate limitting. All you need to do is pass a ratelimit object when initializing the module.

    const API = require('call-of-duty-api')( { platform: 'battle', ratelimit: { maxRequests: 2, perMilliseconds: 1000, maxRPS: 2 } } );

You can find out more about axios-rate-limit here

Discord

Join the discord: here

Call Of Duty API Wrapper

Call of Duty Api is a wrapper for the "private" API that Activision use on the callofduty.com website.

Install

npm install call-of-duty-api

Initialize Module

const API = require('call-of-duty-api')();

or

const API = require('call-of-duty-api')({ platform: "battle" });

List of Platforms

  • psn
  • steam
  • xbl
  • battle
  • uno (activision ID)
//How to use
API.platforms.psn

Please note: uno is for looking up via activision ID and this is only supported on a couple of endpoints.

Supported Endpoints for activision ID

  • MWcombatmp
  • MWcombatwz
  • MWmp
  • MWwz
  • MWstats

Get Stats

API.MWstats(<gamertag>, API.platforms.<platform>).then((output) => {
    console.log(output);  
}).catch((err) => {
    console.log(err);
});

Output

{
    title: 'mw',
    platform: 'platform',
    username: 'gamertag',
    mp:
    { lifetime: { all: [Object], mode: [Object] },
    weekly: null,
    level: 0,
    maxLevel: 0,
    levelXpRemainder: 0,
    levelXpGained: 0,
    prestige: 0,
    prestigeId: 0,
    maxPrestige: 0 },
    zombies:
    { lifetime: { all: [Object], mode: {} },
    weekly: { all: [Object], mode: {} } },
    engagement: { timePlayedAll: 440544, seasonPass: 1 } 
}

Example Project

const API = require('call-of-duty-api')({ platform: "battle" });
//I want Warzone Data
API.MWBattleData('Lierrmm#2364').then(data => {
    console.log(data);  // see output
}).catch(err => {
    console.log(err);
});

Output

[ br: { wins: 1,
    kills: 77,
    kdRatio: 1.2833333333333334,       
    downs: 70,
    topTwentyFive: 20,
    topTen: 11,
    contracts: 15,
    revives: 0,
    topFive: 6,
    score: 55600,
    timePlayed: 27169,
    gamesPlayed: 20,
    scorePerMinute: 122.78699988958003,
    cash: 0,
    deaths: 60,
    title: 'br' },
  br_dmz: { wins: 0,
    kills: 9,
    kdRatio: 1.2857142857142858,
    downs: 11,
    topTwentyFive: 0,
    topTen: 0,
    contracts: 2,
    revives: 0,
    topFive: 0,
    score: 4574,
    timePlayed: 1786,
    gamesPlayed: 1,
    scorePerMinute: 153.66181410974244,
    cash: 53,
    deaths: 7,
    title: 'br_dmz' },
  br_all: { wins: 1,
    kills: 86,
    kdRatio: 1.2835820895522387,
    downs: 81,
    topTwentyFive: 20,
    topTen: 11,
    contracts: 17,
    revives: 0,
    topFive: 6,
    score: 60174,
    timePlayed: 28955,
    gamesPlayed: 21,
    scorePerMinute: 124.6914177171473,
    cash: 53,
    deaths: 67,
    title: 'br_all' } ]

node-callofduty's People

Contributors

bryanberger avatar codacy-badger avatar dtslubbersen avatar j-swift avatar lierrmm avatar luisramirezdev avatar snyk-bot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.