convez.ai
SkillIntegração & APIsIntermediário
htlin222

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 GitHub
BomPluginScore · de 0 a 100

CLI 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-card

1 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

Estrelas
8
Forks
1
Acompanhando
0
Saúde
42%
Último commit
há 2 semanas
Versão
—
Issues abertas
0
Contribuidores
1

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

License: MIT Python Run with uv Dependencies Anki

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):

OperationDomainCookie
add / list cards & notetypesankiuser.netc:2
create / list / remove decksankiweb.netc:1

A single login obtains both:

  1. POST ankiweb.net/svc/account/login {username, password} → ankiweb.net cookie + an ankiuser-login token.
  2. GET ankiuser.net/account/ankiuser-login?t=<token> → ankiuser.net cookie.

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 *.har are 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

FlagMeaning
positional values...field values in the notetype's field order
-d, --deckdeck name (resolved to id) or numeric id; default: last used
-n, --notetypenotetype name or numeric id; default: last used
-f, --field NAME=VALUEset a field by name (repeatable; overrides positional)
-t, --tagsspace-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

PathPurpose
skill/anki/anki.pythe CLI — single source of truth (pure stdlib, no deps)
skill/anki/SKILL.mdskill manifest (how an agent drives the CLI)
skill/anki/.envyour credentials (gitignored)
anki.pysymlink → skill/anki/anki.py, for uv run anki.py at the repo root
Makefilemake 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.

Ver o original no GitHub

Bom para

Relacionados