Duolingo Tracker Skill
Fetch Duolingo user stats via the unofficial Duolingo API. No official API key required — uses the same endpoints the Duolingo web app uses.
Authentication setup
Duolingo does not offer an official public API. The tracker uses the cookie-based session token from an active browser session.
One-time setup:
- 1. Log in to duolingo.com in your browser
- Open DevTools → Application → Cookies → INLINECODE0
- Copy the value of the
jwt_token cookie - Save it: INLINECODE2
Alternatively the user can provide their username only — a subset of public stats is available without auth.
Base URL
CODEBLOCK0
All requests should include:
Accept: application/json
Content-Type: application/json
Authorization: Bearer $DUOLINGO_JWT # omit if unauthenticated
Fetch user profile and streak
CODEBLOCK2
Key fields to surface:
| Field | Meaning |
|---|
| INLINECODE3 | Current day streak |
| INLINECODE4 |
Days in current streak |
|
streakData.longestStreak.length | All-time longest streak |
|
totalXp | Lifetime XP |
|
xpGoal | Daily XP goal |
|
xpGoalMetToday | Whether today's goal is met (bool) |
|
courses[].xp | XP per language course |
|
courses[].crowns | Crowns earned per course |
|
courses[].title | Language name |
Fetch leaderboard / league info
CODEBLOCK3
League tiers (low → high): Bronze, Silver, Gold, Sapphire, Ruby, Emerald, Amethyst, Pearl, Obsidian, Diamond.
Fetch XP summary (last 7 days)
CODEBLOCK4
Set startDate to 7 days ago. Returns daily XP totals — use these to show a mini chart or bar summary.
Displaying results
Present stats in this format:
CODEBLOCK5
If the daily goal is not yet met, flag it clearly so the user knows to practice today.
Public stats (no auth required)
For users who don't want to share their JWT, these endpoints work without auth for public profiles:
CODEBLOCK6
Returns streak, learning_language, level, totalXp, courses. Fewer fields but sufficient for a quick summary.
Common issues
| Problem | Fix |
|---|
| 401 Unauthorized | JWT expired — user needs to re-copy token from browser |
| Empty streak data |
User hasn't practiced in 7+ days (streak likely 0) |
| Username not found | Check exact username (case-sensitive) on duolingo.com/profile |
| Rate limited (429) | Wait 60 seconds before retrying |
Privacy note
Always remind the user that their JWT token is sensitive — treat it like a password. Never log it or include it in outputs.
Duolingo 追踪器技能
通过非官方 Duolingo API 获取 Duolingo 用户数据。无需官方 API 密钥——使用与 Duolingo 网页应用相同的接口。
身份验证设置
Duolingo 不提供官方公共 API。该追踪器使用活跃浏览器会话中的基于 Cookie 的会话令牌。
一次性设置:
- 1. 在浏览器中登录 duolingo.com
- 打开开发者工具 → 应用 → Cookie → duolingo.com
- 复制 jwttoken Cookie 的值
- 保存:export DUOLINGOJWT=你的令牌
或者用户也可以仅提供其用户名——无需身份验证即可获取部分公开数据。
基础 URL
https://www.duolingo.com/2017-06-30
所有请求应包含:
Accept: application/json
Content-Type: application/json
Authorization: Bearer $DUOLINGO_JWT # 未认证时省略
获取用户资料和学习连续记录
bash
curl -s https://www.duolingo.com/2017-06-30/users?username=用户名&fields=streak,xpGoal,xpGoalMetToday,lingots,totalXp,currentCourse,courses,streakData \
-H Authorization: Bearer $DUOLINGO_JWT \
-H Accept: application/json
需要展示的关键字段:
| 字段 | 含义 |
|---|
| streak | 当前连续学习天数 |
| streakData.currentStreak.length |
当前连续学习天数 |
| streakData.longestStreak.length | 历史最长连续学习天数 |
| totalXp | 总经验值 |
| xpGoal | 每日经验值目标 |
| xpGoalMetToday | 今日是否达成目标(布尔值) |
| courses[].xp | 每门语言课程的经验值 |
| courses[].crowns | 每门课程获得的皇冠数 |
| courses[].title | 语言名称 |
获取排行榜/联赛信息
bash
先从资料中获取用户ID,然后:
curl -s https://duolingo-leaderboards-prod.duolingo.com/leaderboards/7d9f5dd1-8423-491a-91f2-2532052038d8/users/用户ID?get
usersonly=true \
-H Authorization: Bearer $DUOLINGO_JWT
联赛等级(从低到高):青铜、白银、黄金、蓝宝石、红宝石、翡翠、紫水晶、珍珠、黑曜石、钻石。
获取经验值汇总(最近7天)
bash
curl -s https://www.duolingo.com/2017-06-30/users/用户ID/xp_summaries?startDate=YYYY-MM-DD \
-H Authorization: Bearer $DUOLINGO_JWT
将 startDate 设置为7天前。返回每日经验值总计——可用于显示迷你图表或柱状汇总。
显示结果
按以下格式展示数据:
🔥 连续学习:47天(最长:93天)
⭐ 今日:150 XP / 100 XP 目标 ✓
📚 活跃课程:西班牙语(es)— 3,420 XP,42个皇冠
🏆 联赛:黄金 | 每周经验值:892
每周经验值:
周一 ████████ 180
周二 ██████ 120
周三 █████ 100
周四 ████████ 160
周五 ██████ 132
周六 ███ 60
周日 ████████ 140
如果每日目标尚未达成,请明确标记,以便用户知道今天需要练习。
公开数据(无需身份验证)
对于不想分享 JWT 的用户,以下接口无需认证即可获取公开资料:
bash
curl -s https://www.duolingo.com/users/用户名 \
-H Accept: application/json
返回 streak、learning_language、level、totalXp、courses。字段较少,但足以提供快速概览。
常见问题
| 问题 | 解决方法 |
|---|
| 401 未授权 | JWT 已过期——用户需要重新从浏览器复制令牌 |
| 连续学习数据为空 |
用户已超过7天未练习(连续学习天数可能为0) |
| 未找到用户名 | 检查确切的用户名(区分大小写)在 duolingo.com/profile 上 |
| 请求频率限制(429) | 等待60秒后重试 |
隐私说明
始终提醒用户,他们的 JWT 令牌是敏感信息——应像密码一样对待。切勿记录或将其包含在输出中。