anki-connect/actions/graphical.md

5.7 KiB

Graphical Actions

  • guiBrowse

    Invokes the Card Browser dialog and searches for a given query. Returns an array of identifiers of the cards that were found. Query syntax is documented here.

    Sample request:

    {
        "action": "guiBrowse",
        "version": 6,
        "params": {
            "query": "deck:current"
        }
    }
    

    Sample result:

    {
        "result": [1494723142483, 1494703460437, 1494703479525],
        "error": null
    }
    
  • guiAddCards

    Invokes the Add Cards dialog, presets the note using the given deck and model, with the provided field values and tags. Invoking it multiple times closes the old window and reopen the window with the new provided values.

    The closeAfterAdding member inside options group can be set to true to create a dialog that closes upon adding the note. Invoking the action mutliple times with this option will create multiple windows.

    The result is the ID of the note which would be added, if the user chose to confirm the Add Cards dialogue.

    Sample request:

    {
        "action": "guiAddCards",
        "version": 6,
        "params": {
            "note": {
                "deckName": "Default",
                "modelName": "Cloze",
                "fields": {
                    "Text": "The capital of Romania is {{c1::Bucharest}}",
                    "Extra": "Romania is a country in Europe"
                },
                "options": {
                    "closeAfterAdding": true
                },
                "tags": [
                  "countries"
                ]
            }
        }
    }
    

    Sample result:

    {
        "result": 1496198395707,
        "error": null
    }
    
  • guiCurrentCard

    Returns information about the current card or null if not in review mode.

    Sample request:

    {
        "action": "guiCurrentCard",
        "version": 6
    }
    

    Sample result:

    {
        "result": {
            "answer": "back content",
            "question": "front content",
            "deckName": "Default",
            "modelName": "Basic",
            "fieldOrder": 0,
            "fields": {
                "Front": {"value": "front content", "order": 0},
                "Back": {"value": "back content", "order": 1}
            },
            "template": "Forward",
            "cardId": 1498938915662,
            "buttons": [1, 2, 3],
            "nextReviews": ["<1m", "<10m", "4d"]
        },
        "error": null
    }
    
  • guiStartCardTimer

    Starts or resets the timerStarted value for the current card. This is useful for deferring the start time to when it is displayed via the API, allowing the recorded time taken to answer the card to be more accurate when calling guiAnswerCard.

    Sample request:

    {
        "action": "guiStartCardTimer",
        "version": 6
    }
    

    Sample result:

    {
        "result": true,
        "error": null
    }
    
  • guiShowQuestion

    Shows question text for the current card; returns true if in review mode or false otherwise.

    Sample request:

    {
        "action": "guiShowQuestion",
        "version": 6
    }
    

    Sample result:

    {
        "result": true,
        "error": null
    }
    
  • guiShowAnswer

    Shows answer text for the current card; returns true if in review mode or false otherwise.

    Sample request:

    {
        "action": "guiShowAnswer",
        "version": 6
    }
    

    Sample result:

    {
        "result": true,
        "error": null
    }
    
  • guiAnswerCard

    Answers the current card; returns true if succeeded or false otherwise. Note that the answer for the current card must be displayed before before any answer can be accepted by Anki.

    Sample request:

    {
        "action": "guiAnswerCard",
        "version": 6,
        "params": {
            "ease": 1
        }
    }
    

    Sample result:

    {
        "result": true,
        "error": null
    }
    
  • guiDeckOverview

    Opens the Deck Overview dialog for the deck with the given name; returns true if succeeded or false otherwise.

    Sample request:

    {
        "action": "guiDeckOverview",
        "version": 6,
        "params": {
            "name": "Default"
        }
    }
    

    Sample result:

    {
        "result": true,
        "error": null
    }
    
  • guiDeckBrowser

    Opens the Deck Browser dialog.

    Sample request:

    {
        "action": "guiDeckBrowser",
        "version": 6
    }
    

    Sample result:

    {
        "result": null,
        "error": null
    }
    
  • guiDeckReview

    Starts review for the deck with the given name; returns true if succeeded or false otherwise.

    Sample request:

    {
        "action": "guiDeckReview",
        "version": 6,
        "params": {
            "name": "Default"
        }
    }
    

    Sample result:

    {
        "result": true,
        "error": null
    }
    
  • guiExitAnki

    Schedules a request to gracefully close Anki. This operation is asynchronous, so it will return immediately and won't wait until the Anki process actually terminates.

    Sample request:

    {
        "action": "guiExitAnki",
        "version": 6
    }
    

    Sample result:

    {
        "result": null,
        "error": null
    }