Updating README.md

This commit is contained in:
Alex Yatskov 2017-09-29 17:03:48 -07:00
parent 065c199105
commit bd071a3dfe

196
README.md
View File

@ -55,7 +55,7 @@ in order to bind it to all network interfaces on your host.
Every request consists of a JSON-encoded object containing an `action`, a `version`, and a set of contextual `params`. A Every request consists of a JSON-encoded object containing an `action`, a `version`, and a set of contextual `params`. A
simple example of a modern JavaScript application communicating with the extension is illustrated below: simple example of a modern JavaScript application communicating with the extension is illustrated below:
```JavaScript ```javascript
function ankiConnectInvoke(action, version, params={}) { function ankiConnectInvoke(action, version, params={}) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
@ -92,7 +92,7 @@ try {
Or using [`curl`](https://curl.haxx.se) from the command line: Or using [`curl`](https://curl.haxx.se) from the command line:
``` ```bash
curl localhost:8765 -X POST -d '{"action": "deckNames", "version": 5}' curl localhost:8765 -X POST -d '{"action": "deckNames", "version": 5}'
``` ```
@ -101,15 +101,15 @@ return value of the executed API, and the `error` field is a description of any
(the value `null` is used if execution completed successfully). (the value `null` is used if execution completed successfully).
*Sample successful response*: *Sample successful response*:
``` ```json
{"result": ["Default", "Filtered Deck 1"], "error": null} {"result": ["Default", "Filtered Deck 1"], "error": null}
``` ```
*Samples of failed responses*: *Samples of failed responses*:
``` ```json
{"result": null, "error": "unsupported action"} {"result": null, "error": "unsupported action"}
``` ```
``` ```json
{"result": null, "error": "guiBrowse() got an unexpected keyword argument 'foobar'"} {"result": null, "error": "guiBrowse() got an unexpected keyword argument 'foobar'"}
``` ```
@ -137,14 +137,14 @@ guarantee that your application continues to function properly in the future.
which are available in the reported AnkiConnect version or earlier, everything should work fine. which are available in the reported AnkiConnect version or earlier, everything should work fine.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "version" "action": "version"
} }
``` ```
*Sample result*: *Sample result*:
``` ```json
5 5
``` ```
@ -155,14 +155,14 @@ guarantee that your application continues to function properly in the future.
GitHub. Returns a boolean value indicating if the plugin was upgraded or not. GitHub. Returns a boolean value indicating if the plugin was upgraded or not.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "upgrade" "action": "upgrade"
} }
``` ```
*Sample result*: *Sample result*:
``` ```json
true true
``` ```
@ -171,7 +171,7 @@ guarantee that your application continues to function properly in the future.
Performs multiple actions in one request, returning an array with the response of each action (in the given order). Performs multiple actions in one request, returning an array with the response of each action (in the given order).
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "multi", "action": "multi",
"params": { "params": {
@ -187,7 +187,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
[ [
["Default"], ["Default"],
[1494723142483, 1494703460437, 1494703479525] [1494723142483, 1494703460437, 1494703479525]
@ -201,14 +201,14 @@ guarantee that your application continues to function properly in the future.
Gets the complete list of deck names for the current user. Gets the complete list of deck names for the current user.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "deckNames" "action": "deckNames"
} }
``` ```
*Sample result*: *Sample result*:
``` ```json
[ [
"Default" "Default"
] ]
@ -219,14 +219,14 @@ guarantee that your application continues to function properly in the future.
Gets the complete list of deck names and their respective IDs for the current user. Gets the complete list of deck names and their respective IDs for the current user.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "deckNamesAndIds" "action": "deckNamesAndIds"
} }
``` ```
*Sample result*: *Sample result*:
``` ```json
{ {
"Default": 1 "Default": 1
} }
@ -238,7 +238,7 @@ guarantee that your application continues to function properly in the future.
cards which belong to it. cards which belong to it.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "getDecks", "action": "getDecks",
"params": { "params": {
@ -248,7 +248,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
{ {
"Default": [1502032366472], "Default": [1502032366472],
"Japanese::JLPT N3": [1502298036657, 1502298033753] "Japanese::JLPT N3": [1502298036657, 1502298033753]
@ -260,7 +260,7 @@ guarantee that your application continues to function properly in the future.
Moves cards with the given IDs to a different deck, creating the deck if it doesn't exist yet. Moves cards with the given IDs to a different deck, creating the deck if it doesn't exist yet.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "changeDeck", "action": "changeDeck",
"params": { "params": {
@ -271,7 +271,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
null null
``` ```
@ -281,7 +281,7 @@ guarantee that your application continues to function properly in the future.
the deleted decks will also be deleted; otherwise they will be moved to the default deck. the deleted decks will also be deleted; otherwise they will be moved to the default deck.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "deleteDecks", "action": "deleteDecks",
"params": { "params": {
@ -292,7 +292,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
null null
``` ```
@ -303,7 +303,7 @@ guarantee that your application continues to function properly in the future.
Gets the config group object for the given deck. Gets the config group object for the given deck.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "getDeckConfig", "action": "getDeckConfig",
"params": { "params": {
@ -313,7 +313,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
{ {
"lapse": { "lapse": {
"leechFails": 8, "leechFails": 8,
@ -358,7 +358,7 @@ guarantee that your application continues to function properly in the future.
it does not exist). it does not exist).
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "saveDeckConfig", "action": "saveDeckConfig",
"params": { "params": {
@ -368,7 +368,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
true true
``` ```
@ -378,7 +378,7 @@ guarantee that your application continues to function properly in the future.
`false` if the given configuration group or any of the given decks do not exist. `false` if the given configuration group or any of the given decks do not exist.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "setDeckConfigId", "action": "setDeckConfigId",
"params": { "params": {
@ -389,7 +389,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
true true
``` ```
@ -400,7 +400,7 @@ guarantee that your application continues to function properly in the future.
not exist. not exist.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "cloneDeckConfigId", "action": "cloneDeckConfigId",
"params": { "params": {
@ -411,7 +411,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
1502972374573 1502972374573
``` ```
@ -421,7 +421,7 @@ guarantee that your application continues to function properly in the future.
either the default config group (ID = 1) or a config group that does not exist. either the default config group (ID = 1) or a config group that does not exist.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "removeDeckConfigId", "action": "removeDeckConfigId",
"params": { "params": {
@ -431,7 +431,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
true true
``` ```
@ -442,14 +442,14 @@ guarantee that your application continues to function properly in the future.
Gets the complete list of model names for the current user. Gets the complete list of model names for the current user.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "modelNames" "action": "modelNames"
} }
``` ```
*Sample result*: *Sample result*:
``` ```json
[ [
"Basic", "Basic",
"Basic (and reversed card)" "Basic (and reversed card)"
@ -461,18 +461,18 @@ guarantee that your application continues to function properly in the future.
Gets the complete list of model names and their corresponding IDs for the current user. Gets the complete list of model names and their corresponding IDs for the current user.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "modelNamesAndIds" "action": "modelNamesAndIds"
} }
``` ```
*Sample result*: *Sample result*:
``` ```json
{ {
"Basic": 1483883011648 "Basic": 1483883011648,
"Basic (and reversed card)": 1483883011644 "Basic (and reversed card)": 1483883011644,
"Basic (optional reversed card)": 1483883011631 "Basic (optional reversed card)": 1483883011631,
"Cloze": 1483883011630 "Cloze": 1483883011630
} }
``` ```
@ -482,7 +482,7 @@ guarantee that your application continues to function properly in the future.
Gets the complete list of field names for the provided model name. Gets the complete list of field names for the provided model name.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "modelFieldNames", "action": "modelFieldNames",
"params": { "params": {
@ -492,7 +492,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
[ [
"Front", "Front",
"Back" "Back"
@ -505,7 +505,7 @@ guarantee that your application continues to function properly in the future.
name. The question side is given first in each array. name. The question side is given first in each array.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "modelFieldsOnTemplates", "action": "modelFieldsOnTemplates",
"params": { "params": {
@ -515,7 +515,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
{ {
"Card 1": [ "Card 1": [
["Front"], ["Front"],
@ -542,7 +542,7 @@ guarantee that your application continues to function properly in the future.
list of fields that should play audio when the card is displayed in Anki. list of fields that should play audio when the card is displayed in Anki.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "addNote", "action": "addNote",
"params": { "params": {
@ -568,7 +568,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
1496198395707 1496198395707
``` ```
@ -579,7 +579,7 @@ guarantee that your application continues to function properly in the future.
documentation for `addNote` for an explanation of objects in the `notes` array. documentation for `addNote` for an explanation of objects in the `notes` array.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "addNotes", "action": "addNotes",
"params": { "params": {
@ -607,7 +607,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
[ [
1496198395707, 1496198395707,
null null
@ -620,7 +620,7 @@ guarantee that your application continues to function properly in the future.
booleans indicating whether or not the parameters at the corresponding index could be used to create a new note. booleans indicating whether or not the parameters at the corresponding index could be used to create a new note.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "canAddNotes", "action": "canAddNotes",
"params": { "params": {
@ -642,7 +642,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
[ [
true true
] ]
@ -655,7 +655,7 @@ guarantee that your application continues to function properly in the future.
Adds tags to notes by note ID. Adds tags to notes by note ID.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "addTags", "action": "addTags",
"params": { "params": {
@ -666,7 +666,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
null null
``` ```
@ -675,7 +675,7 @@ guarantee that your application continues to function properly in the future.
Remove tags from notes by note ID. Remove tags from notes by note ID.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "removeTags", "action": "removeTags",
"params": { "params": {
@ -686,7 +686,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
null null
``` ```
@ -698,7 +698,7 @@ guarantee that your application continues to function properly in the future.
otherwise. otherwise.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "suspend", "action": "suspend",
"params": { "params": {
@ -708,7 +708,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
true true
``` ```
@ -718,7 +718,7 @@ guarantee that your application continues to function properly in the future.
otherwise. otherwise.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "unsuspend", "action": "unsuspend",
"params": { "params": {
@ -728,7 +728,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
true true
``` ```
@ -737,7 +737,7 @@ guarantee that your application continues to function properly in the future.
Returns an array indicating whether each of the given cards is suspended (in the same order). Returns an array indicating whether each of the given cards is suspended (in the same order).
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "areSuspended", "action": "areSuspended",
"params": { "params": {
@ -747,7 +747,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
[false, true] [false, true]
``` ```
@ -760,7 +760,7 @@ guarantee that your application continues to function properly in the future.
match the way Anki treats them when reviewing. match the way Anki treats them when reviewing.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "areDue", "action": "areDue",
"params": { "params": {
@ -770,7 +770,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
[false, true] [false, true]
``` ```
@ -780,7 +780,7 @@ guarantee that your application continues to function properly in the future.
for each given card ID when `complete` is `true`. (Negative intervals are in seconds and positive intervals in days.) for each given card ID when `complete` is `true`. (Negative intervals are in seconds and positive intervals in days.)
*Sample request 1*: *Sample request 1*:
``` ```json
{ {
"action": "getIntervals", "action": "getIntervals",
"params": { "params": {
@ -790,12 +790,12 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result 1*: *Sample result 1*:
``` ```json
[-14400, 3] [-14400, 3]
``` ```
*Sample request 2*: *Sample request 2*:
``` ```json
{ {
"action": "getIntervals", "action": "getIntervals",
"params": { "params": {
@ -806,7 +806,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result 2*: *Sample result 2*:
``` ```json
[ [
[-120, -180, -240, -300, -360, -14400], [-120, -180, -240, -300, -360, -14400],
[-120, -180, -240, -300, -360, -14400, 1, 3] [-120, -180, -240, -300, -360, -14400, 1, 3]
@ -820,7 +820,7 @@ guarantee that your application continues to function properly in the future.
Returns an array of note IDs for a given query (same query syntax as **guiBrowse**). Returns an array of note IDs for a given query (same query syntax as **guiBrowse**).
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "findNotes", "action": "findNotes",
"params": { "params": {
@ -830,7 +830,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
[ [
1483959289817, 1483959289817,
1483959291695 1483959291695
@ -843,7 +843,7 @@ guarantee that your application continues to function properly in the future.
for better performance). for better performance).
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "findCards", "action": "findCards",
"params": { "params": {
@ -853,7 +853,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
[ [
1494723142483, 1494723142483,
1494703460437, 1494703460437,
@ -867,7 +867,7 @@ guarantee that your application continues to function properly in the future.
given once in the array. given once in the array.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "cardsToNotes", "action": "cardsToNotes",
"params": { "params": {
@ -877,7 +877,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
[ [
1502098029797, 1502098029797,
1502298025183 1502298025183
@ -894,7 +894,7 @@ guarantee that your application continues to function properly in the future.
with an underscore. These files are still synchronized to AnkiWeb. with an underscore. These files are still synchronized to AnkiWeb.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "storeMediaFile", "action": "storeMediaFile",
"params": { "params": {
@ -905,7 +905,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
null null
``` ```
@ -919,7 +919,7 @@ guarantee that your application continues to function properly in the future.
Retrieves the base64-encoded contents of the specified file, returning `false` if the file does not exist. Retrieves the base64-encoded contents of the specified file, returning `false` if the file does not exist.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "retrieveMediaFile", "action": "retrieveMediaFile",
"params": { "params": {
@ -929,7 +929,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
"SGVsbG8sIHdvcmxkIQ==" "SGVsbG8sIHdvcmxkIQ=="
``` ```
@ -938,7 +938,7 @@ guarantee that your application continues to function properly in the future.
Deletes the specified file inside the media folder. Deletes the specified file inside the media folder.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "deleteMediaFile", "action": "deleteMediaFile",
"params": { "params": {
@ -948,7 +948,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
null null
``` ```
@ -959,7 +959,7 @@ guarantee that your application continues to function properly in the future.
Invokes the card browser and searches for a given query. Returns an array of identifiers of the cards that were found. Invokes the card browser and searches for a given query. Returns an array of identifiers of the cards that were found.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "guiBrowse", "action": "guiBrowse",
"params": { "params": {
@ -969,7 +969,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
[ [
1494723142483, 1494723142483,
1494703460437, 1494703460437,
@ -982,14 +982,14 @@ guarantee that your application continues to function properly in the future.
Invokes the AddCards dialog. Invokes the AddCards dialog.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "guiAddCards" "action": "guiAddCards"
} }
``` ```
*Sample result*: *Sample result*:
``` ```json
null null
``` ```
@ -998,14 +998,14 @@ guarantee that your application continues to function properly in the future.
Returns information about the current card or `null` if not in review mode. Returns information about the current card or `null` if not in review mode.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "guiCurrentCard" "action": "guiCurrentCard"
} }
``` ```
*Sample result*: *Sample result*:
``` ```json
{ {
"answer": "back content", "answer": "back content",
"question": "front content", "question": "front content",
@ -1032,14 +1032,14 @@ guarantee that your application continues to function properly in the future.
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. 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*: *Sample request*:
``` ```json
{ {
"action": "guiStartCardTimer" "action": "guiStartCardTimer"
} }
``` ```
*Sample result*: *Sample result*:
``` ```json
true true
``` ```
@ -1048,14 +1048,14 @@ guarantee that your application continues to function properly in the future.
Shows question text for the current card; returns `true` if in review mode or `false` otherwise. Shows question text for the current card; returns `true` if in review mode or `false` otherwise.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "guiShowQuestion" "action": "guiShowQuestion"
} }
``` ```
*Sample result*: *Sample result*:
``` ```json
true true
``` ```
@ -1064,14 +1064,14 @@ guarantee that your application continues to function properly in the future.
Shows answer text for the current card; returns `true` if in review mode or `false` otherwise. Shows answer text for the current card; returns `true` if in review mode or `false` otherwise.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "guiShowAnswer" "action": "guiShowAnswer"
} }
``` ```
*Sample result*: *Sample result*:
``` ```json
true true
``` ```
@ -1081,7 +1081,7 @@ guarantee that your application continues to function properly in the future.
card must be displayed before before any answer can be accepted by Anki. card must be displayed before before any answer can be accepted by Anki.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "guiAnswerCard", "action": "guiAnswerCard",
"params": { "params": {
@ -1091,7 +1091,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
true true
``` ```
@ -1100,7 +1100,7 @@ guarantee that your application continues to function properly in the future.
Opens the Deck Overview screen for the deck with the given name; returns `true` if succeeded or `false` otherwise. Opens the Deck Overview screen for the deck with the given name; returns `true` if succeeded or `false` otherwise.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "guiDeckOverview", "action": "guiDeckOverview",
"params": { "params": {
@ -1110,7 +1110,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
true true
``` ```
@ -1119,14 +1119,14 @@ guarantee that your application continues to function properly in the future.
Opens the Deck Browser screen. Opens the Deck Browser screen.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "guiDeckBrowser" "action": "guiDeckBrowser"
} }
``` ```
*Sample result*: *Sample result*:
``` ```json
null null
``` ```
@ -1135,7 +1135,7 @@ guarantee that your application continues to function properly in the future.
Starts review for the deck with the given name; returns `true` if succeeded or `false` otherwise. Starts review for the deck with the given name; returns `true` if succeeded or `false` otherwise.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "guiDeckReview", "action": "guiDeckReview",
"params": { "params": {
@ -1145,7 +1145,7 @@ guarantee that your application continues to function properly in the future.
``` ```
*Sample result*: *Sample result*:
``` ```json
true true
``` ```
@ -1154,14 +1154,14 @@ guarantee that your application continues to function properly in the future.
Schedules a request to close Anki after 1s. This operation is asynchronous, so it will return immediately and won't wait until Anki actually exits. Schedules a request to close Anki after 1s. This operation is asynchronous, so it will return immediately and won't wait until Anki actually exits.
*Sample request*: *Sample request*:
``` ```json
{ {
"action": "guiExitAnki" "action": "guiExitAnki"
} }
``` ```
*Sample result*: *Sample result*:
``` ```json
null null
``` ```