### Start Deck Review with guiDeckReview Source: https://github.com/amikey/anki-connect/blob/master/README.md Starts a review session for a specified deck. Returns true if successful, false otherwise. ```json { "action": "guiDeckReview", "version": 5, "params": { "name": "Default" } } ``` ```json { "result": true, "error": null } ``` -------------------------------- ### MultiAction Example Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/types.md An example of a multi-action request object, specifying the 'findNotes' action with a query parameter. ```json { "action": "findNotes", "params": {"query": "deck:current"} } ``` -------------------------------- ### NoteParams Example Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/types.md An example of a fully populated NoteParams object for creating a note with fields, tags, and audio. ```json { "deckName": "My Deck", "modelName": "Basic", "fields": { "Front": "What is 2+2?", "Back": "4" }, "tags": ["math", "arithmetic"], "audio": { "url": "https://example.com/sound.mp3", "filename": "audio.mp3", "skipHash": "d41d8cd98f00b204e9800998ecf8427e", "fields": ["Front"] } } ``` -------------------------------- ### Start Deck Review Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/endpoints.md Initiates a review session for a specific deck. Returns true if the deck exists and review starts, false otherwise. ```json POST / { "action": "guiDeckReview", "version": 5, "params": {"name": "Default"} } ``` -------------------------------- ### CurrentCardInfo Example Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/types.md An example of the CurrentCardInfo JSON object, showing card details and available buttons. ```json { "cardId": 1498938915662, "fields": { "Front": {"value": "What is 2+2?", "order": 0}, "Back": {"value": "4", "order": 1} }, "fieldOrder": 0, "question": "
What is 2+2?
", "answer": "
4
", "modelName": "Basic", "deckName": "Default", "css": "p {font-family:Arial;}", "buttons": [1, 2, 3, 4] } ``` -------------------------------- ### FieldInfo Example Usage Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/types.md An example of a FieldInfo object, demonstrating the expected format for field content and its order. ```json { "value": "What is 2+2?", "order": 0 } ``` -------------------------------- ### AudioParams Example Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/types.md An example demonstrating how to configure AudioParams for downloading and embedding an audio file. Ensure the filename does not contain path separators and the skipHash is a valid MD5 hex string if provided. ```json { "url": "https://assets.languagepod101.com/dictionary/japanese/audio.mp3", "filename": "yomichan_ねこ.mp3", "skipHash": "7e2c2f954ef6051373ba916f000168dc", "fields": ["Front"] } ``` -------------------------------- ### API Request Example Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/types.md An example of a complete API request to add a note, specifying the action, API version, and note parameters. ```json { "action": "addNote", "version": 5, "params": { "note": { "deckName": "Default", "modelName": "Basic", "fields": { "Front": "front", "Back": "back" } } } } ``` -------------------------------- ### Anki-Connect Request Format Example Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/overview.md All requests to Anki-Connect are made via HTTP POST with a JSON body. This example shows a request to get deck names. ```json { "action": "deckNames", "version": 5, "params": {} } ``` -------------------------------- ### guiDeckReview Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/endpoints.md Starts review for a specific deck. Returns true on success, false if the deck doesn't exist. ```APIDOC ## POST / ### Description Starts review for a specific deck. ### Method POST ### Endpoint / ### Parameters #### Request Body - **action** (string) - Required - "guiDeckReview" - **version** (number) - Required - 5 - **params** (object) - Required - **name** (string) - Required - Deck name ### Request Example ```json { "action": "guiDeckReview", "version": 5, "params": {"name": "Default"} } ``` ### Response #### Success Response (200) - **result** (boolean) - True on success, false if deck doesn't exist. #### Response Example ```json true ``` ``` -------------------------------- ### NoteInfo Example Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/types.md An example JSON object representing a note's information, including its fields and tags. ```json { "noteId": 1502298033753, "modelName": "Basic", "tags": ["tag", "another_tag"], "fields": { "Front": {"value": "front content", "order": 0}, "Back": {"value": "back content", "order": 1} }, "cards": [1498938915662, 1502098034048] } ``` -------------------------------- ### Example DeckConfig JSON Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/types.md A complete JSON example of a DeckConfig object, demonstrating the structure and typical values for all parameters, including nested configurations. ```json { "id": 1, "name": "Default", "mod": 1502970872, "usn": -1, "maxTaken": 60, "autoplay": true, "replayq": true, "timer": 0, "dyn": false, "new": { "delays": [1, 10], "ints": [1, 4, 7], "initialFactor": 2500, "bury": true, "perDay": 20, "order": 1, "separate": true }, "rev": { "delays": [], "perDay": 100, "ease4": 1.3, "fuzz": 0.05, "minSpace": 1, "maxIvl": 36500, "ivlFct": 1, "bury": true }, "lapse": { "delays": [10], "leechFails": 8, "leechAction": 0, "minInt": 1, "mult": 0 } } ``` -------------------------------- ### AnkiConnect API: Start Deck Review Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Initiates a review session for a specified deck. Provide the deck name to start reviewing its cards. ```python guiDeckReview(name) ``` -------------------------------- ### Start Card Timer with guiStartCardTimer Source: https://github.com/amikey/anki-connect/blob/master/README.md Starts or resets the timer for the current card. Useful for accurate timing when calling guiAnswerCard. ```json { "action": "guiStartCardTimer", "version": 5 } ``` ```json { "result": true, "error": null } ``` -------------------------------- ### Anki-Connect Communication Example Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/README.md Demonstrates the HTTP POST request format for interacting with Anki-Connect and the expected JSON response. ```json HTTP POST http://127.0.0.1:8765/ Content-Type: application/json { "action": "deckNames", "version": 5 } ↓ HTTP 200 OK Content-Type: text/json { "result": ["Default", "Japanese"], "error": null } ``` -------------------------------- ### Start Deck Review Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Initiates a review session for a specific deck. Returns true on success, or false if the specified deck does not exist. ```python def guiDeckReview(self, name: str) -> bool ``` -------------------------------- ### Standard API Success Response Example Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/types.md An example of a successful API response, showing a list of results and a null error field. ```json { "result": ["Default", "Filtered Deck 1"], "error": null } ``` -------------------------------- ### Example: Create Note with Audio Data Flow Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/overview.md Details the data flow for adding a note with audio. This involves downloading audio, validating note parameters, adding the note to the collection, and saving changes. ```text HTTP POST / {"action": "addNote", "version": 5, "params": {"note": {..., "audio": {...}}}} ↓ AnkiConnect.addNote() ↓ AnkiNoteParams validation ↓ AnkiBridge.addNote() ↓ 1. download(audio.url) [10s timeout] ↓ 2. collection.addNote(note) ↓ 3. media.writeData(filename, audio_data) ↓ 4. collection.autosave() ↓ {result": 1234567890, "error": null} ``` -------------------------------- ### Make First API Call to AnkiConnect Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/overview.md Demonstrates how to make a POST request to the AnkiConnect API to get the version. ```bash curl -X POST http://127.0.0.1:8765 \ -d '{"action": "version", "version": 5}' # Response: {"result": 5, "error": null} ``` -------------------------------- ### AjaxServer Listen Method Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Starts the HTTP server, configuring the socket for reuse, binding to the network address and port, and setting it to non-blocking mode. ```python def listen(self) -> None ``` -------------------------------- ### Perform Batch Operations Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/README.md This example demonstrates how to execute multiple Anki Connect actions in a single request for efficiency. It retrieves deck names, model names, and the Anki Connect version. ```bash curl -X POST http://127.0.0.1:8765 \ -d '{ "action": "multi", "version": 5, "params": { "actions": [ {"action": "deckNames"}, {"action": "modelNames"}, {"action": "version"} ] } }' ``` -------------------------------- ### Create a New Note Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/README.md This example shows how to add a new note to a specified deck with given fields and tags. Ensure the 'modelName' exists in your Anki collection. ```bash curl -X POST http://127.0.0.1:8765 \ -d '{ "action": "addNote", "version": 5, "params": { "note": { "deckName": "Default", "modelName": "Basic", "fields": { "Front": "What is 2+2?", "Back": "4" }, "tags": ["math"] } } }' ``` -------------------------------- ### Example CardInfo JSON Object Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/types.md A complete JSON example of the CardInfo object, demonstrating the expected data for a typical Anki card. This is useful for understanding the actual data structure returned by AnkiConnect. ```json { "cardId": 1498938915662, "fields": { "Front": {"value": "What is 2+2?", "order": 0}, "Back": {"value": "4", "order": 1} }, "fieldOrder": 0, "question": "
What is 2+2?
", "answer": "
4
", "modelName": "Basic", "deckName": "Default", "css": "p {font-family:Arial;}", "factor": 2500, "interval": 16, "note": 1502298033753 } ``` -------------------------------- ### AnkiConnect API: Get Deck Configuration Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Retrieves the configuration settings for a specific deck. Provide the deck name to get its current configuration. ```python getDeckConfig(deck) ``` -------------------------------- ### Communication Model Example Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/README.md Demonstrates the basic communication model for Anki Connect API requests and responses using HTTP POST. ```APIDOC ## Communication Model Anki Connect uses an HTTP POST request to a local server endpoint. Requests are JSON objects containing an `action` and `version`, and responses are also JSON objects containing a `result` and an `error` field. ### Request Example ```http POST http://127.0.0.1:8765/ HTTP/1.1 Content-Type: application/json { "action": "deckNames", "version": 5 } ``` ### Response Example ```http HTTP/1.1 200 OK Content-Type: text/json { "result": ["Default", "Japanese"], "error": null } ``` ``` -------------------------------- ### Error Handling Example Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/README.md Illustrates the standard error response format for Anki Connect API. ```APIDOC ## Error Handling Errors are returned in a standard JSON format. For API versions 4 and below, only the `result` field is returned, which will be null in case of an error. ### Error Response Example ```json { "result": null, "error": "Error message describing what went wrong" } ``` ``` -------------------------------- ### Get Deck Configuration Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/endpoints.md Retrieve the configuration settings for a specific deck. Requires the deck name as a parameter. ```json { "action": "getDeckConfig", "version": 5, "params": {"deck": "Default"} } ``` -------------------------------- ### deckNames Source: https://github.com/amikey/anki-connect/blob/master/README.md Gets the complete list of deck names for the current user. ```APIDOC ## deckNames ### Description Gets the complete list of deck names for the current user. ### Method POST ### Endpoint / ### Parameters #### Request Body - **action** (string) - Required - The name of the action to perform, in this case, "deckNames". - **version** (integer) - Required - The API version to use. ### Request Example ```json { "action": "deckNames", "version": 5 } ``` ### Response #### Success Response (200) - **result** (array) - An array of strings, where each string is a deck name. - **error** (null) - Indicates if an error occurred. #### Response Example ```json { "result": ["Default"], "error": null } ``` ``` -------------------------------- ### Search for Cards Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/README.md Use this snippet to find cards based on a specific query. The example searches for cards in the current deck that are due for review. ```bash curl -X POST http://127.0.0.1:8765 \ -d '{ "action": "findCards", "version": 5, "params": { "query": "deck:current is:due" } }' ``` -------------------------------- ### Example: Query Deck Names Data Flow Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/overview.md Illustrates the data flow for a POST request to query deck names. The request is processed through various Anki Connect and Anki internal methods, resulting in a list of deck names. ```text HTTP POST / {"action": "deckNames", "version": 5} ↓ AjaxServer.handlerWrapper() ↓ AnkiConnect.handler() ↓ AnkiConnect.deckNames() ↓ AnkiBridge.deckNames() ↓ collection.decks.allNames() ↓ ["Default", "Japanese"] ↓ {"result": ["Default", "Japanese"], "error": null} ``` -------------------------------- ### Get Anki Media Manager Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Retrieves the media collection manager object. Returns None if unavailable. ```python def media(self) -> anki.Media | None: # Returns the media collection manager. ``` -------------------------------- ### AjaxServer Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md An HTTP server for handling JSON requests. It provides methods to start listening, process connections, manage client I/O, set and get headers, and wrap request handlers. ```APIDOC ## Class AjaxServer ### Description HTTP server for handling JSON requests. ### Constructor ```python def __init__(self, handler: callable) ``` **Parameters:** - **handler** (callable) - Request handler function ### Methods #### listen ```python def listen(self) -> None ``` Starts listening on the configured address and port. #### advance ```python def advance(self) -> None ``` Processes new connections and advances existing clients. #### acceptClients ```python def acceptClients(self) -> None ``` Accepts new client connections from the listening socket. #### advanceClients ```python def advanceClients(self) -> None ``` Processes I/O on all connected clients, filtering out closed connections. #### setHeader ```python def setHeader(self, name: str, value: str) -> None ``` Sets a custom HTTP response header. #### resetHeaders ```python def resetHeaders(self) -> None ``` Resets headers to defaults (200 OK, CORS allowed). #### getHeaders ```python def getHeaders(self) -> list[list[str]] ``` Returns all headers as array of [name, value] pairs. #### handlerWrapper ```python def handlerWrapper(self, req: AjaxRequest) -> bytes ``` Wraps request handler output in HTTP headers and response format. **Parameters:** - **req** (AjaxRequest) - Incoming request object **Returns:** Bytes containing complete HTTP response. #### close ```python def close(self) -> None ``` Closes the listening socket and all client connections. ``` -------------------------------- ### Open Deck Overview with guiDeckOverview Source: https://github.com/amikey/anki-connect/blob/master/README.md Opens the Deck Overview dialog for a specified deck. Returns true if successful, false otherwise. ```json { "action": "guiDeckOverview", "version": 5, "params": { "name": "Default" } } ``` ```json { "result": true, "error": null } ``` -------------------------------- ### guiDeckOverview Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Opens the Deck Overview screen for a specified deck. ```APIDOC ## guiDeckOverview ### Description Opens the Deck Overview for a specific deck. ### Method Not applicable (Python method) ### Endpoint Not applicable (Python method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **name** (str) - Required - The name of the deck to open. ### Request Example ```python anki_connect.guiDeckOverview(name="MyDeck") ``` ### Response #### Success Response - **opened** (bool) - True if the deck overview was opened successfully, False if the deck does not exist. #### Response Example ```json true ``` ``` -------------------------------- ### Example: Failed to Get Note Error Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/errors.md This error occurs when trying to update a note that does not exist in the collection, identified by its note ID. Ensure the note ID is valid and the note has not been deleted. ```json { "result": null, "error": "Failed to get note:1234567890" } ``` -------------------------------- ### guiDeckOverview Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/endpoints.md Opens the Deck Overview for a specific deck. Returns true on success, false if the deck doesn't exist. ```APIDOC ## POST / ### Description Opens the Deck Overview for a specific deck. ### Method POST ### Endpoint / ### Parameters #### Request Body - **action** (string) - Required - "guiDeckOverview" - **version** (number) - Required - 5 - **params** (object) - Required - **name** (string) - Required - Deck name ### Request Example ```json { "action": "guiDeckOverview", "version": 5, "params": {"name": "Default"} } ``` ### Response #### Success Response (200) - **result** (boolean) - True on success, false if deck doesn't exist. #### Response Example ```json true ``` ``` -------------------------------- ### guiDeckReview Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Initiates a review session for a specified deck. ```APIDOC ## guiDeckReview ### Description Starts review for a specific deck. ### Method Not applicable (Python method) ### Endpoint Not applicable (Python method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **name** (str) - Required - The name of the deck to review. ### Request Example ```python anki_connect.guiDeckReview(name="MyDeck") ``` ### Response #### Success Response - **started** (bool) - True if the review session started successfully, False if the deck does not exist. #### Response Example ```json true ``` ``` -------------------------------- ### Get Deck Names Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/README.md Use this snippet to retrieve a list of all available deck names in Anki. This is useful for populating dropdowns or verifying deck existence. ```bash curl -X POST http://127.0.0.1:8765 \ -d '{"action": "deckNames", "version": 5}' ``` -------------------------------- ### Batch Operations Request Example Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/INDEX.md This JSON payload illustrates how to perform multiple Anki actions in a single request using the multi action. This is useful for optimizing multiple API calls. ```json POST http://127.0.0.1:8765 { "action": "multi", "version": 5, "params": { "actions": [ {"action": "deckNames"}, {"action": "modelNames"}, {"action": "version"} ] } } ``` -------------------------------- ### Open Deck Browser with guiDeckBrowser Source: https://github.com/amikey/anki-connect/blob/master/README.md Opens the Deck Browser dialog. This action does not require any parameters. ```json { "action": "guiDeckBrowser", "version": 5 } ``` ```json { "result": null, "error": null } ``` -------------------------------- ### Invoke AnkiConnect API with curl Source: https://github.com/amikey/anki-connect/blob/master/README.md This command-line example shows how to send a POST request to AnkiConnect using curl to retrieve deck names. It specifies the target URL, HTTP method, and a JSON payload for the action and version. ```bash curl localhost:8765 -X POST -d "{\"action\": \"deckNames\", \"version\": 5}" ``` -------------------------------- ### version Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/endpoints.md Gets the current API version supported by the AnkiConnect server. This is a simple GET request to check the server's compatibility. ```APIDOC ## version ### Description Gets the current API version supported by the server. ### Method POST ### Endpoint / ### Request Body - **action** (string) - Required - The API action to invoke - **version** (number) - Required - API version (defaults to 4 if omitted; use 5 for current) ### Request Example { "action": "version", "version": 5 } ### Response #### Success Response (200) - **result** (integer) - The latest supported API version. #### Response Example { "result": 5, "error": null } ``` -------------------------------- ### Find Cards by Query Source: https://github.com/amikey/anki-connect/blob/master/README.md Use the `findCards` action to get an array of card IDs matching a specific query. This is a performance-optimized alternative to `guiBrowse` as it does not use the GUI. ```json { "action": "findCards", "version": 5, "params": { "query": "deck:current" } } ``` ```json { "result": [1494723142483, 1494703460437, 1494703479525], "error": null } ``` -------------------------------- ### AnkiConnect Failed Response Examples Source: https://github.com/amikey/anki-connect/blob/master/README.md Examples of failed responses from AnkiConnect, where the 'result' is null and the 'error' field contains a string describing the issue. ```json {"result": null, "error": "unsupported action"} ``` ```json {"result": null, "error": "guiBrowse() got an unexpected keyword argument 'foobar'"} ``` -------------------------------- ### Get Anki-Connect API Version Source: https://github.com/amikey/anki-connect/blob/master/README.md Call this first to ensure communication. It retrieves the API version, supporting versions 1 through 5. New versions are backwards compatible. ```json { "action": "version", "version": 5 } ``` -------------------------------- ### Add Note Request Example Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/INDEX.md This JSON payload demonstrates how to add a new note to Anki using the addNote action. Ensure the 'action', 'version', and 'params' fields are correctly structured. ```json POST http://127.0.0.1:8765 { "action": "addNote", "version": 5, "params": { "note": { "deckName": "Default", "modelName": "Basic", "fields": { "Front": "What is 2+2?", "Back": "4" }, "tags": ["math"] } } } ``` -------------------------------- ### guiDeckBrowser Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/endpoints.md Opens the Deck Browser. ```APIDOC ## POST / ### Description Opens the Deck Browser. ### Method POST ### Endpoint / ### Parameters #### Request Body - **action** (string) - Required - "guiDeckBrowser" - **version** (number) - Required - 5 ### Request Example ```json {"action": "guiDeckBrowser", "version": 5} ``` ### Response #### Success Response (200) - **result** (null) - Null. #### Response Example ```json null ``` ``` -------------------------------- ### AnkiConnect API: Get Card Review Intervals Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Retrieves the review intervals for specified cards. The 'complete' parameter can be set to True to get complete interval information. ```python getIntervals(cards, complete=False) ``` -------------------------------- ### Content of _hello.txt Source: https://github.com/amikey/anki-connect/blob/master/README.md This is the content of the _hello.txt file stored using the storeMediaFile action. ```text Hello world! ``` -------------------------------- ### Batch Import Notes with Media (Bash) Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/README.md This bash script demonstrates how to perform a batch import of notes, potentially including media files, by iterating through a word list and sending POST requests. ```bash for word in $(cat words.txt); do curl -X POST http://127.0.0.1:8765 \ -d "{\"action\": \"addNote\", \"version\": 5, \"params\": {...}}" done ``` -------------------------------- ### Get Card Intervals Source: https://github.com/amikey/anki-connect/blob/master/README.md Retrieve the most recent intervals for given card IDs using the `getIntervals` action. Negative intervals are in seconds, and positive intervals are in days. Set `complete` to `true` to get all intervals. ```json { "action": "getIntervals", "version": 5, "params": { "cards": [1502298033753, 1502298036657] } } ``` ```json { "result": [-14400, 3], "error": null } ``` ```json { "action": "getIntervals", "version": 5, "params": { "cards": [1502298033753, 1502298036657], "complete": true } } ``` ```json { "result": [ [-120, -180, -240, -300, -360, -14400], [-120, -180, -240, -300, -360, -14400, 1, 3] ], "error": null } ``` -------------------------------- ### modelNames Source: https://github.com/amikey/anki-connect/blob/master/README.md Gets the complete list of model names for the current user. ```APIDOC ## modelNames ### Description Gets the complete list of model names for the current user. ### Method POST ### Endpoint / ### Parameters #### Request Body - **action** (string) - Required - The action to perform, which is "modelNames". - **version** (integer) - Required - The API version, which is 5. ### Request Example ```json { "action": "modelNames", "version": 5 } ``` ### Response #### Success Response (200) - **result** (array) - A list of model names. - **error** (null) - Indicates no error occurred. #### Response Example ```json { "result": ["Basic", "Basic (and reversed card)"], "error": null } ``` ``` -------------------------------- ### Get All Tags Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Retrieves a list of all tags present in the Anki collection. ```python def getTags(self) -> list[str]: # Returns all tags in the collection. pass ``` -------------------------------- ### modelFieldNames Source: https://github.com/amikey/anki-connect/blob/master/README.md Gets the complete list of field names for the provided model name. ```APIDOC ## modelFieldNames ### Description Gets the complete list of field names for the provided model name. ### Method POST ### Endpoint / ### Parameters #### Request Body - **action** (string) - Required - The action to perform, which is "modelFieldNames". - **version** (integer) - Required - The API version, which is 5. - **params** (object) - Required - Parameters for the action. - **modelName** (string) - Required - The name of the model. ### Request Example ```json { "action": "modelFieldNames", "version": 5, "params": { "modelName": "Basic" } } ``` ### Response #### Success Response (200) - **result** (array) - A list of field names for the model. - **error** (null) - Indicates no error occurred. #### Response Example ```json { "result": ["Front", "Back"], "error": null } ``` ``` -------------------------------- ### Show Question with guiShowQuestion Source: https://github.com/amikey/anki-connect/blob/master/README.md Displays the question text for the current card. Returns true if in review mode, false otherwise. ```json { "action": "guiShowQuestion", "version": 5 } ``` ```json { "result": true, "error": null } ``` -------------------------------- ### Get Model Field Names Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Retrieves the names of all fields for a specified model. ```python def modelFieldNames(self, modelName: str) -> list[str] | None: # Returns field names for a model. pass ``` -------------------------------- ### Open Deck Overview Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Opens the Deck Overview screen for a specified deck. Returns true if the deck exists and the overview is opened successfully, otherwise false. ```python def guiDeckOverview(self, name: str) -> bool ``` -------------------------------- ### Get Deck Names Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/README.md Retrieves a list of all available deck names in Anki. ```APIDOC ## Get Deck Names ### Description Retrieves a list of all available deck names in Anki. ### Method POST ### Endpoint http://127.0.0.1:8765 ### Request Body - **action** (string) - Required - The action to perform, 'deckNames'. - **version** (integer) - Required - The API version, 5. ### Request Example ```json { "action": "deckNames", "version": 5 } ``` ### Response #### Success Response (200) - **result** (array of strings) - A list of deck names. - **error** (null) - Indicates no error occurred. #### Response Example ```json { "result": ["Default", "Japanese::JLPT N3"], "error": null } ``` ``` -------------------------------- ### Retrieve Deck Configuration Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Fetches the configuration settings for a specified deck. Returns False if the deck does not exist. ```python def getDeckConfig(self, deck: str) -> dict | False ``` -------------------------------- ### Get Anki Scheduler Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Retrieves the scheduler object responsible for managing card reviews. ```python def scheduler(self) -> anki.sched.Scheduler: # Returns the scheduler. ``` -------------------------------- ### Get Anki Main Window Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Retrieves the main Anki application window object. ```python def window(self) -> aqt.AnkiQt: # Returns the main Anki window. ``` -------------------------------- ### AnkiConnect File Structure Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/overview.md Illustrates the directory and file layout of the AnkiConnect project. ```bash anki-connect/ ├── AnkiConnect.py # Main plugin file ├── README.md # User documentation ├── build_zip.sh # Build script ├── tests/ # Test suite │ ├── test_decks.py │ ├── test_misc.py │ └── util.py └── ... ``` -------------------------------- ### Get Model Name from ID Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Looks up the model name associated with a given model ID. ```python def modelNameFromId(self, modelId: int) -> str | None: # Looks up model name by ID. pass ``` -------------------------------- ### Open Deck Overview Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/endpoints.md Opens the Deck Overview for a specified deck. Returns true if the deck exists and the overview is opened, false otherwise. ```json POST / { "action": "guiDeckOverview", "version": 5, "params": {"name": "Default"} } ``` -------------------------------- ### Get Model Names and IDs Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Returns a mapping of model names to their corresponding numeric IDs. ```python def modelNamesAndIds(self) -> dict[str, int]: # Returns mapping of model names to numeric IDs. pass ``` -------------------------------- ### Signal Start of Editing Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Initiates the editing state, preventing background operations from interfering with user edits. ```python def startEditing(self) -> None: # Signals that editing is beginning; prevents background operations. ``` -------------------------------- ### AnkiConnect API: Open Deck Overview Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Opens the overview screen for a specific deck. Provide the deck name to navigate to its overview. ```python guiDeckOverview(name) ``` -------------------------------- ### multi Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Executes a list of actions sequentially, allowing for batch operations. ```APIDOC ## multi ### Description Executes multiple actions in sequence. ### Method Not applicable (Python method) ### Endpoint Not applicable (Python method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **actions** (list[dict]) - Required - A list of action objects. Each object should have an `action` field (string) and can optionally include a `params` field (list or dict). ### Request Example ```python anki_connect.multi([ {"action": "guiShowAnswer"}, {"action": "guiAnswerCard", "params": {"ease": 3}} ]) ``` ### Response #### Success Response - **results** (list) - An array containing the results of each action, in the same order as the input `actions` list. #### Response Example ```json [true, true] ``` ``` -------------------------------- ### version Source: https://github.com/amikey/anki-connect/blob/master/README.md Gets the version of the API exposed by this plugin. This should be the first call to ensure communication between your application and AnkiConnect. ```APIDOC ## version ### Description Gets the version of the API exposed by this plugin. Currently versions `1` through `5` are defined. This should be the first call you make to make sure that your application and AnkiConnect are able to communicate properly with each other. New versions of AnkiConnect are backwards compatible; as long as you are using actions which are available in the reported AnkiConnect version or earlier, everything should work fine. ### Method POST ### Endpoint / ### Parameters #### Request Body - **action** (string) - Required - The name of the action to perform, in this case, "version". - **version** (integer) - Required - The API version to use. ### Request Example ```json { "action": "version", "version": 5 } ``` ### Response #### Success Response (200) - **result** (integer) - The current AnkiConnect API version. - **error** (null) - Indicates if an error occurred. #### Response Example ```json { "result": 5, "error": null } ``` ``` -------------------------------- ### Get All Model Names Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Retrieves a list of all available model (note type) names in the Anki collection. ```python def modelNames(self) -> list[str] | None: # Returns all model (note type) names. pass ``` -------------------------------- ### Get Anki Collection Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Retrieves the current Anki collection object. Returns None if the collection is not available. ```python def collection(self) -> anki.Collection | None: # Returns the current collection or None if unavailable. ``` -------------------------------- ### AnkiConnect API: Apply Configuration to Decks Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Applies a specific deck configuration to one or more decks. Provide the list of decks and the configuration ID. ```python setDeckConfigId(decks, configId) ``` -------------------------------- ### Deck Configuration Methods Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Methods for managing deck configurations, including retrieving, saving, applying, cloning, and deleting configuration settings. ```APIDOC ## Deck Configuration Methods ### Description Methods for managing deck configurations. ### Methods - `getDeckConfig(deck)` — retrieves deck configuration - `saveDeckConfig(config)` — saves modified config - `setDeckConfigId(decks, configId)` — applies config to decks - `cloneDeckConfigId(name, cloneFrom)` — clones configuration - `removeDeckConfigId(configId)` — deletes configuration ``` -------------------------------- ### guiCurrentCard Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/endpoints.md Gets information about the currently displayed card during review. Returns card info or null if not in review. ```APIDOC ## POST / ### Description Gets information about the currently displayed card during review. ### Method POST ### Endpoint / ### Parameters #### Request Body - **action** (string) - Required - "guiCurrentCard" - **version** (number) - Required - 5 ### Request Example ```json {"action": "guiCurrentCard", "version": 5} ``` ### Response #### Success Response (200) - **result** (object) - Card info object with an additional `buttons` field, or null if not in review. - **buttons** (array) - Array of button ease values available for this card #### Response Example ```json { "question": "Front of card", "answer": "Back of card", "tags": ["tag1", "tag2"], "buttons": [1, 2, 3, 4] } ``` ``` -------------------------------- ### Get All Tags Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/endpoints.md Retrieve a list of all tags currently used in your Anki collection. This endpoint requires no parameters. ```json POST / {"action": "getTags", "version": 5} ``` -------------------------------- ### Open Deck Browser Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/endpoints.md Opens the main Deck Browser in Anki. This action requires no parameters. ```json POST / {"action": "guiDeckBrowser", "version": 5} ``` -------------------------------- ### startEditing Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Signals the beginning of an editing session, preventing background operations. ```APIDOC ## startEditing ### Description Signals that editing is beginning; prevents background operations. ### Method `startEditing(self)` ### Return Type `None` ``` -------------------------------- ### guiAddCards Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/endpoints.md Opens the Add Cards dialog. ```APIDOC ## POST / ### Description Opens the Add Cards dialog. ### Method POST ### Endpoint / ### Parameters #### Request Body - **action** (string) - Required - "guiAddCards" - **version** (number) - Required - 5 ### Request Example ```json {"action": "guiAddCards", "version": 5} ``` ### Response #### Success Response (200) - **result** (null) - Null. #### Response Example ```json null ``` ``` -------------------------------- ### AnkiConnect API: Get Current Card Info Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Retrieves information about the currently displayed card during a review session. ```python guiCurrentCard() ``` -------------------------------- ### NewConfig Structure Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/types.md Defines parameters for scheduling new cards. Use this to set intervals, initial ease, and daily limits for new cards. ```python { "delays": list[int], # Intervals between repetitions (minutes) "ints": list[int], # Delays to graduating intervals (days) "initialFactor": int, # Starting ease (e.g., 2500 = 250%) "bury": bool, # Bury related cards "perDay": int, # Max new cards per day "order": int, # Display order "separate": bool, # Separate by model } ``` -------------------------------- ### Start Current Card Timer Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/endpoints.md Resets the timer for the current card. Returns true if successful, false if not currently in a review. ```json POST / {"action": "guiStartCardTimer", "version": 5} ``` -------------------------------- ### window Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Provides access to the main Anki window. ```APIDOC ## window ### Description Returns the main Anki window. ### Method `window(self)` ### Return Type `aqt.AnkiQt` ``` -------------------------------- ### Retrieve Media File from Anki Source: https://github.com/amikey/anki-connect/blob/master/README.md Use retrieveMediaFile to get the base64-encoded content of a file. Returns false if the file does not exist. ```json { "action": "retrieveMediaFile", "version": 5, "params": { "filename": "_hello.txt" } } ``` -------------------------------- ### Open Add Cards Dialog with guiAddCards Source: https://github.com/amikey/anki-connect/blob/master/README.md Invokes the Add Cards dialog. This action does not require any parameters. ```json { "action": "guiAddCards", "version": 5 } ``` ```json { "result": null, "error": null } ``` -------------------------------- ### Get Model Names Source: https://github.com/amikey/anki-connect/blob/master/README.md Retrieves a list of all available model names for the current user. Use this to identify models for other operations. ```json { "action": "modelNames", "version": 5 } ``` -------------------------------- ### cloneDeckConfigId Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/endpoints.md Creates a new deck configuration by cloning an existing one. ```APIDOC ## cloneDeckConfigId ### Description Creates a new deck configuration by cloning an existing one. ### Method POST ### Endpoint / ### Parameters #### Request Body ```json { "action": "cloneDeckConfigId", "version": 5, "params": { "name": "Copy of Default", "cloneFrom": 1 } } ``` #### Request Body Parameters - **name** (string) - Required - The name for the new deck configuration. - **cloneFrom** (number) - Optional - The ID of the configuration to clone from. Defaults to 1. ### Response #### Success Response (200) - **response** (number or boolean) - The numeric ID of the newly created configuration, or false if the source configuration does not exist. ``` -------------------------------- ### Get All Deck Names Source: https://github.com/amikey/anki-connect/blob/master/README.md Retrieves a list of all available deck names for the current user. This is a fundamental call for deck-related operations. ```json { "action": "deckNames", "version": 5 } ``` -------------------------------- ### AnkiNoteParams Constructor Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Initializes AnkiNoteParams with raw parameters. Validates audio parameters for URL, filename, fields, and skipHash. ```python def __init__(self, params: dict) ``` -------------------------------- ### Get Fields on Templates Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Returns the fields used on each side of each template for a given model. Useful for understanding template structure. ```python def modelFieldsOnTemplates(self, modelName: str) -> dict[str, list[list[str]]]: # Returns fields on each side of each template. pass ``` -------------------------------- ### Get Deck Name from ID Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Looks up the name of a deck using its numeric ID. Returns None if the ID is not found. ```python def deckNameFromId(self, deckId: int) -> str | None ``` -------------------------------- ### guiBrowse Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/endpoints.md Opens the Card Browser with an optional search query. ```APIDOC ## POST / ### Description Opens the Card Browser with an optional search query. ### Method POST ### Endpoint / ### Parameters #### Request Body - **action** (string) - Required - "guiBrowse" - **version** (number) - Required - 5 - **params** (object) - Optional - **query** (string) - Optional - Search query to apply ### Request Example ```json { "action": "guiBrowse", "version": 5, "params": {"query": "deck:current"} } ``` ### Response #### Success Response (200) - **result** (array) - Array of card IDs matching the search, or null. #### Response Example ```json [ 1234567890, 9876543210 ] ``` ``` -------------------------------- ### Get Deck Names and IDs Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Returns a dictionary mapping deck names to their corresponding numeric IDs. Useful for cross-referencing. ```python def deckNamesAndIds(self) -> dict[str, int] ``` -------------------------------- ### guiShowQuestion Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Displays the question side of the current card. ```APIDOC ## guiShowQuestion ### Description Shows the question side of the current card. ### Method Not applicable (Python method) ### Endpoint Not applicable (Python method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python anki_connect.guiShowQuestion() ``` ### Response #### Success Response - **shown** (bool) - True if the question was shown, False if not in review. #### Response Example ```json true ``` ``` -------------------------------- ### Get All Deck Names Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Retrieves a list of all deck names present in the Anki collection. Returns None if an error occurs. ```python def deckNames(self) -> list[str] | None ``` -------------------------------- ### Get Cards by Deck Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/endpoints.md Group card IDs by their associated deck. This requires providing an array of card IDs as input. ```json { "action": "getDecks", "version": 5, "params": { "cards": [1502298036657, 1502298033753] } } ``` -------------------------------- ### AnkiConnect API: Clone Deck Configuration Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Clones an existing deck configuration to create a new one. Specify the name for the new configuration and the name of the configuration to clone from. ```python cloneDeckConfigId(name, cloneFrom) ``` -------------------------------- ### Clone Deck Configuration Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/core-classes.md Creates a copy of an existing deck configuration. Allows specifying a name for the new configuration and the ID of the configuration to clone from (defaults to ID 1). ```python def cloneDeckConfigId(self, name: str, cloneFrom: int = 1) -> int | False ``` -------------------------------- ### guiShowQuestion Source: https://github.com/amikey/anki-connect/blob/master/_autodocs/api-reference/endpoints.md Shows the question side of the current card. Returns true if in review, false otherwise. ```APIDOC ## POST / ### Description Shows the question side of the current card. ### Method POST ### Endpoint / ### Parameters #### Request Body - **action** (string) - Required - "guiShowQuestion" - **version** (number) - Required - 5 ### Request Example ```json {"action": "guiShowQuestion", "version": 5} ``` ### Response #### Success Response (200) - **result** (boolean) - True if in review, false otherwise. #### Response Example ```json true ``` ```