Skip to content

Using CodTracker API to get Black Ops 4 data. Intention is to use with stream overlay or chat bot.

License

Notifications You must be signed in to change notification settings

I-M-G/BlackOps4Stats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Black Ops 4 Stats

Using COD Tracker API for player stats. Initial intention is to use with a stream overlay and/or chat bot. Data for streaming is output to text files that can be used in OBS or Xsplit.

The API supports BO4, BO3, IW, and WWII. This project is currently only using BO4, so the endpoints may differ if you want other game data. API Endpoint: https://cod-api.tracker.gg/v1/standard/{GAME}/profile/{PLATFORM}/{NAME}

Project Setup

  1. You'll need to get an API key from here.
  2. Install init npm and install dependencies. I'm using request and filesystem, but only request needs to be installed npm i request.
  3. Create an auth.js or .env file to store your key and other sensitive data. Change or update auth.apiKey and auth.gamertag in app.js. You'll also want to update the platform. 1 = XBOX, 2 = PSN, 3 = BattleNet.
const options = {
  url: `https://cod-api.tracker.gg/v1/standard/bo4/profile/${auth.platform}/${auth.gamertag}`,
  headers: {
    'TRN-Api-Key': auth.apiKey
  }
}
  1. Update the path for saving the text files in Data.js. You can save anywhere you'd like.
let writeFiles = (fileName, fileType, data) => {
  fs.writeFile(`./Data/${fileName}.${fileType}`, data, error => {
    if(error) console.log(error);

    console.log('FILE SAVED');
  });
}
  1. Uncomment the for loop in Data.js inside the handleData function. The writeFiles function saves data to a Data folder in the project, so you'll need to change or update that.
// for(let i = 0; i < stats.length; i++) {
//   writeFiles(stats[i].title, 'txt', stats[i].value);
// }

Steam Setup

Just going to show how to bring in text files to the most common streaming software. For now that will be OBS and Xsplit.

These steps were last tested with OBS version 22.0.2

  • Open OBS and go to the scene that will use the data.
  • Click the plus sign to add a new source. Then select the "Text (GDI+)" option.

Add text file source

  • A sub menu will open. You can name your new source here if you wish. Click "OK" when you are finished.

Name your scene

  • The next menu will let you configure the text's display on the stream. Here we will add the file we wish to display. Select the check box "Read from file" and then select "Browse". Navigate to the location of the saved files. You'll need to run the app once or you will not have your files yet.

Add your text file

  • You can customize the font, color, background and a few other options, but at this point you are done with adding the files. Click "OK" and then position and resize as you need within your scene.

These steps were last tested with Xsplit version 3.6 and a premium license.

  • Open Xsplit and go to the scene that will use the data.
  • Select "Add source" and then click "Text...".

Add text file source

  • A sub menu will open, click the check box "Use custom script" and then select "Edit Script".

Edit script

  • From the "Template" drop down select "Load Text from Local File".

Load text from local file

  • In the settings tab go to the "File Path" option and navigate to the location of the saved files. You'll need to run the app once or you will not have your files yet.

Add file path

  • In this menu you can also add an update interval. This will check the file for changes every X amount of seconds. Probably best to keep this low, so your stream is getting the new data when it's pushed to the file. Not sure about any performance issues a smaller number could have.
  • Finally, click "Update Text" and you are essentially done. You can customize the font, color, background and a few other options at this point. Click "OK" and then position and resize as you need within your scene.

About

Using CodTracker API to get Black Ops 4 data. Intention is to use with stream overlay or chat bot.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published