AnkiWeb CLI — Criar e Adicionar Flashcards via API
htlin222/ankiweb-add-card
Automatiza criação de decks e cards no AnkiWeb sem browser
Ver no GitHubCLI minimalista para criar baralhos e adicionar cards no AnkiWeb através dos endpoints internos de protobuf, sem navegador ou automação. Sem dependências externas, roda em Python 3.10+ puro e também funciona como skill do Claude para integração direta.
Instalação
npx convez-ai htlin222/ankiweb-add-card1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.
Métricas
Casos de uso
- Automatizar criação em massa de flashcards para estudos
- Integrar AnkiWeb em pipelines de conhecimento e aprendizado
- Sincronizar conteúdo externo diretamente em decks estruturados
Veredito

Solução técnica sólida para automatizar AnkiWeb sem dependências externas ou hacks de scraping. Ideal para quem quer programaticamente alimentar sua plataforma de estudos a partir de fontes automatizadas ou fluxos Claude.
README
A tradução para o português deste README ainda está na fila.
ankiweb-cli
A tiny, dependency-free CLI for AnkiWeb that creates decks and adds cards
directly through AnkiWeb's internal protobuf /svc/ endpoints — no browser, no
automation framework, no anti-bot bypass needed.
It logs in once with your credentials, caches both session cookies, and speaks the same wire protocol the AnkiWeb web app uses.
How it works
AnkiWeb splits its API across two domains, each with its own session cookie
(same login, different c claim):
| Operation | Domain | Cookie |
|---|---|---|
| add / list cards & notetypes | ankiuser.net | c:2 |
| create / list / remove decks | ankiweb.net | c:1 |
A single login obtains both:
POST ankiweb.net/svc/account/login{username, password}→ankiweb.netcookie + anankiuser-logintoken.GET ankiuser.net/account/ankiuser-login?t=<token>→ankiuser.netcookie.
Both cookies are cached to a session file in the OS temp dir and reused until
they expire (auto-relogin on 403). Requests and responses are length-delimited
protobuf (Content-Type: application/octet-stream), encoded/decoded by a small
hand-rolled codec in anki.py.
Setup
No dependencies — the CLI is pure Python stdlib, so python3 anki.py … runs
anywhere with Python 3.10+. uv also works
(uv run anki.py …) if you prefer it.
Create skill/anki/.env with your AnkiWeb credentials (the CLI reads the .env
next to anki.py):
ANKI_USERID=you@example.com
ANKI_PASSWORD=your-password
.env, the exported cookie files, and*.harare gitignored — they hold live credentials/sessions. Never commit them.
Usage
# Decks (use :: to nest)
uv run anki.py create_deck "Spanish::Verbs"
uv run anki.py remove-deck "Spanish::Verbs" # also removes its cards
# Cards — positional values map to the notetype's field order
uv run anki.py add_card "hola" "hello" -d "Spanish::Verbs" -n Basic
# Override a field by name, add tags
uv run anki.py add_card "Q" "A" -f "Extra=note here" -t "tag1 tag2"
# Omit -d/-n to use your last-used deck / notetype
uv run anki.py add_card "front" "back"
# Discovery
uv run anki.py list-decks # id<TAB>name
uv run anki.py list-notetypes
# Session
uv run anki.py login # force re-login, refresh cached session
add_card options
| Flag | Meaning |
|---|---|
positional values... | field values in the notetype's field order |
-d, --deck | deck name (resolved to id) or numeric id; default: last used |
-n, --notetype | notetype name or numeric id; default: last used |
-f, --field NAME=VALUE | set a field by name (repeatable; overrides positional) |
-t, --tags | space-separated tags |
Names are resolved against your collection; an unknown name produces a "did you mean …?" suggestion. Numeric arguments are treated as raw ids.
Claude skill
The same CLI ships as a Claude skill (for claude.ai / Claude Code). Build the package with:
make build # -> dist/anki.skill (bundles anki.py + SKILL.md + .env)
make clean # -> remove dist/
Upload dist/anki.skill in claude.ai under Settings → Capabilities → Skills
(the code-execution tool must be enabled). The package bundles .env, so it
contains your live password — keep it private and never share it.
Layout
| Path | Purpose |
|---|---|
skill/anki/anki.py | the CLI — single source of truth (pure stdlib, no deps) |
skill/anki/SKILL.md | skill manifest (how an agent drives the CLI) |
skill/anki/.env | your credentials (gitignored) |
anki.py | symlink → skill/anki/anki.py, for uv run anki.py at the repo root |
Makefile | make build → dist/anki.skill |
dist/ | build output (gitignored) |
The session cache lives in the OS temp dir (gitignored anyway), not the repo.
Disclaimer
This talks to AnkiWeb's private, undocumented endpoints, which may change at any time. Use it only with your own account. Not affiliated with or endorsed by Anki.