โ† Back to Web & Frontend Development

monkeytype-tracker

Track and analyze Monkeytype typing statistics

0
Source Code

Monkeytype Tracker

Track your Monkeytype typing statistics and get personalized improvement tips.

Pre-Flight Check (ALWAYS DO THIS FIRST)

Before running ANY command, check if setup is complete:

Security Priority:

  1. Environment variable (most secure): MONKEYTYPE_APE_KEY
  2. Config file fallback: ~/.openclaw/workspace/config/monkeytype.json
# Check environment variable first
ape_key = os.getenv('MONKEYTYPE_APE_KEY')
if not ape_key:
    # Check config exists and has valid key
    config_path = Path.home() / ".openclaw" / "workspace" / "config" / "monkeytype.json"

If no env var AND no config: โ†’ Run Setup Flow (Step 1) If apeKey exists but API returns 471 "inactive": โ†’ Tell user to activate the key (checkbox) If apeKey works: โ†’ Proceed with command

Setup Flow (3 Steps)

Step 1: Get ApeKey

Send this message:

Hey! ๐Ÿ‘‹ I see you want to track your Monkeytype stats. I'll need your API key to get started.

**๐Ÿ”‘ How to get it:**
1. Go to monkeytype.com โ†’ **Account Settings** (click your profile icon)
2. Select **"Ape Keys"** from the left sidebar
3. Click **"Generate new key"**
4. โš ๏ธ **Activate it:** Check the checkbox next to your new key (keys are inactive by default!)
5. Copy the key and send it to me

Once you share the key, I'll ask about automation preferences ๐Ÿค–

---

๐Ÿ”’ **Prefer to add it manually?** No problem!

**Option 1: Environment Variable (Recommended - Most Secure)**
Set in your system:
- Windows (PowerShell): `$env:MONKEYTYPE_APE_KEY="YOUR_KEY_HERE"`
- Linux/Mac: `export MONKEYTYPE_APE_KEY="YOUR_KEY_HERE"`

**Option 2: Config File**
Create this file: `~/.openclaw/workspace/config/monkeytype.json`
With this content:
{
  "apeKey": "YOUR_KEY_HERE"
}

Then just say "monkeytype stats" and I'll take it from there!

After receiving key:

  1. Save to ~/.openclaw/workspace/config/monkeytype.json:
{
  "apeKey": "USER_KEY_HERE",
  "automations": {
    "dailyReport": false,
    "weeklyReport": false,
    "reportTime": "20:00"
  }
}
  1. Test the key immediately by running python scripts/monkeytype_stats.py stats
  2. If 471 error โ†’ Key is inactive, ask user to check the checkbox
  3. If success โ†’ Proceed to Step 2

Step 2: Verify & Ask Automation Preferences

After key verification succeeds, send:

Got it! Key saved and verified โœ…

**๐Ÿ“Š Quick Overview:**
โ€ข {tests} tests completed ({hours} hrs)
โ€ข ๐Ÿ† PB: {pb_15}WPM (15s) | {pb_30}WPM (30s) | {pb_60}WPM (60s)
โ€ข ๐Ÿ”ฅ Current streak: {streak} days

Now, would you like automated reports?

**Options:**
1๏ธโƒฃ **Daily report** โ€” Summary of the day's practice
2๏ธโƒฃ **Weekly report** โ€” Week-over-week comparison + tips
3๏ธโƒฃ **Both**
4๏ธโƒฃ **None** โ€” On-demand only

โฐ What time should I send reports? (default: 8pm)

Step 3: Finalize Setup

After user chooses options:

  1. Update config with preferences
  2. Create cron jobs if automations enabled:
    • Daily: 0 {hour} * * * with name monkeytype-daily-report
    • Weekly: 0 {hour} * * 0 with name monkeytype-weekly-report
  3. Send completion message:
๐ŸŽ‰ **You're all set!**

**โœ… Config saved:**
โ€ข Weekly report: {status}
โ€ข Daily report: {status}

**๐Ÿ’ก Try these anytime:**
โ€ข "show my typing stats"
โ€ข "how's my typing progress"
โ€ข "compare my typing this week"
โ€ข "monkeytype leaderboard"

Happy typing! May your WPM be ever higher ๐Ÿš€โŒจ๏ธ

Error Handling

Error User Message
No config file "Looks like Monkeytype isn't set up yet. Let me help you get started! ๐Ÿ”‘" โ†’ Start Setup Flow
No apeKey in config Same as above
API 471 "inactive" "Your API key is inactive. Go to Monkeytype โ†’ Account Settings โ†’ Ape Keys and check the checkbox next to your key to activate it โœ…"
API 401 "unauthorized" "Your API key seems invalid. Let's set up a new one." โ†’ Start Setup Flow
API rate limit "Hit the API rate limit. Try again in a minute โณ"
Network error "Couldn't reach Monkeytype servers. Check your connection and try again."

Commands

Fetch Stats

Triggers: "show my monkeytype stats", "how's my typing", "typing stats"

  1. Pre-flight check (see above)
  2. Run: python scripts/monkeytype_stats.py stats
  3. Format output nicely with emojis

Recent History & Analysis

Triggers: "analyze my recent typing", "how have I been typing lately"

  1. Pre-flight check
  2. Run: python scripts/monkeytype_stats.py history --limit 50
  3. Analyze output and provide 2-3 improvement tips

Progress Comparison

Triggers: "compare my typing progress", "am I improving"

  1. Pre-flight check
  2. Run: python scripts/monkeytype_stats.py compare

Leaderboard Lookup

Triggers: "monkeytype leaderboard", "where do I rank"

  1. Pre-flight check
  2. Run: python scripts/monkeytype_stats.py leaderboard [--mode time] [--mode2 60]

Improvement Tips Logic

After fetching stats, analyze and provide tips based on:

Issue Tip
StdDev > 15 "Focus on consistency โ€” slow down and aim for 95%+ accuracy every test"
Accuracy < 95% "Accuracy builds speed. Slow down until you hit 95%+ consistently"
60s << 30s PB "Stamina gap detected. Practice longer tests to build endurance"
Low test count "More practice = faster progress. Aim for 5-10 tests daily"
Streak broken "Consistency matters! Try to type a bit every day"

API Notes

  • Base URL: https://api.monkeytype.com
  • Auth header: Authorization: ApeKey {key}
  • Rate limits: 30 req/min global, 30/day for results endpoint
  • Cache results locally when possible

Files

  • ~/.openclaw/workspace/config/monkeytype.json: User config
  • scripts/monkeytype_stats.py: Main stats fetcher script