Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

m4a1.js

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

m4a1.js

Wrapper for CSGO stats.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

m4a1.js

CodeFactor NPM-Version NPM-Downloads Github Stars Issues

This a wrapper of the TRNetwork Public API for CSGO stats.

Instalattion

You gotta request a Free API key on Tracker.gg

Dependencies

axios

To install use:

npm i m4a1.js

You must call CSAPI.fetchUser before using any other method.

MethodsDescription
infouser info
statslifeline stats
weaponsweapons stats
mapsmaps stats

There are constants to format the string of maps and weapons (feel free to pr if something is missing)

const { MAPS, WEAPONS } = require('m4a1.js')
/* Maps */
MAPS['de_cbble']		// Cobblestone
MAPS['de_train']		// Train
MAPS['de_shorttrain']		// Train (wingman)
/* Weapons */
WEAPONS['ak47']			// AK-47
WEAPONS['deagle']		// Desert Eagle
WEAPONS['hkp2000']		// P2000

This module supports either

  • SteamID
  • Vanity URL

You can see the diference between them in this page

Example code: (Feel free to use my steamid for testing)

const { CSAPI } = require('m4a1.js')

try {

	const user = await CSAPI.fetchUser('iFraan_', 'YourApiKey')
	
	console.log('User:', user.info())
	/*
	User: {
		platform: 'steam' ,
		steamid: '76561198137433783' ,
		name: 'fran' ,
		avatar: 'https://avatars.akamai.steamstatic.com/b5ac48b867b9ac1935fc564eaf1b43e8ac326e24_full.jpg'
	}
	*/

	console.log('Stats:', user.stats())
	/*
	Stats: {
		timePlayedDisplay: '1,311h',
		timePlayed: 4722655,
		score: 248751,
		kills: 100376,
		deaths: 64971,
		kd: 1.5449354327315263,
		damage: 11336712,
		headshots: 42423,
		dominations: 649,
		shotsFired: 1308051,
		shotsHit: 299525,
		shotsAccuracy: 22.89857199757502,
		snipersKilled: 4619,
		dominationOverkills: 666,
		dominationRevenges: 177,
		bombsPlanted: 4962,
		bombsDefused: 989,
		moneyEarned: 191909700,
		hostagesRescued: 0,
		mvp: 11693,
		wins: 1466,
		ties: 0,
		matchesPlayed: 3877,
		losses: 2411,
		roundsPlayed: 68576,
		roundsWon: 1466,
		wlPercentage: 37.8,
		headshotPct: 42.3
	}
	*/

	console.log('Weapons:', user.weapons())
	/*
	Weapons: {
		ak47: {
		  kills: 24626,
		  shotsFired: 465473,
		  shotsHit: 107951,
		  shotsAccuracy: 23.191678142448648
		},
		aug: {
		  kills: 1253,
		  shotsFired: 25473,
		  shotsHit: 4664,
		  shotsAccuracy: 18.309582695402977
		},
		awp: {
		  kills: 8690,
		  shotsFired: 32426,
		  shotsHit: 9679,
		  shotsAccuracy: 29.84950348485783
		},
		...
	}
	*/
	console.log('Maps:', user.maps())
	/* 
	Maps: {
		de_cbble: { 
			rounds: 1595, 
			wins: 770, 
			wr: 0.4827586206896552 
		},
		de_inferno: { 
			rounds: 14407, 
			wins: 7198, 
			wr: 0.4996182411327827 
		},
		de_nuke: { 
			rounds: 687, 
			wins: 358, 
			wr: 0.5211062590975255 
		},
		...
	}
	*/

} catch (e) {
	console.log(e)
	/* Error: We could not find the player [player]. */
}

Disclaimer

This project is fully for educational purposes.

Keywords

FAQs

Package last updated on 29 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc