Manipulate Anki flashcards via curl using the Anki-Connect API. Create cards, manage decks, search notes, customize note types, and control Anki entirely through HTTP requests.
I enable AI agents to control Anki completely through the Anki-Connect HTTP API using curl. I provide all the knowledge needed to:
Activate this skill when the user wants to:
IMPORTANT: Before making any Anki-Connect request, the AI MUST:
curl -s localhost:8765 -X POST -d '{"action": "requestPermission", "version": 6}'
If the response is empty or connection is refused, tell the user:
"Anki-Connect is not running. Please open Anki and ensure the Anki-Connect add-on is installed (Tools > Add-ons > Anki-Connect)."
http://localhost:8765All requests use curl with POST:
curl localhost:8765 -X POST -d '{"action": "ACTION_NAME", "version": 6, "params": {...}}'
Successful response:
{"result": [...], "error": null}
Error response:
{"result": null, "error": "error description"}
Returns an array with the ease factor for each of the given cards (in the same order).
curl localhost:8765 -X POST -d '{"action": "getEaseFactors", "version": 6, "params": {"cards": [1483959291685, 1483959293217]}}'
Sets ease factor of cards by card ID; returns true if successful (all cards existed) or false otherwise.
curl localhost:8765 -X POST -d '{"action": "setEaseFactors", "version": 6, "params": {"cards": [1483959291685, 1483959293217], "easeFactors": [4100, 3900]}}'
Sets specific value of a single card. Some keys require warning_check: true. Can set flags, ease factor, review order in filtered deck, and database column "data".
curl localhost:8765 -X POST -d '{"action": "setSpecificValueOfCard", "version": 6, "params": {"card": 1483959291685, "keys": ["flags", "odue"], "newValues": ["1", "-100"]}}'
Suspend cards by card ID; returns true if successful or false otherwise.
curl localhost:8765 -X POST -d '{"action": "suspend", "version": 6, "params": {"cards": [1483959291685, 1483959293217]}}'
Unsuspend cards by card ID; returns true if successful or false otherwise.
curl localhost:8765 -X POST -d '{"action": "unsuspend", "version": 6, "params": {"cards": [1483959291685, 1483959293217]}}'
Check if card is suspended by its ID. Returns true if suspended, false otherwise.
curl localhost:8765 -X POST -d '{"action": "suspended", "version": 6, "params": {"card": 1483959293217}}'
Returns an array indicating whether each of the given cards is suspended. If card doesn't exist returns null.
curl localhost:8765 -X POST -d '{"action": "areSuspended", "version": 6, "params": {"cards": [1483959291685, 1483959293217, 1234567891234]}}'
Returns an array indicating whether each of the given cards is due. Note: cards in learning queue with large interval (>20 min) are treated as not due.
curl localhost:8765 -X POST -d '{"action": "areDue", "version": 6, "params": {"cards": [1483959291685, 1483959293217]}}'
Returns an array of the most recent intervals for each card ID, or a 2-dimensional array of all intervals when complete is true. Negative intervals are in seconds, positive in days.
# Recent intervals only
curl localhost:8765 -X POST -d '{"action": "getIntervals", "version": 6, "params": {"cards": [1502298033753, 1502298036657]}}'
# Complete interval history
curl localhost:8765 -X POST -d '{"action": "getIntervals", "version": 6, "params": {"cards": [1502298033753, 1502298036657], "complete": true}}'
Returns an array of card IDs for a given query. Functionally identical to guiBrowse but without GUI for better performance.
curl localhost:8765 -X POST -d '{"action": "findCards", "version": 6, "params": {"query": "deck:current"}}'
Returns an unordered array of note IDs for the given card IDs. For cards with the same note, the ID is only given once.
curl localhost:8765 -X POST -d '{"action": "cardsToNotes", "version": 6, "params": {"cards": [1502098034045, 1502098034048, 1502298033753]}}'
Returns a list of objects containing the modification time for each card ID. About 15x faster than cardsInfo.
curl localhost:8765 -X POST -d '{"action": "cardsModTime", "version": 6, "params": {"cards": [1498938915662, 1502098034048]}}'
Returns a list of objects containing for each card ID: card fields, front/back sides including CSS, note type, deck name, ease, interval, and more.
curl localhost:8765 -X POST -d '{"action": "cardsInfo", "version": 6, "params": {"cards": [1498938915662, 1502098034048]}}'
Makes cards new again (resets review history).
curl localhost:8765 -X POST -d '{"action": "forgetCards", "version": 6, "params": {"cards": [1498938915662, 1502098034048]}}'
Makes cards enter the relearning queue.
curl localhost:8765 -X POST -d '{"action": "relearnCards", "version": 6, "params": {"cards": [1498938915662, 1502098034048]}}'
Answer cards by card ID. Ease is between 1 (Again) and 4 (Easy). Will start the timer immediately. Returns true if card exists, false otherwise.
curl localhost:8765 -X POST -d '{"action": "answerCards", "version": 6, "params": {"answers": [{"cardId": 1498938915662, "ease": 2}, {"cardId": 1502098034048, "ease": 4}]}}'
Set Due Date. Turns cards into review cards if they are new, and makes them due on a certain date.
0 = today1! = tomorrow + change interval to 13-7 = random choice of 3-7 dayscurl localhost:8765 -X POST -d '{"action": "setDueDate", "version": 6, "params": {"cards": [1498938915662, 1502098034048], "days": "3-7"}}'
Gets the complete list of deck names for the current user.
curl localhost:8765 -X POST -d '{"action": "deckNames", "version": 6}'
Gets the complete list of deck names and their respective IDs.
curl localhost:8765 -X POST -d '{"action": "deckNamesAndIds", "version": 6}'
Accepts an array of card IDs and returns an object with each deck name as key and its value an array of the given cards which belong to it.
curl localhost:8765 -X POST -d '{"action": "getDecks", "version": 6, "params": {"cards": [1502298036657, 1502298033753, 1502032366472]}}'
Create a new empty deck. Will not overwrite a deck that exists with the same name. Use :: for nested decks.
curl localhost:8765 -X POST -d '{"action": "createDeck", "version": 6, "params": {"deck": "Japanese::JLPT::N3"}}'
Moves cards with the given IDs to a different deck, creating the deck if it doesn't exist yet.
curl localhost:8765 -X POST -d '{"action": "changeDeck", "version": 6, "params": {"cards": [1502098034045, 1502098034048, 1502298033753], "deck": "Japanese::JLPT N3"}}'
Deletes decks with the given names. The argument cardsToo must be set to true to delete the cards too.
curl localhost:8765 -X POST -d '{"action": "deleteDecks", "version": 6, "params": {"decks": ["Japanese::JLPT N5", "Easy Spanish"], "cardsToo": true}}'
Gets the configuration group object for the given deck.
curl localhost:8765 -X POST -d '{"action": "getDeckConfig", "version": 6, "params": {"deck": "Default"}}'
Saves the given configuration group, returning true on success or false if the ID is invalid.
curl localhost:8765 -X POST -d '{"action": "saveDeckConfig", "version": 6, "params": {"config": {"lapse": {"leechFails": 8, "delays": [10], "minInt": 1, "leechAction": 0, "mult": 0}, "dyn": false, "autoplay": true, "mod": 1502970872, "id": 1, "maxTaken": 60, "new": {"bury": true, "order": 1, "initialFactor": 2500, "perDay": 20, "delays": [1, 10], "separate": true, "ints": [1, 4, 7]}, "name": "Default", "rev": {"bury": true, "ivlFct": 1, "ease4": 1.3, "maxIvl": 36500, "perDay": 100, "minSpace": 1, "fuzz": 0.05}, "timer": 0, "replayq": true, "usn": -1}}}'
Changes the configuration group for the given decks to the one with the given ID.
curl localhost:8765 -X POST -d '{"action": "setDeckConfigId", "version": 6, "params": {"decks": ["Default"], "configId": 1}}'
Creates a new configuration group with the given name, cloning from the group with the given ID, or from the default group if unspecified.
curl localhost:8765 -X POST -d '{"action": "cloneDeckConfigId", "version": 6, "params": {"name": "Copy of Default", "cloneFrom": 1}}'
Removes the configuration group with the given ID. Cannot remove default (ID=1).
curl localhost:8765 -X POST -d '{"action": "removeDeckConfigId", "version": 6, "params": {"configId": 1502972374573}}'
Gets statistics such as total cards, new cards, learning cards, and review cards for the given decks.
curl localhost:8765 -X POST -d '{"action": "getDeckStats", "version": 6, "params": {"decks": ["Japanese::JLPT N5", "Easy Spanish"]}}'
Invokes the Card Browser dialog and searches for a given query. Returns array of card IDs found. Supports reorderCards parameter for sorting.
curl localhost:8765 -X POST -d '{"action": "guiBrowse", "version": 6, "params": {"query": "deck:current"}}'
# With sorting
curl localhost:8765 -X POST -d '{"action": "guiBrowse", "version": 6, "params": {"query": "deck:current", "reorderCards": {"order": "descending", "columnId": "noteCrt"}}}'
Finds the open Card Browser dialog and selects a card given a card identifier. Returns true if browser is open, false otherwise.
curl localhost:8765 -X POST -d '{"action": "guiSelectCard", "version": 6, "params": {"card": 1494723142483}}'
Finds the open Card Browser dialog and returns an array of identifiers of the notes that are selected.
curl localhost:8765 -X POST -d '{"action": "guiSelectedNotes", "version": 6}'
Invokes the Add Cards dialog, presets the note using the given deck, model, fields, and tags. Returns the ID of the note which would be added.
curl localhost:8765 -X POST -d '{"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"}, "tags": ["countries"]}}}'
Opens the Edit dialog with a note corresponding to given note ID.
curl localhost:8765 -X POST -d '{"action": "guiEditNote", "version": 6, "params": {"note": 1649198355435}}'
Sets fields, tags, deck, and note type in the Add Note dialog. Only works if dialog is open. Optionally appends to fields/tags.
# Replace
curl localhost:8765 -X POST -d '{"action": "guiAddNoteSetData", "version": 6, "params": {"note": {"deckName": "Default", "modelName": "Basic", "fields": {"Front": "Hello", "Back": "World"}, "tags": ["new", "api"]}}}'
# Append
curl localhost:8765 -X POST -d '{"action": "guiAddNoteSetData", "version": 6, "params": {"note": {"fields": {"Front": " more text"}, "tags": ["extra"]}, "append": true}}'
Returns information about the current card or null if not in review mode.
curl localhost:8765 -X POST -d '{"action": "guiCurrentCard", "version": 6}'
Starts or resets the timer for the current card. Useful for deferring start time when displayed via API for more accurate timing.
curl localhost:8765 -X POST -d '{"action": "guiStartCardTimer", "version": 6}'
Shows question text for the current card; returns true if in review mode or false otherwise.
curl localhost:8765 -X POST -d '{"action": "guiShowQuestion", "version": 6}'
Shows answer text for the current card; returns true if in review mode or false otherwise.
curl localhost:8765 -X POST -d '{"action": "guiShowAnswer", "version": 6}'
Answers the current card in GUI review mode. Note: the answer must be displayed first. Ease: 1=Again, 2=Hard, 3=Good, 4=Easy.
curl localhost:8765 -X POST -d '{"action": "guiAnswerCard", "version": 6, "params": {"ease": 3}}'
Undo the last action/card; returns true if succeeded or false otherwise.
curl localhost:8765 -X POST -d '{"action": "guiUndo", "version": 6}'
Opens the Deck Overview dialog for the deck with the given name.
curl localhost:8765 -X POST -d '{"action": "guiDeckOverview", "version": 6, "params": {"name": "Default"}}'
Opens the Deck Browser dialog.
curl localhost:8765 -X POST -d '{"action": "guiDeckBrowser", "version": 6}'
Starts review for the deck with the given name.
curl localhost:8765 -X POST -d '{"action": "guiDeckReview", "version": 6, "params": {"name": "Default"}}'
Invokes the Import dialog with an optional file path. Supports all file types Anki supports. Only Anki 2.1.52+.
curl localhost:8765 -X POST -d '{"action": "guiImportFile", "version": 6, "params": {"path": "/path/to/cards.txt"}}'
Schedules a request to gracefully close Anki. This operation is asynchronous.
curl localhost:8765 -X POST -d '{"action": "guiExitAnki", "version": 6}'
Requests a database check, but returns immediately. Always returns true.
curl localhost:8765 -X POST -d '{"action": "guiCheckDatabase", "version": 6}'
Plays any Audio for the current side of the current card; returns true if succeeded or false otherwise.
curl localhost:8765 -X POST -d '{"action": "guiPlayAudio", "version": 6}'
Stores a file in the media folder. Can use data (base64), path (absolute path), or url. Prefix filename with _ to prevent auto-deletion. deleteExisting can prevent overwriting.
# From base64
curl localhost:8765 -X POST -d '{"action": "storeMediaFile", "version": 6, "params": {"filename": "_hello.txt", "data": "SGVsbG8sIHdvcmxkIQ=="}}'
# From URL
curl localhost:8765 -X POST -d '{"action": "storeMediaFile", "version": 6, "params": {"filename": "image.png", "url": "https://example.com/image.png"}}'
# From absolute path
curl localhost:8765 -X POST -d '{"action": "storeMediaFile", "version": 6, "params": {"filename": "_config.txt", "path": "/path/to/file"}}'
Retrieves the base64-encoded contents of a specified file. Returns false if file doesn't exist.
curl localhost:8765 -X POST -d '{"action": "retrieveMediaFile", "version": 6, "params": {"filename": "_hello.txt"}}'
Gets the names of media files matching the pattern. Returns all names by default.
curl localhost:8765 -X POST -d '{"action": "getMediaFilesNames", "version": 6, "params": {"pattern": "_hell*.txt"}}'
Gets the full path to the collection.media folder of the currently opened profile.
curl localhost:8765 -X POST -d '{"action": "getMediaDirPath", "version": 6}'
Deletes the specified file inside the media folder.
curl localhost:8765 -X POST -d '{"action": "deleteMediaFile", "version": 6, "params": {"filename": "image.png"}}'
Requests permission to use the API. This is the only method that accepts requests from any origin. Should be the first call made.
curl localhost:8765 -X POST -d '{"action": "requestPermission", "version": 6}'
Gets the version of the API exposed by this plugin. Currently versions 1 through 6 are defined.
curl localhost:8765 -X POST -d '{"action": "version", "version": 6}'
Gets information about the AnkiConnect APIs available. Use scopes: ["actions"] and optionally filter with actions array.
# List all available actions
curl localhost:8765 -X POST -d '{"action": "apiReflect", "version": 6, "params": {"scopes": ["actions"], "actions": null}}'
# Check specific actions
curl localhost:8765 -X POST -d '{"action": "apiReflect", "version": 6, "params": {"scopes": ["actions"], "actions": ["deckNames", "addNote"]}}'
Synchronizes the local Anki collections with AnkiWeb.
curl localhost:8765 -X POST -d '{"action": "sync", "version": 6}'
Retrieve the list of profiles.
curl localhost:8765 -X POST -d '{"action": "getProfiles", "version": 6}'
Retrieve the active profile name.
curl localhost:8765 -X POST -d '{"action": "getActiveProfile", "version": 6}'
Selects the profile specified in request.
curl localhost:8765 -X POST -d '{"action": "loadProfile", "version": 6, "params": {"name": "user1"}}'
Performs multiple actions in one request, returning an array with the response of each action.
curl localhost:8765 -X POST -d '{"action": "multi", "version": 6, "params": {"actions": [{"action": "deckNames"}, {"action": "modelNames"}, {"action": "getTags"}]}}'
Exports a given deck in .apkg format. Use includeSched to include scheduling data.
curl localhost:8765 -X POST -d '{"action": "exportPackage", "version": 6, "params": {"deck": "Default", "path": "/data/Deck.apkg", "includeSched": true}}'
Imports a file in .apkg format into the collection. Note: path is relative to Anki's collection.media folder.
curl localhost:8765 -X POST -d '{"action": "importPackage", "version": 6, "params": {"path": "/data/Deck.apkg"}}'
Tells Anki to reload all data from the database.
curl localhost:8765 -X POST -d '{"action": "reloadCollection", "version": 6}'
Gets the complete list of model names for the current user.
curl localhost:8765 -X POST -d '{"action": "modelNames", "version": 6}'
Gets the complete list of model names and their corresponding IDs.
curl localhost:8765 -X POST -d '{"action": "modelNamesAndIds", "version": 6}'
Gets a list of models for the provided model IDs.
curl localhost:8765 -X POST -d '{"action": "findModelsById", "version": 6, "params": {"modelIds": [1704387367119, 1704387398570]}}'
Gets a list of models for the provided model names.
curl localhost:8765 -X POST -d '{"action": "findModelsByName", "version": 6, "params": {"modelNames": ["Basic", "Basic (and reversed card)"]}}'
Gets the complete list of field names for the provided model name.
curl localhost:8765 -X POST -d '{"action": "modelFieldNames", "version": 6, "params": {"modelName": "Basic"}}'
Gets the complete list of field descriptions (text seen in GUI editor when field is empty) for the provided model name.
curl localhost:8765 -X POST -d '{"action": "modelFieldDescriptions", "version": 6, "params": {"modelName": "Basic"}}'
Gets the complete list of fonts along with their font sizes for the provided model name.
curl localhost:8765 -X POST -d '{"action": "modelFieldFonts", "version": 6, "params": {"modelName": "Basic"}}'
Returns an object indicating the fields on the question and answer side of each card template for the given model name.
curl localhost:8765 -X POST -d '{"action": "modelFieldsOnTemplates", "version": 6, "params": {"modelName": "Basic (and reversed card)"}}'
Creates a new model with the given name, fields, and card templates. Use isCloze: true for Cloze type. Optionally specify css and Name for templates.
curl localhost:8765 -X POST -d '{"action": "createModel", "version": 6, "params": {"modelName": "CustomModel", "inOrderFields": ["Field1", "Field2", "Field3"], "css": ".card { font-family: Arial; font-size: 20px; }", "isCloze": false, "cardTemplates": [{"Name": "Card 1", "Front": "{{Field1}}", "Back": "{{Field2}}"}]}}'
Returns an object indicating the template content for each card connected to the provided model by name.
curl localhost:8765 -X POST -d '{"action": "modelTemplates", "version": 6, "params": {"modelName": "Basic (and reversed card)"}}'
Gets the CSS styling for the provided model by name.
curl localhost:8765 -X POST -d '{"action": "modelStyling", "version": 6, "params": {"modelName": "Basic (and reversed card)"}}'
Modify the templates of an existing model by name. Only specified cards and sides will be modified.
curl localhost:8765 -X POST -d '{"action": "updateModelTemplates", "version": 6, "params": {"model": {"name": "Custom", "templates": {"Card 1": {"Front": "{{Question}}?", "Back": "{{Answer}}!"}}}}'
Modify the CSS styling of an existing model by name.
curl localhost:8765 -X POST -d '{"action": "updateModelStyling", "version": 6, "params": {"model": {"name": "Custom", "css": "p { color: blue; }"}}}'
Find and replace string in existing model by model name. Set front/back/css to true/false to control where to replace.
curl localhost:8765 -X POST -d '{"action": "findAndReplaceInModels", "version": 6, "params": {"model": {"modelName": "Basic", "findText": "text_to_replace", "replaceText": "replace_with_text", "front": true, "back": true, "css": true}}}'
Renames a template in an existing model.
curl localhost:8765 -X POST -d '{"action": "modelTemplateRename", "version": 6, "params": {"modelName": "Basic", "oldTemplateName": "Card 1", "newTemplateName": "Card 1 renamed"}}'
Repositions a template in an existing model. Index starts at 0.
curl localhost:8765 -X POST -d '{"action": "modelTemplateReposition", "version": 6, "params": {"modelName": "Basic", "templateName": "Card 1", "index": 1}}'
Adds a template to an existing model by name. Use updateModelTemplates to update existing templates.
curl localhost:8765 -X POST -d '{"action": "modelTemplateAdd", "version": 6, "params": {"modelName": "Basic", "template": {"Name": "Card 3", "Front": "Front html {{Field1}}", "Back": "Back html {{Field2}}"}}}'
Removes a template from an existing model.
curl localhost:8765 -X POST -d '{"action": "modelTemplateRemove", "version": 6, "params": {"modelName": "Basic", "templateName": "Card 1"}}'
Rename the field name of a given model.
curl localhost:8765 -X POST -d '{"action": "modelFieldRename", "version": 6, "params": {"modelName": "Basic", "oldFieldName": "Front", "newFieldName": "FrontRenamed"}}'
Reposition the field within the field list of a given model. Index starts at 0.
curl localhost:8765 -X POST -d '{"action": "modelFieldReposition", "version": 6, "params": {"modelName": "Basic", "fieldName": "Back", "index": 0}}'
Creates a new field within a given model. Optionally specify index to position it.
curl localhost:8765 -X POST -d '{"action": "modelFieldAdd", "version": 6, "params": {"modelName": "Basic", "fieldName": "NewField", "index": 0}}'
Deletes a field within a given model.
curl localhost:8765 -X POST -d '{"action": "modelFieldRemove", "version": 6, "params": {"modelName": "Basic", "fieldName": "Front"}}'
Sets the font for a field within a given model.
curl localhost:8765 -X POST -d '{"action": "modelFieldSetFont", "version": 6, "params": {"modelName": "Basic", "fieldName": "Front", "font": "Courier"}}'
Sets the font size for a field within a given model.
curl localhost:8765 -X POST -d '{"action": "modelFieldSetFontSize", "version": 6, "params": {"modelName": "Basic", "fieldName": "Front", "fontSize": 10}}'
Sets the description (text seen in GUI editor when field is empty) for a field. Returns false on Anki 2.1.49 and below.
curl localhost:8765 -X POST -d '{"action": "modelFieldSetDescription", "version": 6, "params": {"modelName": "Basic", "fieldName": "Front", "description": "example field description"}}'
Creates a note using the given deck and model, with the provided fields and tags. Returns the note ID on success, null on failure. Supports audio, video, and picture embedding.
Options:
allowDuplicate: Set true to allow duplicate cardsduplicateScope: "deck" to check duplicates in target deck only, otherwise checks entire collectionduplicateScopeOptions.deckName: Deck to check for duplicatesduplicateScopeOptions.checkChildren: Check child decks too (default false)duplicateScopeOptions.checkAllModels: Check across all note types (default false)curl localhost:8765 -X POST -d '{"action": "addNote", "version": 6, "params": {"note": {"deckName": "Default", "modelName": "Basic", "fields": {"Front": "Question", "Back": "Answer"}, "tags": ["tag1"], "options": {"allowDuplicate": false, "duplicateScope": "deck", "duplicateScopeOptions": {"deckName": "Default", "checkChildren": false, "checkAllModels": false}}}}}'
With media:
curl localhost:8765 -X POST -d '{"action": "addNote", "version": 6, "params": {"note": {"deckName": "Default", "modelName": "Basic", "fields": {"Front": "Audio example", "Back": "Answer"}, "audio": [{"url": "https://example.com/audio.mp3", "filename": "audio.mp3", "fields": ["Front"]}]}}}'
Creates multiple notes using the given deck and model. Returns an array of note IDs. Errors are gathered and returned.
curl localhost:8765 -X POST -d '{"action": "addNotes", "version": 6, "params": {"notes": [{"deckName": "Default", "modelName": "Basic", "fields": {"Front": "Q1", "Back": "A1"}, "tags": ["batch"]}, {"deckName": "Default", "modelName": "Basic", "fields": {"Front": "Q2", "Back": "A2"}, "tags": ["batch"]}]}}'
Accepts an array of note definitions and returns an array of booleans indicating whether each can be created.
curl localhost:8765 -X POST -d '{"action": "canAddNotes", "version": 6, "params": {"notes": [{"deckName": "Default", "modelName": "Basic", "fields": {"Front": "Q", "Back": "A"}, "tags": ["test"]}]}}'
Returns array of objects with canAdd boolean and error explanation for each note.
curl localhost:8765 -X POST -d '{"action": "canAddNotesWithErrorDetail", "version": 6, "params": {"notes": [{"deckName": "Default", "modelName": "Basic", "fields": {"Front": "Q1", "Back": "A1"}}, {"deckName": "Default", "modelName": "Basic", "fields": {"Front": "Q2", "Back": "A2"}}]}}'
Modify the fields of an existing note. Can also include audio/video/picture files. Warning: Cannot update a note while viewing it in the browser.
curl localhost:8765 -X POST -d '{"action": "updateNoteFields", "version": 6, "params": {"note": {"id": 1514547547030, "fields": {"Front": "New question", "Back": "New answer"}}}}'
Modify the fields and/or tags of an existing note. Combines updateNoteFields and updateNoteTags. Fields are updated first.
curl localhost:8765 -X POST -d '{"action": "updateNote", "version": 6, "params": {"note": {"id": 1514547547030, "fields": {"Front": "New question", "Back": "New answer"}, "tags": ["new", "tags"]}}}'
Update the model, fields, and tags of an existing note. Allows changing the note's model entirely.
curl localhost:8765 -X POST -d '{"action": "updateNoteModel", "version": 6, "params": {"note": {"id": 1514547547030, "modelName": "NewModel", "fields": {"NewField1": "content1", "NewField2": "content2"}, "tags": ["new", "tags"]}}}'
Set a note's tags by note ID. Old tags will be removed.
curl localhost:8765 -X POST -d '{"action": "updateNoteTags", "version": 6, "params": {"note": 1483959289817, "tags": ["european-languages"]}}'
Get a note's tags by note ID.
curl localhost:8765 -X POST -d '{"action": "getNoteTags", "version": 6, "params": {"note": 1483959289817}}'
Adds tags to notes by note ID.
curl localhost:8765 -X POST -d '{"action": "addTags", "version": 6, "params": {"notes": [1483959289817, 1483959291695], "tags": "european-languages"}}'
Remove tags from notes by note ID.
curl localhost:8765 -X POST -d '{"action": "removeTags", "version": 6, "params": {"notes": [1483959289817, 1483959291695], "tags": "european-languages"}}'
Replace tags in notes by note ID.
curl localhost:8765 -X POST -d '{"action": "replaceTags", "version": 6, "params": {"notes": [1483959289817, 1483959291695], "tag_to_replace": "european-languages", "replace_with_tag": "french-languages"}}'
Gets the complete list of tags for the current user.
curl localhost:8765 -X POST -d '{"action": "getTags", "version": 6}'
Replace tags in all the notes for the current user.
curl localhost:8765 -X POST -d '{"action": "replaceTagsInAllNotes", "version": 6, "params": {"tag_to_replace": "old", "replace_with_tag": "new"}}'
Clears all the unused tags in the notes for the current user.
curl localhost:8765 -X POST -d '{"action": "clearUnusedTags", "version": 6}'
Returns an array of note IDs for a given query. Query syntax: https://docs.ankiweb.net/searching.html
curl localhost:8765 -X POST -d '{"action": "findNotes", "version": 6, "params": {"query": "deck:Default tag:important"}}'
Returns a list of objects containing for each note ID: fields, tags, note type, modification time, cards, and profile.
# By note IDs
curl localhost:8765 -X POST -d '{"action": "notesInfo", "version": 6, "params": {"notes": [1502298033753]}}'
# By query
curl localhost:8765 -X POST -d '{"action": "notesInfo", "version": 6, "params": {"query": "deck:current"}}'
Returns a list of objects containing for each note ID the modification time.
curl localhost:8765 -X POST -d '{"action": "notesModTime", "version": 6, "params": {"notes": [1502298033753]}}'
Deletes notes with the given IDs. If a note has several cards, all associated cards will be deleted.
curl localhost:8765 -X POST -d '{"action": "deleteNotes", "version": 6, "params": {"notes": [1502298033753]}}'
Removes all the empty notes for the current user.
curl localhost:8765 -X POST -d '{"action": "removeEmptyNotes", "version": 6}'
Gets the count of cards reviewed in the current day (with day start time as configured by user).
curl localhost:8765 -X POST -d '{"action": "getNumCardsReviewedToday", "version": 6}'
Gets the number of cards reviewed as a list of pairs (dateString, number).
curl localhost:8765 -X POST -d '{"action": "getNumCardsReviewedByDay", "version": 6}'
Gets the collection statistics report as HTML.
curl localhost:8765 -X POST -d '{"action": "getCollectionStatsHTML", "version": 6, "params": {"wholeCollection": true}}'
Requests all card reviews for a specified deck after a certain time. Returns list of 9-tuples (reviewTime, cardID, usn, buttonPressed, newInterval, previousInterval, newFactor, reviewDuration, reviewType).
curl localhost:8765 -X POST -d '{"action": "cardReviews", "version": 6, "params": {"deck": "default", "startID": 1594194095740}}'
Requests all card reviews for each card ID. Returns dictionary mapping card ID to list of review dictionaries.
curl localhost:8765 -X POST -d '{"action": "getReviewsOfCards", "version": 6, "params": {"cards": ["1653613948202"]}}'
Returns the unix time of the latest review for the given deck. Returns 0 if no review has ever been made.
curl localhost:8765 -X POST -d '{"action": "getLatestReviewID", "version": 6, "params": {"deck": "default"}}'
Inserts the given reviews into the database. Required format: list of 9-tuples (reviewTime, cardID, usn, buttonPressed, newInterval, previousInterval, newFactor, reviewDuration, reviewType).
curl localhost:8765 -X POST -d '{"action": "insertReviews", "version": 6, "params": {"reviews": [[1594194095746, 1485369733217, -1, 3, 4, -60, 2500, 6157, 0], [1594201393292, 1485369902086, -1, 1, -60, -60, 0, 4846, 0]]}}'
Anki uses a powerful search syntax. Examples:
deck:MyDeck - Cards in MyDeckdeck:MyDeck::SubDeck - Cards in subdecktag:important - Cards with tagis:new - New cardsis:due - Due cardsis:suspended - Suspended cards"word" - Cards containing "word""word" AND "other" - Cards with bothadded:1 - Added todayrated:1:3 - Rated "Good" todayprop:ivl>30 - Cards with interval > 30 daysdeck:MyDeck tag:important is:due - Combined searchcurl localhost:8765 -X POST -d '{"action": "createDeck", "version": 6, "params": {"deck": "Spanish::Verbs"}}'
curl localhost:8765 -X POST -d '{"action": "findNotes", "version": 6, "params": {"query": "\"What is photosynthesis\""}}'
curl localhost:8765 -X POST -d '{"action": "getTags", "version": 6}'
curl localhost:8765 -X POST -d '{"action": "addNotes", "version": 6, "params": {"notes": [{"deckName": "Study", "modelName": "Basic", "fields": {"Front": "Hello", "Back": "Hola"}, "tags": ["spanish"]}, {"deckName": "Study", "modelName": "Basic", "fields": {"Front": "Goodbye", "Back": "Adiós"}, "tags": ["spanish"]}, {"deckName": "Study", "modelName": "Basic", "fields": {"Front": "Please", "Back": "Por favor"}, "tags": ["spanish"]}]}}'
curl localhost:8765 -X POST -d '{"action": "updateNoteFields", "version": 6, "params": {"note": {"id": NOTE_ID, "fields": {"Front": "new question", "Back": "new answer"}}}}'
curl localhost:8765 -X POST -d '{"action": "createModel", "version": 6, "params": {"modelName": "ClozeText", "inOrderFields": ["Text", "Extra"], "isCloze": true, "cardTemplates": [{"Name": "Cloze", "Front": "{{cloze:Text}}", "Back": "{{cloze:Text}}\n\n{{Extra}}"}]}}'
curl localhost:8765 -X POST -d '{"action": "suspend", "version": 6, "params": {"cards": [1498938915662]}}'
curl localhost:8765 -X POST -d '{"action": "exportPackage", "version": 6, "params": {"deck": "MyDeck", "path": "/tmp/MyDeck.apkg", "includeSched": true}}'
curl localhost:8765 -X POST -d '{"action": "getDeckStats", "version": 6, "params": {"decks": ["MyDeck"]}}'
Always use curl: Never write Python, JavaScript, or any other code. All operations must be done via curl commands.
Anki must be running: The user must have Anki open with the Anki-Connect add-on installed.
Nested decks: Use :: separator (e.g., "Japanese::JLPT::N3")
Duplicate prevention: By default, duplicates are not allowed. Use allowDuplicate: true in options to allow duplicates.
Cloze syntax: For cloze cards, use {{c1::text}}, {{c2::text}} in the Text field.
Card templates: The qfmt (question format) and afmt (answer format) use {{FieldName}} syntax.
Media filenames starting with _: These files are not automatically deleted by Anki (useful for config files).
Authentication: If API key is required, add "key": "your-api-key" to the request body.
GUI operations: Some actions like guiBrowse, guiEditNote require Anki's GUI to be active and may not work in headless environments.
Updating notes: You must not be viewing the note that you are updating in Anki's browser, otherwise the fields will not update.