@udondan/duolingo 1.0.2 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +278 -58
- package/dist/cli/config-file.d.ts +22 -0
- package/dist/cli/config-file.d.ts.map +1 -0
- package/dist/cli/config-file.js +68 -0
- package/dist/cli/config-file.js.map +1 -0
- package/dist/cli/program.d.ts +25 -0
- package/dist/cli/program.d.ts.map +1 -0
- package/dist/cli/program.js +190 -0
- package/dist/cli/program.js.map +1 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +8 -0
- package/dist/cli.js.map +1 -0
- package/dist/client/duolingo.d.ts +13 -10
- package/dist/client/duolingo.d.ts.map +1 -1
- package/dist/client/duolingo.js +56 -159
- package/dist/client/duolingo.js.map +1 -1
- package/dist/client/errors.d.ts +9 -0
- package/dist/client/errors.d.ts.map +1 -1
- package/dist/client/errors.js +28 -0
- package/dist/client/errors.js.map +1 -1
- package/dist/client/tts.d.ts +34 -0
- package/dist/client/tts.d.ts.map +1 -0
- package/dist/client/tts.js +97 -0
- package/dist/client/tts.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/mcp.d.ts +14 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +38 -0
- package/dist/mcp.js.map +1 -0
- package/dist/tools/account.d.ts.map +1 -1
- package/dist/tools/account.js +31 -621
- package/dist/tools/account.js.map +1 -1
- package/dist/tools/helpers.d.ts +11 -7
- package/dist/tools/helpers.d.ts.map +1 -1
- package/dist/tools/helpers.js +19 -50
- package/dist/tools/helpers.js.map +1 -1
- package/dist/tools/language.d.ts.map +1 -1
- package/dist/tools/language.js +63 -552
- package/dist/tools/language.js.map +1 -1
- package/dist/tools/shop.d.ts.map +1 -1
- package/dist/tools/shop.js +6 -93
- package/dist/tools/shop.js.map +1 -1
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +4 -0
- package/dist/version.js.map +1 -0
- package/dist/views/account.d.ts +15 -0
- package/dist/views/account.d.ts.map +1 -0
- package/dist/views/account.js +118 -0
- package/dist/views/account.js.map +1 -0
- package/dist/views/language.d.ts +38 -0
- package/dist/views/language.d.ts.map +1 -0
- package/dist/views/language.js +269 -0
- package/dist/views/language.js.map +1 -0
- package/dist/views/profile.d.ts +9 -0
- package/dist/views/profile.d.ts.map +1 -0
- package/dist/views/profile.js +77 -0
- package/dist/views/profile.js.map +1 -0
- package/dist/views/progress.d.ts +13 -0
- package/dist/views/progress.d.ts.map +1 -0
- package/dist/views/progress.js +142 -0
- package/dist/views/progress.js.map +1 -0
- package/dist/views/social.d.ts +9 -0
- package/dist/views/social.d.ts.map +1 -0
- package/dist/views/social.js +62 -0
- package/dist/views/social.js.map +1 -0
- package/dist/views/utils.d.ts +13 -0
- package/dist/views/utils.d.ts.map +1 -0
- package/dist/views/utils.js +30 -0
- package/dist/views/utils.js.map +1 -0
- package/dist/views/view.d.ts +44 -0
- package/dist/views/view.d.ts.map +1 -0
- package/dist/views/view.js +54 -0
- package/dist/views/view.js.map +1 -0
- package/package.json +23 -19
- package/dist/server.d.ts +0 -19
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js +0 -40
- package/dist/server.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
# @udondan/duolingo
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@udondan/duolingo)
|
|
4
|
+
[](https://hub.docker.com/r/udondan/duolingo)
|
|
5
|
+
[](https://www.npmjs.com/package/@udondan/duolingo)
|
|
6
|
+
[](https://github.com/udondan/duolingo/actions/workflows/ci.yml)
|
|
7
|
+
[](https://codecov.io/gh/udondan/duolingo)
|
|
8
|
+
[](https://qlty.sh/gh/udondan/projects/duolingo)
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
|
|
11
|
+
> [!NOTE]
|
|
12
|
+
> Unofficial community project. Not affiliated with, endorsed or authorized by Duolingo.
|
|
13
|
+
|
|
14
|
+
A TypeScript package that provides a **client library** for the Duolingo API, a
|
|
15
|
+
**command line interface** (`duolingo`) and an
|
|
4
16
|
**[MCP](https://modelcontextprotocol.io) server** for LLM agents (e.g. Claude).
|
|
5
17
|
|
|
6
18
|
Built natively in TypeScript against the unofficial Duolingo REST API — no third-party
|
|
@@ -9,28 +21,35 @@ Duolingo library dependency.
|
|
|
9
21
|
## Table of Contents
|
|
10
22
|
|
|
11
23
|
- [Getting Your JWT Token](#getting-your-jwt-token)
|
|
24
|
+
- [CLI](#cli)
|
|
25
|
+
- [Installation](#cli-installation)
|
|
26
|
+
- [Credentials](#credentials)
|
|
27
|
+
- [Commands](#commands)
|
|
28
|
+
- [With Docker](#with-docker)
|
|
12
29
|
- [MCP Server](#mcp-server)
|
|
13
30
|
- [Installation](#mcp-installation)
|
|
14
31
|
- [Claude Desktop](#claude-desktop)
|
|
15
32
|
- [Claude Code](#claude-code)
|
|
33
|
+
- [Docker MCP Toolkit](#docker-mcp-toolkit)
|
|
16
34
|
- [Available Tools](#available-tools)
|
|
17
35
|
- [Library](#library)
|
|
18
36
|
- [Installation](#library-installation)
|
|
19
37
|
- [Quick Start](#quick-start)
|
|
20
38
|
- [API Reference](#api-reference)
|
|
21
39
|
- [Development](#development)
|
|
40
|
+
- [Disclaimer](#disclaimer)
|
|
22
41
|
|
|
23
42
|
---
|
|
24
43
|
|
|
25
44
|
## Getting Your JWT Token
|
|
26
45
|
|
|
27
|
-
|
|
46
|
+
The CLI, the MCP server and the library all require a Duolingo JWT token for authentication.
|
|
28
47
|
|
|
29
48
|
1. Log in to [duolingo.com](https://www.duolingo.com) in your browser.
|
|
30
49
|
2. Open the browser developer console (F12 → Console tab).
|
|
31
50
|
3. Run:
|
|
32
51
|
```js
|
|
33
|
-
document.cookie.match(new RegExp('(^| )jwt_token=([^;]+)'))[0].slice(11)
|
|
52
|
+
document.cookie.match(new RegExp('(^| )jwt_token=([^;]+)'))[0].slice(11);
|
|
34
53
|
```
|
|
35
54
|
4. Copy the output — that is your JWT token.
|
|
36
55
|
|
|
@@ -38,6 +57,103 @@ Both the MCP server and the library require a Duolingo JWT token for authenticat
|
|
|
38
57
|
|
|
39
58
|
---
|
|
40
59
|
|
|
60
|
+
## CLI
|
|
61
|
+
|
|
62
|
+
### CLI Installation
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npm install -g @udondan/duolingo
|
|
66
|
+
duolingo --help
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Or run it without installing: `npx -y @udondan/duolingo --help`.
|
|
70
|
+
|
|
71
|
+
The CLI and the MCP server are also available as the Docker image
|
|
72
|
+
[`udondan/duolingo`](https://hub.docker.com/r/udondan/duolingo) (amd64 and
|
|
73
|
+
arm64), no Node.js needed. See [With Docker](#with-docker).
|
|
74
|
+
|
|
75
|
+
### Credentials
|
|
76
|
+
|
|
77
|
+
The CLI reads `DUOLINGO_USERNAME` and `DUOLINGO_JWT` from the environment. You
|
|
78
|
+
can also put them in `~/.config/duolingo/config`:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
mkdir -p ~/.config/duolingo
|
|
82
|
+
cat > ~/.config/duolingo/config <<'EOF'
|
|
83
|
+
DUOLINGO_USERNAME=your_username
|
|
84
|
+
DUOLINGO_JWT=your_jwt_token
|
|
85
|
+
EOF
|
|
86
|
+
chmod 0600 ~/.config/duolingo/config
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The file is only read when no other user can access it (mode `0600`).
|
|
90
|
+
Environment variables take precedence over the file.
|
|
91
|
+
|
|
92
|
+
### Commands
|
|
93
|
+
|
|
94
|
+
Output is JSON by default. Use `--format markdown` (or `-f markdown`) for the
|
|
95
|
+
same readable text the MCP tools return.
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
duolingo streak
|
|
99
|
+
duolingo --format markdown progress es
|
|
100
|
+
duolingo known-words fr --username someone
|
|
101
|
+
duolingo leaderboard --unit month
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
| Command | Description |
|
|
105
|
+
| --------------------------------------------------- | ------------------------------------------------------ |
|
|
106
|
+
| `user [-u name]` | Profile: name, bio, location, followers, languages |
|
|
107
|
+
| `settings` | Account settings |
|
|
108
|
+
| `streak [-u name]` | Current streak, daily goal and longest streak |
|
|
109
|
+
| `xp` | XP earned and lessons completed today |
|
|
110
|
+
| `languages [-u name] [-a]` | Languages being learned (`-a` for abbreviations) |
|
|
111
|
+
| `courses [-u name]` | All courses, including Math, Chess and Music |
|
|
112
|
+
| `friends` | Users the authenticated user follows |
|
|
113
|
+
| `calendar [-u name]` | Recent activity of the current course |
|
|
114
|
+
| `leaderboard [--unit week\|month]` | Friends ranked by XP |
|
|
115
|
+
| `shop` | Shop items and prices |
|
|
116
|
+
| `health` | Hearts and refill status |
|
|
117
|
+
| `currencies` | Gem and lingot balances |
|
|
118
|
+
| `streak-goal` | Current streak goal and checkpoints |
|
|
119
|
+
| `language <name> [-u name]` | Level, points and streak of a language (e.g. `French`) |
|
|
120
|
+
| `progress <abbr>` | Detailed progress in a language (e.g. `fr`) |
|
|
121
|
+
| `known-topics <abbr> [-u name]` | Learned topics |
|
|
122
|
+
| `unknown-topics <abbr> [-u name]` | Topics not learned yet |
|
|
123
|
+
| `golden-topics <abbr> [-u name]` | Fully mastered topics |
|
|
124
|
+
| `reviewable-topics <abbr> [-u name]` | Learned topics that need review |
|
|
125
|
+
| `known-words <abbr> [-u name]` | Words learned |
|
|
126
|
+
| `learned-skills <abbr> [-u name]` | Learned skills in learning order |
|
|
127
|
+
| `voices [abbr]` | Text-to-speech voices |
|
|
128
|
+
| `audio-url <word> [abbr] [--voice v] [--no-random]` | Pronunciation audio URL |
|
|
129
|
+
| `language-name <abbr> [-u name]` | Full name of a language (`fr` → `French`) |
|
|
130
|
+
| `abbreviation <name> [-u name]` | Abbreviation of a language (`French` → `fr`) |
|
|
131
|
+
| `mcp` | Start the MCP server (stdio) |
|
|
132
|
+
|
|
133
|
+
Errors go to stderr and the CLI exits with code 1.
|
|
134
|
+
|
|
135
|
+
### With Docker
|
|
136
|
+
|
|
137
|
+
Arguments after the image name are passed to the CLI. `-e NAME` without a
|
|
138
|
+
value takes the variable from your shell:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
docker run --rm -e DUOLINGO_USERNAME -e DUOLINGO_JWT udondan/duolingo streak
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
As an alias, the image behaves like an installed `duolingo`:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
alias duolingo='docker run --rm -e DUOLINGO_USERNAME -e DUOLINGO_JWT udondan/duolingo'
|
|
148
|
+
|
|
149
|
+
duolingo --format markdown progress es
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
The config file `~/.config/duolingo/config` is not visible inside the
|
|
153
|
+
container, so pass the credentials as environment variables.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
41
157
|
## MCP Server
|
|
42
158
|
|
|
43
159
|
### MCP Installation
|
|
@@ -45,23 +161,32 @@ Both the MCP server and the library require a Duolingo JWT token for authenticat
|
|
|
45
161
|
**Option A — run directly with npx (no install needed):**
|
|
46
162
|
|
|
47
163
|
```bash
|
|
48
|
-
DUOLINGO_USERNAME=your_username DUOLINGO_JWT=your_jwt npx @udondan/duolingo
|
|
164
|
+
DUOLINGO_USERNAME=your_username DUOLINGO_JWT=your_jwt npx -y @udondan/duolingo mcp
|
|
49
165
|
```
|
|
50
166
|
|
|
51
167
|
**Option B — install globally:**
|
|
52
168
|
|
|
53
169
|
```bash
|
|
54
170
|
npm install -g @udondan/duolingo
|
|
55
|
-
DUOLINGO_USERNAME=your_username DUOLINGO_JWT=your_jwt duolingo
|
|
171
|
+
DUOLINGO_USERNAME=your_username DUOLINGO_JWT=your_jwt duolingo mcp
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**Option C — run the Docker image:**
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
docker run --rm -i -e DUOLINGO_USERNAME -e DUOLINGO_JWT udondan/duolingo
|
|
56
178
|
```
|
|
57
179
|
|
|
58
|
-
|
|
180
|
+
Without arguments, the image starts the MCP server. `-i` keeps stdin open,
|
|
181
|
+
which the server uses to talk to the client.
|
|
182
|
+
|
|
183
|
+
**Option D — clone and build from source:**
|
|
59
184
|
|
|
60
185
|
```bash
|
|
61
186
|
git clone https://github.com/udondan/duolingo.git
|
|
62
187
|
cd duolingo
|
|
63
188
|
npm install && npm run build
|
|
64
|
-
node dist/
|
|
189
|
+
node dist/cli.js mcp
|
|
65
190
|
```
|
|
66
191
|
|
|
67
192
|
### Claude Desktop
|
|
@@ -73,7 +198,34 @@ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
|
73
198
|
"mcpServers": {
|
|
74
199
|
"duolingo": {
|
|
75
200
|
"command": "npx",
|
|
76
|
-
"args": ["-y", "@udondan/duolingo"],
|
|
201
|
+
"args": ["-y", "@udondan/duolingo", "mcp"],
|
|
202
|
+
"env": {
|
|
203
|
+
"DUOLINGO_USERNAME": "your_username",
|
|
204
|
+
"DUOLINGO_JWT": "your_jwt_token"
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
With Docker instead of `npx`, the entry looks like this. `-e NAME` without a
|
|
212
|
+
value passes the variable from `env` to the container:
|
|
213
|
+
|
|
214
|
+
```json
|
|
215
|
+
{
|
|
216
|
+
"mcpServers": {
|
|
217
|
+
"duolingo": {
|
|
218
|
+
"command": "docker",
|
|
219
|
+
"args": [
|
|
220
|
+
"run",
|
|
221
|
+
"--rm",
|
|
222
|
+
"-i",
|
|
223
|
+
"-e",
|
|
224
|
+
"DUOLINGO_USERNAME",
|
|
225
|
+
"-e",
|
|
226
|
+
"DUOLINGO_JWT",
|
|
227
|
+
"udondan/duolingo"
|
|
228
|
+
],
|
|
77
229
|
"env": {
|
|
78
230
|
"DUOLINGO_USERNAME": "your_username",
|
|
79
231
|
"DUOLINGO_JWT": "your_jwt_token"
|
|
@@ -86,7 +238,7 @@ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
|
86
238
|
### Claude Code
|
|
87
239
|
|
|
88
240
|
```bash
|
|
89
|
-
claude mcp add duolingo -- npx -y @udondan/duolingo
|
|
241
|
+
claude mcp add duolingo -- npx -y @udondan/duolingo mcp
|
|
90
242
|
```
|
|
91
243
|
|
|
92
244
|
Then set the environment variables before starting Claude Code:
|
|
@@ -96,49 +248,95 @@ export DUOLINGO_USERNAME="your_username"
|
|
|
96
248
|
export DUOLINGO_JWT="your_jwt_token"
|
|
97
249
|
```
|
|
98
250
|
|
|
251
|
+
### Docker MCP Toolkit
|
|
252
|
+
|
|
253
|
+
With the [Docker MCP Toolkit](https://docs.docker.com/ai/mcp-catalog-and-toolkit/toolkit/)
|
|
254
|
+
of Docker Desktop, the server runs as a container behind the MCP Gateway. The
|
|
255
|
+
gateway starts the container on demand and passes its tools on to the connected
|
|
256
|
+
clients. The credentials are stored as secrets in Docker Desktop instead of in
|
|
257
|
+
plain text in the client configuration.
|
|
258
|
+
|
|
259
|
+
Requires Docker Desktop with the MCP Toolkit enabled.
|
|
260
|
+
|
|
261
|
+
1. Download the server definition [`docker-mcp.yml`](docker-mcp.yml) and add it
|
|
262
|
+
to a Toolkit profile. The Toolkit only reads such files from its catalogs
|
|
263
|
+
directory:
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
mkdir -p ~/.docker/mcp/catalogs
|
|
267
|
+
curl -fsSL https://raw.githubusercontent.com/udondan/duolingo/main/docker-mcp.yml -o ~/.docker/mcp/catalogs/duolingo.yml
|
|
268
|
+
|
|
269
|
+
# new profile "duolingo" ...
|
|
270
|
+
docker mcp profile create --name duolingo --id duolingo --server "file://$HOME/.docker/mcp/catalogs/duolingo.yml"
|
|
271
|
+
# ... or add it to an existing profile
|
|
272
|
+
docker mcp profile server add default --server "file://$HOME/.docker/mcp/catalogs/duolingo.yml"
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
The profile keeps the image at the version it had when it was added. Run
|
|
276
|
+
`profile server add` again to update.
|
|
277
|
+
|
|
278
|
+
2. Store the credentials as secrets (see [Getting Your JWT Token](#getting-your-jwt-token)):
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
docker mcp secret set duolingo.username=your_username
|
|
282
|
+
docker mcp secret set duolingo.jwt=your_jwt_token
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
3. Connect a client to the profile:
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
docker mcp client connect claude-desktop --profile duolingo
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
`docker mcp client connect --help` lists more clients such as `claude-code`,
|
|
292
|
+
`cursor` or `vscode`. This also works in Docker Desktop under _MCP Toolkit_.
|
|
293
|
+
|
|
294
|
+
`docker mcp gateway run --profile duolingo --dry-run --verbose` checks the setup
|
|
295
|
+
without starting a client. The output should end with `duolingo: (N tools)`.
|
|
296
|
+
|
|
99
297
|
### Available Tools
|
|
100
298
|
|
|
101
299
|
All tools are **read-only** — the server never modifies your Duolingo account.
|
|
102
300
|
|
|
103
301
|
#### Account
|
|
104
302
|
|
|
105
|
-
| Tool
|
|
106
|
-
|
|
107
|
-
| `duolingo_get_user_info`
|
|
108
|
-
| `duolingo_get_settings`
|
|
109
|
-
| `duolingo_get_streak_info`
|
|
110
|
-
| `duolingo_get_daily_xp_progress` | XP goal, XP earned today, lessons completed today
|
|
111
|
-
| `duolingo_get_languages`
|
|
112
|
-
| `duolingo_get_courses`
|
|
113
|
-
| `duolingo_get_friends`
|
|
114
|
-
| `duolingo_get_calendar`
|
|
115
|
-
| `duolingo_get_leaderboard`
|
|
116
|
-
| `duolingo_get_shop_items`
|
|
117
|
-
| `duolingo_get_health`
|
|
118
|
-
| `duolingo_get_currencies`
|
|
119
|
-
| `duolingo_get_streak_goal`
|
|
303
|
+
| Tool | Description |
|
|
304
|
+
| -------------------------------- | ---------------------------------------------------------------------------- |
|
|
305
|
+
| `duolingo_get_user_info` | Profile: username, name, bio, location, avatar, followers, learning language |
|
|
306
|
+
| `duolingo_get_settings` | Notification and account settings |
|
|
307
|
+
| `duolingo_get_streak_info` | Current streak, longest streak, daily goal, extended today |
|
|
308
|
+
| `duolingo_get_daily_xp_progress` | XP goal, XP earned today, lessons completed today |
|
|
309
|
+
| `duolingo_get_languages` | Languages being learned (full names or abbreviations) |
|
|
310
|
+
| `duolingo_get_courses` | All courses including Math, Chess, and Music with XP per course |
|
|
311
|
+
| `duolingo_get_friends` | Users the authenticated user follows, with total XP |
|
|
312
|
+
| `duolingo_get_calendar` | Recent activity calendar for the current course (~last 2 weeks) |
|
|
313
|
+
| `duolingo_get_leaderboard` | Authenticated user's friends sorted by XP for week or month |
|
|
314
|
+
| `duolingo_get_shop_items` | Full shop catalogue with prices and item types |
|
|
315
|
+
| `duolingo_get_health` | Current hearts count, max hearts, refill timing |
|
|
316
|
+
| `duolingo_get_currencies` | Gem and lingot balances |
|
|
317
|
+
| `duolingo_get_streak_goal` | Current streak goal with upcoming checkpoints |
|
|
120
318
|
|
|
121
319
|
#### Language
|
|
122
320
|
|
|
123
|
-
| Tool
|
|
124
|
-
|
|
125
|
-
| `duolingo_get_language_details`
|
|
321
|
+
| Tool | Description |
|
|
322
|
+
| -------------------------------- | --------------------------------------------------------- |
|
|
323
|
+
| `duolingo_get_language_details` | Level, points, streak for a specific language |
|
|
126
324
|
| `duolingo_get_language_progress` | Detailed progress: level %, points to next level, fluency |
|
|
127
|
-
| `duolingo_get_known_topics`
|
|
128
|
-
| `duolingo_get_unknown_topics`
|
|
129
|
-
| `duolingo_get_golden_topics`
|
|
130
|
-
| `duolingo_get_reviewable_topics` | Learned but not fully mastered topics
|
|
131
|
-
| `duolingo_get_known_words`
|
|
132
|
-
| `duolingo_get_learned_skills`
|
|
133
|
-
| `duolingo_get_language_voices`
|
|
134
|
-
| `duolingo_get_audio_url`
|
|
325
|
+
| `duolingo_get_known_topics` | Learned topic/skill names |
|
|
326
|
+
| `duolingo_get_unknown_topics` | Not-yet-learned topics |
|
|
327
|
+
| `duolingo_get_golden_topics` | Fully mastered topics (strength = 1.0) |
|
|
328
|
+
| `duolingo_get_reviewable_topics` | Learned but not fully mastered topics |
|
|
329
|
+
| `duolingo_get_known_words` | Set of known words for a language |
|
|
330
|
+
| `duolingo_get_learned_skills` | Full skill objects sorted by learning order |
|
|
331
|
+
| `duolingo_get_language_voices` | Available TTS voice names for a language |
|
|
332
|
+
| `duolingo_get_audio_url` | Pronunciation audio URL for a word |
|
|
135
333
|
|
|
136
334
|
#### Utilities
|
|
137
335
|
|
|
138
|
-
| Tool
|
|
139
|
-
|
|
336
|
+
| Tool | Description |
|
|
337
|
+
| --------------------------------- | ----------------------------------------------------------------- |
|
|
140
338
|
| `duolingo_get_language_from_abbr` | Convert language abbreviation to full name (e.g. `fr` → `French`) |
|
|
141
|
-
| `duolingo_get_abbreviation_of`
|
|
339
|
+
| `duolingo_get_abbreviation_of` | Convert full language name to abbreviation (e.g. `French` → `fr`) |
|
|
142
340
|
|
|
143
341
|
---
|
|
144
342
|
|
|
@@ -177,7 +375,7 @@ for (const friend of friends) {
|
|
|
177
375
|
|
|
178
376
|
// Get shop items
|
|
179
377
|
const items = await client.getShopItems();
|
|
180
|
-
const streakFreeze = items.find(i => i.id === 'streak_freeze');
|
|
378
|
+
const streakFreeze = items.find((i) => i.id === 'streak_freeze');
|
|
181
379
|
|
|
182
380
|
// Get hearts
|
|
183
381
|
const health = await client.getHealth();
|
|
@@ -216,13 +414,13 @@ const id = await client.getUserIdByUsername('someuser');
|
|
|
216
414
|
const v2 = await client.getUserDataV2(userId);
|
|
217
415
|
|
|
218
416
|
// All courses
|
|
219
|
-
v2.courses;
|
|
417
|
+
v2.courses; // DuolingoCourse[]
|
|
220
418
|
|
|
221
419
|
// Filter by subject
|
|
222
|
-
const langCourses
|
|
223
|
-
const mathCourses
|
|
224
|
-
const chessCourses = v2.courses.filter(c => c.subject === 'chess');
|
|
225
|
-
const musicCourses = v2.courses.filter(c => c.subject === 'music');
|
|
420
|
+
const langCourses = v2.courses.filter((c) => c.subject === 'language');
|
|
421
|
+
const mathCourses = v2.courses.filter((c) => c.subject === 'math');
|
|
422
|
+
const chessCourses = v2.courses.filter((c) => c.subject === 'chess');
|
|
423
|
+
const musicCourses = v2.courses.filter((c) => c.subject === 'music');
|
|
226
424
|
```
|
|
227
425
|
|
|
228
426
|
Each course has: `id`, `subject`, `topic`, `xp`, `fromLanguage`.
|
|
@@ -231,7 +429,11 @@ Language courses also have: `learningLanguage`, `title`, `authorId`.
|
|
|
231
429
|
#### Daily XP Progress
|
|
232
430
|
|
|
233
431
|
```typescript
|
|
234
|
-
const progress = await client.getUserDataById(userId, [
|
|
432
|
+
const progress = await client.getUserDataById(userId, [
|
|
433
|
+
'xpGoal',
|
|
434
|
+
'xpGains',
|
|
435
|
+
'streakData',
|
|
436
|
+
]);
|
|
235
437
|
// progress.xpGoal — daily XP goal
|
|
236
438
|
// progress.xpGains — array of { xp, skillId, time } for recent lessons
|
|
237
439
|
// progress.streakData.updatedTimestamp — last streak update
|
|
@@ -278,7 +480,7 @@ const options = await client.getStreakGoalNextOptions();
|
|
|
278
480
|
|
|
279
481
|
```typescript
|
|
280
482
|
// Discover available voices for a language
|
|
281
|
-
const voices = await client.getLanguageVoices('es');
|
|
483
|
+
const voices = await client.getLanguageVoices('es'); // ['beaes', 'juniores', ...]
|
|
282
484
|
|
|
283
485
|
// Build an audio URL
|
|
284
486
|
const url = await client.buildAudioUrl('hola', 'es');
|
|
@@ -343,31 +545,49 @@ npm run dev
|
|
|
343
545
|
```
|
|
344
546
|
src/
|
|
345
547
|
├── index.ts # Library entry point — exports client, types, errors
|
|
346
|
-
├──
|
|
548
|
+
├── cli.ts # `duolingo` binary
|
|
549
|
+
├── mcp.ts # MCP server (stdio transport), started by `duolingo mcp`
|
|
550
|
+
├── version.ts # Package version
|
|
551
|
+
├── cli/
|
|
552
|
+
│ ├── program.ts # CLI commands (commander)
|
|
553
|
+
│ └── config-file.ts # ~/.config/duolingo/config loader
|
|
347
554
|
├── client/
|
|
348
555
|
│ ├── duolingo.ts # DuolingoClient — all API methods
|
|
349
556
|
│ ├── types.ts # TypeScript interfaces for all API responses
|
|
350
557
|
│ └── errors.ts # Custom error classes
|
|
558
|
+
├── views/
|
|
559
|
+
│ ├── account.ts # Account queries: data + markdown
|
|
560
|
+
│ ├── language.ts # Language queries: data + markdown
|
|
561
|
+
│ ├── utils.ts # Language name/abbreviation lookups
|
|
562
|
+
│ └── view.ts # View type and rendering
|
|
351
563
|
└── tools/
|
|
352
|
-
├── account.ts # Account tools
|
|
353
|
-
├── language.ts # Language tools
|
|
354
|
-
├── shop.ts # Utility tools
|
|
564
|
+
├── account.ts # Account tools
|
|
565
|
+
├── language.ts # Language tools
|
|
566
|
+
├── shop.ts # Utility tools
|
|
355
567
|
└── helpers.ts # Shared utilities (error handling, Zod schemas)
|
|
356
568
|
```
|
|
357
569
|
|
|
358
570
|
### API Versions Used
|
|
359
571
|
|
|
360
|
-
| Endpoint
|
|
361
|
-
|
|
362
|
-
| `/users/<username>`
|
|
363
|
-
| `/2023-05-23/users/{id}`
|
|
364
|
-
| `/2023-05-23/friends/users/{id}/following` | Current
|
|
365
|
-
| `/2023-05-23/shop-items`
|
|
366
|
-
| `/users/{id}/streak-goal-current`
|
|
367
|
-
| `/2017-06-30/sessions`
|
|
572
|
+
| Endpoint | API Version | Used For |
|
|
573
|
+
| ------------------------------------------ | ----------- | --------------------------------------------- |
|
|
574
|
+
| `/users/<username>` | Legacy | User profile, language data, skills, calendar |
|
|
575
|
+
| `/2023-05-23/users/{id}` | Current | Courses (all subjects), streak, health, gems |
|
|
576
|
+
| `/2023-05-23/friends/users/{id}/following` | Current | Friends, leaderboard |
|
|
577
|
+
| `/2023-05-23/shop-items` | Current | Shop catalogue |
|
|
578
|
+
| `/users/{id}/streak-goal-current` | Current | Streak goals |
|
|
579
|
+
| `/2017-06-30/sessions` | Current | TTS voice discovery |
|
|
368
580
|
|
|
369
581
|
---
|
|
370
582
|
|
|
371
583
|
## License
|
|
372
584
|
|
|
373
585
|
MIT — see [LICENSE](LICENSE)
|
|
586
|
+
|
|
587
|
+
## Disclaimer
|
|
588
|
+
|
|
589
|
+
This is an unofficial, independent open-source project and is not affiliated
|
|
590
|
+
with Duolingo, Inc. Duolingo is a trademark of Duolingo, Inc. The name is used
|
|
591
|
+
only to describe compatibility. The API used is not public and may change at any
|
|
592
|
+
time. Use at your own risk and in accordance with the Duolingo Terms and
|
|
593
|
+
Conditions.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config file loader for the Duolingo CLI.
|
|
3
|
+
*
|
|
4
|
+
* Reads ~/.config/duolingo/config (or the path given) and applies any
|
|
5
|
+
* KEY=VALUE entries to process.env, but only when the variable is not
|
|
6
|
+
* already set. Environment variables always take precedence.
|
|
7
|
+
*
|
|
8
|
+
* File format:
|
|
9
|
+
* # comment
|
|
10
|
+
* DUOLINGO_USERNAME=your_username
|
|
11
|
+
* DUOLINGO_JWT=your_jwt
|
|
12
|
+
*
|
|
13
|
+
* The file holds secrets, so it is only read when nobody but its owner can
|
|
14
|
+
* access it (e.g. mode 0600).
|
|
15
|
+
*/
|
|
16
|
+
export declare function defaultConfigFilePath(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Load the config file and apply entries to process.env.
|
|
19
|
+
* Values already present in the environment are not overwritten.
|
|
20
|
+
*/
|
|
21
|
+
export declare function loadConfigFile(path?: string): void;
|
|
22
|
+
//# sourceMappingURL=config-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-file.d.ts","sourceRoot":"","sources":["../../src/cli/config-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAQD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,SAA0B,GAAG,IAAI,CA0CnE"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config file loader for the Duolingo CLI.
|
|
3
|
+
*
|
|
4
|
+
* Reads ~/.config/duolingo/config (or the path given) and applies any
|
|
5
|
+
* KEY=VALUE entries to process.env, but only when the variable is not
|
|
6
|
+
* already set. Environment variables always take precedence.
|
|
7
|
+
*
|
|
8
|
+
* File format:
|
|
9
|
+
* # comment
|
|
10
|
+
* DUOLINGO_USERNAME=your_username
|
|
11
|
+
* DUOLINGO_JWT=your_jwt
|
|
12
|
+
*
|
|
13
|
+
* The file holds secrets, so it is only read when nobody but its owner can
|
|
14
|
+
* access it (e.g. mode 0600).
|
|
15
|
+
*/
|
|
16
|
+
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
17
|
+
import { homedir } from 'node:os';
|
|
18
|
+
import { join } from 'node:path';
|
|
19
|
+
export function defaultConfigFilePath() {
|
|
20
|
+
return join(homedir(), '.config', 'duolingo', 'config');
|
|
21
|
+
}
|
|
22
|
+
function warn(message) {
|
|
23
|
+
process.stderr.write(`[duolingo] Warning: ${message}\n`);
|
|
24
|
+
}
|
|
25
|
+
const UNSAFE_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
|
|
26
|
+
/**
|
|
27
|
+
* Load the config file and apply entries to process.env.
|
|
28
|
+
* Values already present in the environment are not overwritten.
|
|
29
|
+
*/
|
|
30
|
+
export function loadConfigFile(path = defaultConfigFilePath()) {
|
|
31
|
+
if (!existsSync(path))
|
|
32
|
+
return;
|
|
33
|
+
let content;
|
|
34
|
+
try {
|
|
35
|
+
const stat = statSync(path);
|
|
36
|
+
if (!stat.isFile()) {
|
|
37
|
+
warn(`refusing to load config file ${path} because it is not a file.`);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (process.platform !== 'win32' && stat.mode & 0o077) {
|
|
41
|
+
const mode = (stat.mode & 0o777).toString(8);
|
|
42
|
+
warn(`refusing to load config file ${path} because other users can access it (mode ${mode}). Run: chmod 0600 "${path}"`);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
content = readFileSync(path, 'utf8');
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
// fs always throws Error objects
|
|
49
|
+
warn(`unable to read config file ${path}: ${error.message}`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
for (const raw of content.split('\n')) {
|
|
53
|
+
const line = raw.trim();
|
|
54
|
+
if (!line || line.startsWith('#'))
|
|
55
|
+
continue;
|
|
56
|
+
const eq = line.indexOf('=');
|
|
57
|
+
if (eq < 1)
|
|
58
|
+
continue;
|
|
59
|
+
const key = line.slice(0, eq).trim();
|
|
60
|
+
const value = line.slice(eq + 1).trim();
|
|
61
|
+
if (!UNSAFE_KEYS.has(key) &&
|
|
62
|
+
/^[A-Z_][A-Z0-9_]*$/i.test(key) &&
|
|
63
|
+
!Object.hasOwn(process.env, key)) {
|
|
64
|
+
process.env[key] = value;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=config-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-file.js","sourceRoot":"","sources":["../../src/cli/config-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,UAAU,qBAAqB;IACnC,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,IAAI,CAAC,OAAe;IAC3B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,OAAO,IAAI,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC;AAEvE;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,IAAI,GAAG,qBAAqB,EAAE;IAC3D,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO;IAE9B,IAAI,OAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;YACnB,IAAI,CAAC,gCAAgC,IAAI,4BAA4B,CAAC,CAAC;YACvE,OAAO;QACT,CAAC;QACD,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,IAAI,CAAC,IAAI,GAAG,KAAK,EAAE,CAAC;YACtD,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC7C,IAAI,CACF,gCAAgC,IAAI,4CAA4C,IAAI,uBAAuB,IAAI,GAAG,CACnH,CAAC;YACF,OAAO;QACT,CAAC;QACD,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACvC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,iCAAiC;QACjC,IAAI,CAAC,8BAA8B,IAAI,KAAM,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;QACxE,OAAO;IACT,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;QACxB,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,SAAS;QAE5C,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,EAAE,GAAG,CAAC;YAAE,SAAS;QAErB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACrC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAExC,IACE,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC;YACrB,qBAAqB,CAAC,IAAI,CAAC,GAAG,CAAC;YAC/B,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,EAChC,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAC3B,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `duolingo` command line interface.
|
|
3
|
+
*
|
|
4
|
+
* Prints JSON by default (`--format markdown` for readable text) and shares
|
|
5
|
+
* its queries with the MCP tools. `duolingo mcp` starts the MCP server.
|
|
6
|
+
*
|
|
7
|
+
* Credentials come from DUOLINGO_USERNAME and DUOLINGO_JWT, or from the
|
|
8
|
+
* config file ~/.config/duolingo/config (environment variables win).
|
|
9
|
+
*/
|
|
10
|
+
import { Command } from 'commander';
|
|
11
|
+
import { type ResponseFormat, type View } from '../views/view.js';
|
|
12
|
+
export interface CliOptions {
|
|
13
|
+
/** Config file to load; defaults to ~/.config/duolingo/config. */
|
|
14
|
+
configFile?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Render a view for the terminal. JSON always prints the data, markdown the
|
|
18
|
+
* rendered text. A view without data means nothing was found: an error.
|
|
19
|
+
*/
|
|
20
|
+
export declare function formatView(view: View, format: ResponseFormat): string;
|
|
21
|
+
/** Build the CLI. It throws instead of exiting, see `main`. */
|
|
22
|
+
export declare function buildProgram(options?: CliOptions): Command;
|
|
23
|
+
/** Run the CLI with the given arguments. Returns the exit code. */
|
|
24
|
+
export declare function main(argv: string[], options?: CliOptions): Promise<number>;
|
|
25
|
+
//# sourceMappingURL=program.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../src/cli/program.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,OAAO,EAA0B,MAAM,WAAW,CAAC;AAkC5D,OAAO,EAAU,KAAK,cAAc,EAAE,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAG1E,MAAM,WAAW,UAAU;IACzB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAMD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,GAAG,MAAM,CAMrE;AAED,+DAA+D;AAC/D,wBAAgB,YAAY,CAAC,OAAO,GAAE,UAAe,GAAG,OAAO,CA4M9D;AAED,mEAAmE;AACnE,wBAAsB,IAAI,CACxB,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC,MAAM,CAAC,CAUjB"}
|