If you play on Null’s Brawl, the popular private server version of Brawl Stars, you might want to track your matches — to analyze performance, compare results with friends, or simply keep a fun history of your battles.
In this article, we’ll walk through how to fetch and display battle logs from Null’s Brawl using Node.js and a simple API call.
Prerequisites
Before getting started, make sure you have the following:
- Node.js (version 16 or newer)
- A text editor like VS Code
- Null’s Brawl API access
(usually https://api.nulls.gg/brawl/v1/) - Your player tag and, if required, an API token
If you’re not sure where to find your player tag — open Null’s Brawl, go to your profile, and copy the string starting with #.
Step 1: Setting Up Your Project
First, create a folder for your project and initialize Node.js:
mkdir nulls-brawl-tracker
cd nulls-brawl-tracker
npm init -y
npm install axios
We’ll be using Axios to send HTTP requests to the API.
Step 2: Fetching Battle Logs
Create a file named battleLogs.js and paste the following code:
// battleLogs.js
const axios = require("axios");
const API_URL = "https://api.nulls.gg/brawl/v1";
const PLAYER_TAG = "#YOUR_PLAYER_TAG"; // Example: "#2P0LQ9R9"
const TOKEN = "YOUR_API_TOKEN"; // Optional depending on API
async function fetchBattleLogs() {
try {
const response = await axios.get(
`${API_URL}/players/${encodeURIComponent(PLAYER_TAG)}/battlelog`,
{
headers: {
Authorization: `Bearer ${TOKEN}`,
},
}
);
const logs = response.data.items;
console.log("🕹️ Recent Battles:");
logs.slice(0, 5).forEach((battle, index) => {
const mode = battle.event.mode;
const result = battle.battle.result || "unknown";
const duration = battle.battle.duration || "N/A";
const time = battle.battleTime;
console.log(
`${index + 1}. Mode: ${mode} | Result: ${result} | Duration: ${duration}s | Time: ${time}`
);
});
} catch (error) {
console.error("❌ Error fetching battle logs:", error.message);
}
}
fetchBattleLogs();
Step 3: Understanding the Code
Here’s what’s happening:
- Axios makes a GET request to the Null’s Brawl API endpoint /players/{tag}/battlelog.
- The player tag identifies your account.
- The API responds with a JSON object containing recent battle data.
- The script loops through the first 5 entries and logs the key information (game mode, result, and duration).
Example Output
When you run the script using:
node battleLogs.js
You should see something like:
Recent Battles:
1. Mode: gemGrab | Result: victory | Duration: 125s | Time: 2025-10-25T18:42:00Z
2. Mode: showdown | Result: defeat | Duration: 98s | Time: 2025-10-25T18:30:00Z
3. Mode: heist | Result: victory | Duration: 110s | Time: 2025-10-25T18:18:00Z
Step 4: Automating Battle Tracking
You can automate this tracker to run every few minutes or hours. Add this snippet at the end of your file:
// Fetch logs every 10 minutes
setInterval(fetchBattleLogs, 10 * 60 * 1000);
This allows you to keep an updated feed of your latest matches without manual input.
Optional: Create a Simple Web Dashboard
Want to visualize your battles? You can easily serve this data using Express.js.
npm install express
Then create a simple server.js file:
const express = require("express");
const app = express();
const PORT = 3000;
const battleLogs = require("./battle_history.json");
app.get("/", (req, res) => {
res.send(`
<h1>Null’s Brawl Battle Tracker</h1>
<pre>${JSON.stringify(battleLogs.slice(0, 5), null, 2)}</pre>
`);
});
app.listen(PORT, () => console.log(`🚀 Server running at http://localhost:${PORT}`));
Now open your browser at http://localhost:300 to see your latest battle data in a neat JSON format.
Step 5: Ideas for Expansion
Once you’ve got the basics working, here are a few ideas to enhance your project:
- Visualize stats (win rate, favorite brawlers, most played maps)
- Add date filters to analyze performance over time
- Set up Discord or Telegram notifications for battle results
- Integrate with a database (e.g., MongoDB or SQLite)
- Build a front-end UI with React or Vue to view data nicely
Final Thoughts
Tracking your Null’s Brawl battle logs with Node.js is a fun and practical way to explore APIs while learning about real-time data fetching.
Whether you’re a developer, a gamer, or just curious about how APIs work — this project gives you a simple yet powerful foundation to build upon.
s.js` and past
Top comments (0)