Skip to main content

py_ankiconnect

Minimal wrapper to simplify the usage of the awesome ankiconnect anki addon. I made this in about an hour to make it easy to interact with anki from my many python projects (see my other repos), as well as from the command line.

Installation

  • python -m pip install py-ankiconnect or git clone followed by python -m pip install -e .

How To

Using the command line

  • You can either call it using py_ankiconnect or python -m py_ankiconnect.
  • To see the help: py_ankiconnect --help (this will either print it using rich if installed or using the pager.)
  • Examples:
    • Get the list of tags: py_ankiconnect getTags | jq
    • Get info about Clozolkor: py_ankiconnect findModelsByName --modelNames ["Clozolkor"] | jq
    • You can even use pipes: py_ankiconnect findNotes --query '*test*' | jq -c '.[0:10]' | py_ankiconnect notesInfo --notes - (you have to use '-', if will be replaced by the content of sys.stdin)

Using python

from py_ankiconnect import PyAnkiconnect
akc = PyAnkiconnect()
# ^ You can set a different port or host there directly:
# akc = PyAnkiconnect(default_port=your_port)

# trigger a sync:
result = akc("sync")

# Get the list of all tags:
result = akc("getTags")

# Do some more advanced stuff:
akc(
    action="changeDeck",
    params={
        "cards": [
            1502098034045,
            1502098034048,
            1502298033753
            ],
        "deck": "Japanese::JLPT N3"
        },
)

# It supports async mode. By default it will try async or sync depending on who calls it, but you can set force_async_mode to always use async.
import asyncio
akc = PyAnkiconnect(force_async_mode=True, limit_concurrency=50)
async def main():
    return await akc("getTags")
asyncio.run(main())

Release files for py-ankiconnect 1.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-ankiconnect 1.1.4
File Size Uploaded
py_ankiconnect-1.1.4.tar.gz 33.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-ankiconnect 1.1.4
File Interpreter ABI Platform
py_ankiconnect-1.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 67.5 kB

Release files / py_ankiconnect-1.1.4.tar.gz

Download URL py_ankiconnect-1.1.4.tar.gz
Size 33.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1d8d862d83a339ff5e1b13c63292c197eecddcbe9429103b6b8062b046c52d1d
BLAKE2b-256 checksum
How to use checksums
48a696dd87f4466e5f9dfce26a6a6efe5d145a17b661c0152bd87262d2d2d4c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.7

Release files / py_ankiconnect-1.1.4-py3-none-any.whl

Download URL py_ankiconnect-1.1.4-py3-none-any.whl
Size 33.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8438bebae6995a73716fe7c2545896b2a3cdeb484e367ce00871e79d32b4c814
BLAKE2b-256 checksum
How to use checksums
09fe19ec12225183b74dc4d06bebdf4acd2aca1dc04b1fadbe05b2b76c02ce71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.7

Release history Release notifications | RSS feed

This release

1.1.4 This release

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page