diff --git a/README-origin.md b/README-origin.md
new file mode 100644
index 0000000..9ffe4b3
--- /dev/null
+++ b/README-origin.md
@@ -0,0 +1,4582 @@
+# Anki-Connect
+
+Anki-Connect enables external applications such as Yomichan to communicate with [Anki](https://apps.ankiweb.net/) over a simple HTTP API. Its capabilities include executing queries against the user's card deck, automatically creating new cards, and more. Anki-Connect is compatible with the latest stable (2.1.x) releases of Anki; older versions (2.0.x and below) are no longer supported.
+
+## Installation
+
+The installation process is similar to other Anki plugins and can be accomplished in three steps:
+
+1. Open the `Install Add-on` dialog by selecting `Tools` | `Add-ons` | `Get Add-ons...` in Anki.
+2. Input [2055492159](https://ankiweb.net/shared/info/2055492159) into the text box labeled `Code` and press the `OK` button to proceed.
+3. Restart Anki when prompted to do so in order to complete the installation of Anki-Connect.
+
+Anki must be kept running in the background in order for other applications to be able to use Anki-Connect. You can verify that Anki-Connect is running at any time by accessing `localhost:8765` in your browser. If the server is running, you will see the message `Anki-Connect` displayed in your browser window.
+
+### Notes for Windows Users
+
+Windows users may see a firewall nag dialog box appear on Anki startup. This occurs because Anki-Connect runs a local HTTP server in order to enable other applications to connect to it. The host application, Anki, must be unblocked for this plugin to function correctly.
+
+### Notes for MacOS Users
+
+Starting with [Mac OS X Mavericks](https://en.wikipedia.org/wiki/OS_X_Mavericks), a feature named *App Nap* has been introduced to the operating system. This feature causes certain applications which are open (but not visible) to be placed in a suspended state. As this behavior causes Anki-Connect to stop working while you have another window in the foreground, App Nap should be disabled for Anki:
+
+1. Start the Terminal application.
+2. Execute the following commands in the terminal window:
+ ```bash
+ defaults write net.ankiweb.dtop NSAppSleepDisabled -bool true
+ defaults write net.ichi2.anki NSAppSleepDisabled -bool true
+ defaults write org.qt-project.Qt.QtWebEngineCore NSAppSleepDisabled -bool true
+ ```
+3. Restart Anki.
+
+## Application Interface for Developers
+
+Anki-Connect exposes internal Anki features to external applications via an easy to use API. After being installed, this plugin will start an HTTP server on port 8765 whenever Anki is launched. Other applications (including browser extensions) can then communicate with it via HTTP requests.
+
+By default, Anki-Connect will only bind the HTTP server to the `127.0.0.1` IP address, so that you will only be able to access it from the same host on which it is running. If you need to access it over a network, you can change the binding address in the configuration. Go to Tools->Add-ons->AnkiConnect->Config and change the "webBindAddress" value. For example, you can set it to `0.0.0.0` in order to bind it to all network interfaces on your host. This also requires a restart for Anki.
+
+### Sample Invocation
+
+Every request consists of a JSON-encoded object containing an `action`, a `version`, contextual `params`, and a `key`
+value used for authentication (which is optional and can be omitted by default). Anki-Connect will respond with an
+object containing two fields: `result` and `error`. The `result` field contains the return value of the executed API,
+and the `error` field is a description of any exception thrown during API execution (the value `null` is used if
+execution completed successfully).
+
+*Sample successful response*:
+```json
+{"result": ["Default", "Filtered Deck 1"], "error": null}
+```
+
+*Samples of failed responses*:
+```json
+{"result": null, "error": "unsupported action"}
+```
+```json
+{"result": null, "error": "guiBrowse() got an unexpected keyword argument 'foobar'"}
+```
+
+For compatibility with clients designed to work with older versions of Anki-Connect, failing to provide a `version`
+field in the request will make the version default to 4. Furthermore, when the provided version is level 4 or below, the
+API response will only contain the value of the `result`; no `error` field is available for error handling.
+
+You can use whatever language or tool you like to issue request to Anki-Connect, but a couple of simple examples are
+included below as reference.
+
+#### Curl
+
+```bash
+curl localhost:8765 -X POST -d '{"action": "deckNames", "version": 6}'
+```
+
+#### Powershell
+
+```powershell
+(Invoke-RestMethod -Uri http://localhost:8765 -Method Post -Body '{"action": "deckNames", "version": 6}').result
+```
+
+#### Python
+
+```python
+import json
+import urllib.request
+
+def request(action, **params):
+ return {'action': action, 'params': params, 'version': 6}
+
+def invoke(action, **params):
+ requestJson = json.dumps(request(action, **params)).encode('utf-8')
+ response = json.load(urllib.request.urlopen(urllib.request.Request('http://127.0.0.1:8765', requestJson)))
+ if len(response) != 2:
+ raise Exception('response has an unexpected number of fields')
+ if 'error' not in response:
+ raise Exception('response is missing required error field')
+ if 'result' not in response:
+ raise Exception('response is missing required result field')
+ if response['error'] is not None:
+ raise Exception(response['error'])
+ return response['result']
+
+invoke('createDeck', deck='test1')
+result = invoke('deckNames')
+print('got list of decks: {}'.format(result))
+```
+
+#### JavaScript
+
+```javascript
+function invoke(action, version, params={}) {
+ return new Promise((resolve, reject) => {
+ const xhr = new XMLHttpRequest();
+ xhr.addEventListener('error', () => reject('failed to issue request'));
+ xhr.addEventListener('load', () => {
+ try {
+ const response = JSON.parse(xhr.responseText);
+ if (Object.getOwnPropertyNames(response).length != 2) {
+ throw 'response has an unexpected number of fields';
+ }
+ if (!response.hasOwnProperty('error')) {
+ throw 'response is missing required error field';
+ }
+ if (!response.hasOwnProperty('result')) {
+ throw 'response is missing required result field';
+ }
+ if (response.error) {
+ throw response.error;
+ }
+ resolve(response.result);
+ } catch (e) {
+ reject(e);
+ }
+ });
+
+ xhr.open('POST', 'http://127.0.0.1:8765');
+ xhr.send(JSON.stringify({action, version, params}));
+ });
+}
+
+await invoke('createDeck', 6, {deck: 'test1'});
+const result = await invoke('deckNames', 6);
+console.log(`got list of decks: ${result}`);
+```
+
+### Authentication
+
+Anki-Connect supports requiring authentication in order to make API requests.
+This support is *disabled* by default, but can be enabled by setting the `apiKey` field of Anki-Config's settings (Tools->Add-ons->AnkiConnect->Config) to a desired string.
+If you have done so, you should see the [`requestPermission`](#requestpermission) API request return `true` for `requireApiKey`.
+You then must include an additional parameter called `key` in any further API request bodies, whose value must match the configured API key.
+
+### Hey, could you add a new action to support $FEATURE?
+
+The primary goal for Anki-Connect was to support real-time flash card creation from the Yomichan browser extension. The current API provides all the required actions to make this happen. I recognise that the role of Anki-Connect has evolved from this original vision, and I am happy to review new feature requests.
+
+With that said, *this project operates on a self-serve model*. If you would like a new feature, create a PR. I'll review it and if it looks good, it will be merged in. *Requests to add new features without accompanying pull requests will not be serviced*. Make sure that your pull request meets the following criteria:
+
+* Attempt to match style of the surrounding code.
+* Have accompanying documentation with examples.
+* Have accompanying tests that verify operation.
+* Implement features useful in other applications.
+
+## Supported Actions
+
+Documentation for currently supported actions is split up by category and is referenced below. Note that deprecated APIs will continue to function despite not being listed on this page as long as your request is labeled with a version number corresponding to when the API was available for use. Search parameters are passed to Anki, check the docs for more information: https://docs.ankiweb.net/searching.html
+
+* [Card Actions](#card-actions)
+* [Deck Actions](#deck-actions)
+* [Graphical Actions](#graphical-actions)
+* [Media Actions](#media-actions)
+* [Miscellaneous Actions](#miscellaneous-actions)
+* [Model Actions](#model-actions)
+* [Note Actions](#note-actions)
+* [Statistic Actions](#statistic-actions)
+
+---
+
+### Card Actions
+
+#### `getEaseFactors`
+
+* Returns an array with the ease factor for each of the given cards (in the same order).
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "getEaseFactors",
+ "version": 6,
+ "params": {
+ "cards": [1483959291685, 1483959293217]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": [4100, 3900],
+ "error": null
+ }
+ ```
+
+
+#### `setEaseFactors`
+
+* Sets ease factor of cards by card ID; returns `true` if successful (all cards existed) or `false` otherwise.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "setEaseFactors",
+ "version": 6,
+ "params": {
+ "cards": [1483959291685, 1483959293217],
+ "easeFactors": [4100, 3900]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": [true, true],
+ "error": null
+ }
+ ```
+
+
+
+#### `setSpecificValueOfCard`
+
+* Sets specific value of a single card. Given the risk of wreaking havor in the database when changing some of the values of a card, some of the keys require the argument "warning_check" set to True.
+ This can be used to set a card's flag, change it's ease factor, change the review order in a filtered deck and change the column "data" (not currently used by anki apparantly), and many other values.
+ A list of values and explanation of their respective utility can be found at [AnkiDroid's wiki](https://github.com/ankidroid/Anki-Android/wiki/Database-Structure).
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "setSpecificValueOfCard",
+ "version": 6,
+ "params": {
+ "card": 1483959291685,
+ "keys": ["flags", "odue"],
+ "newValues": ["1", "-100"]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": [true, true],
+ "error": null
+ }
+ ```
+
+
+
+#### `suspend`
+
+* Suspend cards by card ID; returns `true` if successful (at least one card wasn't already suspended) or `false`
+ otherwise.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "suspend",
+ "version": 6,
+ "params": {
+ "cards": [1483959291685, 1483959293217]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
+#### `unsuspend`
+
+* Unsuspend cards by card ID; returns `true` if successful (at least one card was previously suspended) or `false`
+ otherwise.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "unsuspend",
+ "version": 6,
+ "params": {
+ "cards": [1483959291685, 1483959293217]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
+#### `suspended`
+
+* Check if card is suspended by its ID. Returns `true` if suspended, `false` otherwise.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "suspended",
+ "version": 6,
+ "params": {
+ "card": 1483959293217
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
+#### `areSuspended`
+
+* Returns an array indicating whether each of the given cards is suspended (in the same order). If card doesn't
+ exist returns `null`.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "areSuspended",
+ "version": 6,
+ "params": {
+ "cards": [1483959291685, 1483959293217, 1234567891234]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": [false, true, null],
+ "error": null
+ }
+ ```
+
+
+#### `areDue`
+
+* Returns an array indicating whether each of the given cards is due (in the same order). *Note*: cards in the
+ learning queue with a large interval (over 20 minutes) are treated as not due until the time of their interval has
+ passed, to match the way Anki treats them when reviewing.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "areDue",
+ "version": 6,
+ "params": {
+ "cards": [1483959291685, 1483959293217]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": [false, true],
+ "error": null
+ }
+ ```
+
+
+#### `getIntervals`
+
+* Returns an array of the most recent intervals for each given card ID, or a 2-dimensional array of all the intervals
+ for each given card ID when `complete` is `true`. Negative intervals are in seconds and positive intervals in days.
+
+
+ Sample request 1:
+
+ ```json
+ {
+ "action": "getIntervals",
+ "version": 6,
+ "params": {
+ "cards": [1502298033753, 1502298036657]
+ }
+ }
+ ```
+
+
+
+ Sample result 1:
+
+ ```json
+ {
+ "result": [-14400, 3],
+ "error": null
+ }
+ ```
+
+
+
+ Sample request 2:
+
+ ```json
+ {
+ "action": "getIntervals",
+ "version": 6,
+ "params": {
+ "cards": [1502298033753, 1502298036657],
+ "complete": true
+ }
+ }
+ ```
+
+
+
+ Sample result 2:
+
+ ```json
+ {
+ "result": [
+ [-120, -180, -240, -300, -360, -14400],
+ [-120, -180, -240, -300, -360, -14400, 1, 3]
+ ],
+ "error": null
+ }
+ ```
+
+
+#### `findCards`
+
+* Returns an array of card IDs for a given query. Functionally identical to `guiBrowse` but doesn't use the GUI for
+ better performance.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "findCards",
+ "version": 6,
+ "params": {
+ "query": "deck:current"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": [1494723142483, 1494703460437, 1494703479525],
+ "error": null
+ }
+ ```
+
+
+#### `cardsToNotes`
+
+* Returns an unordered array of note IDs for the given card IDs. For cards with the same note, the ID is only given
+ once in the array.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "cardsToNotes",
+ "version": 6,
+ "params": {
+ "cards": [1502098034045, 1502098034048, 1502298033753]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": [1502098029797, 1502298025183],
+ "error": null
+ }
+ ```
+
+
+#### `cardsModTime`
+
+* Returns a list of objects containings for each card ID the modification time.
+ This function is about 15 times faster than executing `cardsInfo`.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "cardsModTime",
+ "version": 6,
+ "params": {
+ "cards": [1498938915662, 1502098034048]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": [
+ {
+ "cardId": 1498938915662,
+ "mod": 1629454092
+ }
+ ],
+ "error": null
+ }
+ ```
+
+
+
+#### `cardsInfo`
+
+* Returns a list of objects containing for each card ID the card fields, front and back sides including CSS, note
+ type, the note that the card belongs to, and deck name, last modification timestamp as well as ease and interval.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "cardsInfo",
+ "version": 6,
+ "params": {
+ "cards": [1498938915662, 1502098034048]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": [
+ {
+ "answer": "back content",
+ "question": "front content",
+ "deckName": "Default",
+ "modelName": "Basic",
+ "fieldOrder": 1,
+ "fields": {
+ "Front": {"value": "front content", "order": 0},
+ "Back": {"value": "back content", "order": 1}
+ },
+ "css":"p {font-family:Arial;}",
+ "cardId": 1498938915662,
+ "interval": 16,
+ "note":1502298033753,
+ "ord": 1,
+ "type": 0,
+ "queue": 0,
+ "due": 1,
+ "reps": 1,
+ "lapses": 0,
+ "left": 6,
+ "mod": 1629454092
+ },
+ {
+ "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}
+ },
+ "css":"p {font-family:Arial;}",
+ "cardId": 1502098034048,
+ "interval": 23,
+ "note":1502298033753,
+ "ord": 1,
+ "type": 0,
+ "queue": 0,
+ "due": 1,
+ "reps": 1,
+ "lapses": 0,
+ "left": 6
+ }
+ ],
+ "error": null
+ }
+ ```
+
+
+#### `forgetCards`
+
+* Forget cards, making the cards new again.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "forgetCards",
+ "version": 6,
+ "params": {
+ "cards": [1498938915662, 1502098034048]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `relearnCards`
+
+* Make cards be "relearning".
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "relearnCards",
+ "version": 6,
+ "params": {
+ "cards": [1498938915662, 1502098034048]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `answerCards`
+
+* Answer cards. Ease is between 1 (Again) and 4 (Easy). Will start the timer immediately before answering. Returns `true` if card exists, `false` otherwise.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "answerCards",
+ "version": 6,
+ "params": {
+ "answers": [
+ {
+ "cardId": 1498938915662,
+ "ease": 2
+ },
+ {
+ "cardId": 1502098034048,
+ "ease": 4
+ }
+ ]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": [true, true],
+ "error": null
+ }
+ ```
+
+
+#### `setDueDate`
+
+* Set Due Date. Turns cards into review cards if they are new, and makes them due on a certain date.
+ * 0 = today
+ * 1! = tomorrow + change interval to 1
+ * 3-7 = random choice of 3-7 days
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "setDueDate",
+ "version": 6,
+ "params": {
+ "cards": [1498938915662, 1502098034048],
+ "days": "3-7"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
+---
+
+### Deck Actions
+
+#### `deckNames`
+
+* Gets the complete list of deck names for the current user.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "deckNames",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": ["Default"],
+ "error": null
+ }
+ ```
+
+
+#### `deckNamesAndIds`
+
+* Gets the complete list of deck names and their respective IDs for the current user.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "deckNamesAndIds",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": {"Default": 1},
+ "error": null
+ }
+ ```
+
+
+#### `getDecks`
+
+* Accepts an array of card IDs and returns an object with each deck name as a key, and its value an array of the given
+ cards which belong to it.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "getDecks",
+ "version": 6,
+ "params": {
+ "cards": [1502298036657, 1502298033753, 1502032366472]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": {
+ "Default": [1502032366472],
+ "Japanese::JLPT N3": [1502298036657, 1502298033753]
+ },
+ "error": null
+ }
+ ```
+
+
+#### `createDeck`
+
+* Create a new empty deck. Will not overwrite a deck that exists with the same name.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "createDeck",
+ "version": 6,
+ "params": {
+ "deck": "Japanese::Tokyo"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": 1519323742721,
+ "error": null
+ }
+ ```
+
+
+#### `changeDeck`
+
+* Moves cards with the given IDs to a different deck, creating the deck if it doesn't exist yet.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "changeDeck",
+ "version": 6,
+ "params": {
+ "cards": [1502098034045, 1502098034048, 1502298033753],
+ "deck": "Japanese::JLPT N3"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `deleteDecks`
+
+* Deletes decks with the given names.
+ The argument `cardsToo` *must* be specified and set to `true`.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "deleteDecks",
+ "version": 6,
+ "params": {
+ "decks": ["Japanese::JLPT N5", "Easy Spanish"],
+ "cardsToo": true
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `getDeckConfig`
+
+* Gets the configuration group object for the given deck.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "getDeckConfig",
+ "version": 6,
+ "params": {
+ "deck": "Default"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": {
+ "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
+ },
+ "error": null
+ }
+ ```
+
+
+#### `saveDeckConfig`
+
+* Saves the given configuration group, returning `true` on success or `false` if the ID of the configuration group is
+ invalid (such as when it does not exist).
+
+
+ Sample request:
+
+ ```json
+ {
+ "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
+ }
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
+#### `setDeckConfigId`
+
+* Changes the configuration group for the given decks to the one with the given ID. Returns `true` on success or
+ `false` if the given configuration group or any of the given decks do not exist.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "setDeckConfigId",
+ "version": 6,
+ "params": {
+ "decks": ["Default"],
+ "configId": 1
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
+#### `cloneDeckConfigId`
+
+* Creates a new configuration group with the given name, cloning from the group with the given ID, or from the default
+ group if this is unspecified. Returns the ID of the new configuration group, or `false` if the specified group to
+ clone from does not exist.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "cloneDeckConfigId",
+ "version": 6,
+ "params": {
+ "name": "Copy of Default",
+ "cloneFrom": 1
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": 1502972374573,
+ "error": null
+ }
+ ```
+
+
+#### `removeDeckConfigId`
+
+* Removes the configuration group with the given ID, returning `true` if successful, or `false` if attempting to
+ remove either the default configuration group (ID = 1) or a configuration group that does not exist.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "removeDeckConfigId",
+ "version": 6,
+ "params": {
+ "configId": 1502972374573
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
+#### `getDeckStats`
+
+* Gets statistics such as total cards and cards due for the given decks.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "getDeckStats",
+ "version": 6,
+ "params": {
+ "decks": ["Japanese::JLPT N5", "Easy Spanish"]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": {
+ "1651445861967": {
+ "deck_id": 1651445861967,
+ "name": "Japanese::JLPT N5",
+ "new_count": 20,
+ "learn_count": 0,
+ "review_count": 0,
+ "total_in_deck": 1506
+ },
+ "1651445861960": {
+ "deck_id": 1651445861960,
+ "name": "Easy Spanish",
+ "new_count": 26,
+ "learn_count": 10,
+ "review_count": 5,
+ "total_in_deck": 852
+ }
+ },
+ "error": null
+ }
+ ```
+
+
+---
+
+### 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](https://docs.ankiweb.net/searching.html).
+
+ Optionally, the `reorderCards` property can be provided to reorder the cards shown in the *Card Browser*.
+ This is an array including the `order` and `columnId` objects. `order` can be either `ascending` or `descending` while `columnId` can be one of several column identifiers (as documented in the [Anki source code](https://github.com/ankitects/anki/blob/main/rslib/src/browser_table.rs)).
+ The specified column needs to be visible in the *Card Browser*.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "guiBrowse",
+ "version": 6,
+ "params": {
+ "query": "deck:current",
+ "reorderCards": {
+ "order": "descending",
+ "columnId": "noteCrt"
+ }
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": [1494723142483, 1494703460437, 1494703479525],
+ "error": null
+ }
+ ```
+
+
+#### `guiSelectCard`
+
+* Finds the open instance of the *Card Browser* dialog and selects a card given a card identifier.
+ Returns `true` if the *Card Browser* is open, `false` otherwise.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "guiSelectCard",
+ "version": 6,
+ "params": {
+ "card": 1494723142483
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
+#### `guiSelectedNotes`
+
+* Finds the open instance of the *Card Browser* dialog and returns an array of identifiers of the notes that are
+ selected. Returns an empty list if the browser is not open.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "guiSelectedNotes",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "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.
+
+ Audio, video, and picture files can be embedded into the fields via the `audio`, `video`, and `picture` keys, respectively.
+ Refer to the documentation of `addNote` and `storeMediaFile` for an explanation of these fields.
+
+ The result is the ID of the note which would be added, if the user chose to confirm the *Add Cards* dialogue.
+
+
+ Sample request:
+
+ ```json
+ {
+ "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"
+ ],
+ "picture": [{
+ "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/1/13/EU-Romania.svg/285px-EU-Romania.svg.png",
+ "filename": "romania.png",
+ "fields": [
+ "Extra"
+ ]
+ }]
+ }
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": 1496198395707,
+ "error": null
+ }
+ ```
+
+
+#### `guiEditNote`
+
+* Opens the *Edit* dialog with a note corresponding to given note ID.
+ The dialog is similar to the *Edit Current* dialog, but:
+
+ * has a Preview button to preview the cards for the note
+ * has a Browse button to open the browser with these cards
+ * has Previous/Back buttons to navigate the history of the dialog
+ * has no bar with the Close button
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "guiEditNote",
+ "version": 6,
+ "params": {
+ "note": 1649198355435
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `guiCurrentCard`
+
+* Returns information about the current card or `null` if not in review mode.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "guiCurrentCard",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "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:
+
+ ```json
+ {
+ "action": "guiStartCardTimer",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
+#### `guiShowQuestion`
+
+* Shows question text for the current card; returns `true` if in review mode or `false` otherwise.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "guiShowQuestion",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
+#### `guiShowAnswer`
+
+* Shows answer text for the current card; returns `true` if in review mode or `false` otherwise.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "guiShowAnswer",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "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:
+
+ ```json
+ {
+ "action": "guiAnswerCard",
+ "version": 6,
+ "params": {
+ "ease": 1
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
+#### `guiUndo`
+
+* Undo the last action / card; returns `true` if succeeded or `false` otherwise.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "guiUndo",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "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:
+
+ ```json
+ {
+ "action": "guiDeckOverview",
+ "version": 6,
+ "params": {
+ "name": "Default"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
+#### `guiDeckBrowser`
+
+* Opens the *Deck Browser* dialog.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "guiDeckBrowser",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `guiDeckReview`
+
+* Starts review for the deck with the given name; returns `true` if succeeded or `false` otherwise.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "guiDeckReview",
+ "version": 6,
+ "params": {
+ "name": "Default"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
+#### `guiImportFile`
+
+* Invokes the *Import... (Ctrl+Shift+I)* dialog with an optional file path. Brings up the dialog for user to review the import. Supports all file types that Anki supports. Brings open file dialog if no path is provided. Forward slashes must be used in the path on Windows. Only supported for Anki 2.1.52+.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "guiImportFile",
+ "version": 6,
+ "params": {
+ "path": "C:/Users/Desktop/cards.txt"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "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:
+
+ ```json
+ {
+ "action": "guiExitAnki",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `guiCheckDatabase`
+
+* Requests a database check, but returns immediately without waiting for the check to complete. Therefore, the action will always return `true` even if errors are detected during the database check.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "guiCheckDatabase",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
+---
+
+### Media Actions
+
+#### `storeMediaFile`
+
+* Stores a file with the specified base64-encoded contents inside the media folder. Alternatively you can specify a
+ absolute file path, or a url from where the file shell be downloaded. If more than one of `data`, `path` and `url` are provided, the `data` field will be used first, then `path`, and finally `url`. To prevent Anki from removing files not used by any cards (e.g. for configuration files), prefix the filename with an underscore. These files are still synchronized to AnkiWeb.
+ Any existing file with the same name is deleted by default. Set `deleteExisting` to false to prevent that
+ by [letting Anki give the new file a non-conflicting name](https://github.com/ankitects/anki/blob/aeba725d3ea9628c73300648f748140db3fdd5ed/rslib/src/media/files.rs#L194).
+
+
+ Sample request (relative path):
+
+ ```json
+ {
+ "action": "storeMediaFile",
+ "version": 6,
+ "params": {
+ "filename": "_hello.txt",
+ "data": "SGVsbG8sIHdvcmxkIQ=="
+ }
+ }
+ ```
+
+ *Content of `_hello.txt`*:
+
+ ```
+ Hello world!
+ ```
+
+
+
+ Sample result (relative path):
+
+ ```json
+ {
+ "result": "_hello.txt",
+ "error": null
+ }
+ ```
+
+
+
+ Sample request (absolute path):
+
+ ```json
+ {
+ "action": "storeMediaFile",
+ "version": 6,
+ "params": {
+ "filename": "_hello.txt",
+ "path": "/path/to/file"
+ }
+ }
+ ```
+
+
+
+ Sample result (absolute path):
+
+ ```json
+ {
+ "result": "_hello.txt",
+ "error": null
+ }
+ ```
+
+
+
+ Sample request (url):
+
+ ```json
+ {
+ "action": "storeMediaFile",
+ "version": 6,
+ "params": {
+ "filename": "_hello.txt",
+ "url": "https://url.to.file"
+ }
+ }
+ ```
+
+
+
+ Sample result (url):
+
+ ```json
+ {
+ "result": "_hello.txt",
+ "error": null
+ }
+ ```
+
+
+#### `retrieveMediaFile`
+
+* Retrieves the base64-encoded contents of the specified file, returning `false` if the file does not exist.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "retrieveMediaFile",
+ "version": 6,
+ "params": {
+ "filename": "_hello.txt"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": "SGVsbG8sIHdvcmxkIQ==",
+ "error": null
+ }
+ ```
+
+
+#### `getMediaFilesNames`
+
+* Gets the names of media files matched the pattern. Returning all names by default.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "getMediaFilesNames",
+ "version": 6,
+ "params": {
+ "pattern": "_hell*.txt"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": ["_hello.txt"],
+ "error": null
+ }
+ ```
+
+
+#### `getMediaDirPath`
+
+* Gets the full path to the `collection.media` folder of the currently opened profile.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "getMediaDirPath",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": "/home/user/.local/share/Anki2/Main/collection.media",
+ "error": null
+ }
+ ```
+
+
+#### `deleteMediaFile`
+
+* Deletes the specified file inside the media folder.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "deleteMediaFile",
+ "version": 6,
+ "params": {
+ "filename": "_hello.txt"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+---
+
+### Miscellaneous Actions
+
+#### `requestPermission`
+
+* Requests permission to use the API exposed by this plugin. This method does not require the API key, and is the
+ only one that accepts requests from any origin; the other methods only accept requests from trusted origins,
+ which are listed under `webCorsOriginList` in the add-on config. `localhost` is trusted by default.
+
+ Calling this method from an untrusted origin will display a popup in Anki asking the user whether they want to
+ allow your origin to use the API; calls from trusted origins will return the result without displaying the popup.
+ When denying permission, the user may also choose to ignore further permission requests from that origin. These
+ origins end up in the `ignoreOriginList`, editable via the add-on config.
+
+ The result always contains the `permission` field, which in turn contains either the string `granted` or `denied`,
+ corresponding to whether your origin is trusted. If your origin is trusted, the fields `requireApiKey` (`true` if
+ required) and `version` will also be returned.
+
+ This should be the first call you make to make sure that your application and Anki-Connect are able to communicate
+ properly with each other. New versions of Anki-Connect are backwards compatible; as long as you are using actions
+ which are available in the reported Anki-Connect version or earlier, everything should work fine.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "requestPermission",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample results:
+
+ ```json
+ {
+ "result": {
+ "permission": "granted",
+ "requireApiKey": false,
+ "version": 6
+ },
+ "error": null
+ }
+ ```
+
+ ```json
+ {
+ "result": {
+ "permission": "denied"
+ },
+ "error": null
+ }
+ ```
+
+
+#### `version`
+
+* Gets the version of the API exposed by this plugin. Currently versions `1` through `6` are defined.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "version",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": 6,
+ "error": null
+ }
+ ```
+
+
+
+#### `apiReflect`
+
+* Gets information about the AnkiConnect APIs available. The request supports the following params:
+
+ * `scopes` - An array of scopes to get reflection information about.
+ The only currently supported value is `"actions"`.
+ * `actions` - Either `null` or an array of API method names to check for.
+ If the value is `null`, the result will list all of the available API actions.
+ If the value is an array of strings, the result will only contain actions which were in this array.
+
+ The result will contain a list of which scopes were used and a value for each scope.
+ For example, the `"actions"` scope will contain a `"actions"` property which contains a list of supported action names.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "apiReflect",
+ "version": 6,
+ "params": {
+ "scopes": ["actions", "invalidType"],
+ "actions": ["apiReflect", "invalidMethod"]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": {
+ "scopes": ["actions"],
+ "actions": ["apiReflect"]
+ },
+ "error": null
+ }
+ ```
+
+
+#### `sync`
+
+* Synchronizes the local Anki collections with AnkiWeb.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "sync",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `getProfiles`
+
+* Retrieve the list of profiles.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "getProfiles",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": ["User 1"],
+ "error": null
+ }
+ ```
+
+
+#### `getActiveProfile`
+
+* Retrieve the active profile.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "getActiveProfile",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": "User 1",
+ "error": null
+ }
+ ```
+
+
+
+#### `loadProfile`
+
+* Selects the profile specified in request.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "loadProfile",
+ "version": 6,
+ "params": {
+ "name": "user1"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
+#### `multi`
+
+* Performs multiple actions in one request, returning an array with the response of each action (in the given order).
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "multi",
+ "version": 6,
+ "params": {
+ "actions": [
+ {
+ "action": "deckNames"
+ },
+ {
+ "action": "deckNames",
+ "version": 6
+ },
+ {
+ "action": "invalidAction",
+ "params": {"useless": "param"}
+ },
+ {
+ "action": "invalidAction",
+ "params": {"useless": "param"},
+ "version": 6
+ }
+ ]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": [
+ ["Default"],
+ {"result": ["Default"], "error": null},
+ {"result": null, "error": "unsupported action"},
+ {"result": null, "error": "unsupported action"}
+ ],
+ "error": null
+ }
+ ```
+
+
+#### `exportPackage`
+
+* Exports a given deck in `.apkg` format. Returns `true` if successful or `false` otherwise. The optional property
+ `includeSched` (default is `false`) can be specified to include the cards' scheduling data.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "exportPackage",
+ "version": 6,
+ "params": {
+ "deck": "Default",
+ "path": "/data/Deck.apkg",
+ "includeSched": true
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
+#### `importPackage`
+
+* Imports a file in `.apkg` format into the collection. Returns `true` if successful or `false` otherwise.
+ Note that the file path is relative to Anki's collection.media folder, not to the client.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "importPackage",
+ "version": 6,
+ "params": {
+ "path": "/data/Deck.apkg"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
+#### `reloadCollection`
+
+* Tells anki to reload all data from the database.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "reloadCollection",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+---
+
+### Model Actions
+
+#### `modelNames`
+
+* Gets the complete list of model names for the current user.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "modelNames",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": ["Basic", "Basic (and reversed card)"],
+ "error": null
+ }
+ ```
+
+
+#### `modelNamesAndIds`
+
+* Gets the complete list of model names and their corresponding IDs for the current user.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "modelNamesAndIds",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": {
+ "Basic": 1483883011648,
+ "Basic (and reversed card)": 1483883011644,
+ "Basic (optional reversed card)": 1483883011631,
+ "Cloze": 1483883011630
+ },
+ "error": null
+ }
+ ```
+
+
+#### `findModelsById`
+
+* Gets a list of models for the provided model IDs from the current user.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "findModelsById",
+ "version": 6,
+ "params": {
+ "modelIds": [1704387367119, 1704387398570]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": [
+ {
+ "id": 1704387367119,
+ "name": "Basic",
+ "type": 0,
+ "mod": 1704387367,
+ "usn": -1,
+ "sortf": 0,
+ "did": null,
+ "tmpls": [
+ {
+ "name": "Card 1",
+ "ord": 0,
+ "qfmt": "{{Front}}",
+ "afmt": "{{FrontSide}}\n\n
\n\n{{Back}}",
+ "bqfmt": "",
+ "bafmt": "",
+ "did": null,
+ "bfont": "",
+ "bsize": 0,
+ "id": 9176047152973362695
+ }
+ ],
+ "flds": [
+ {
+ "name": "Front",
+ "ord": 0,
+ "sticky": false,
+ "rtl": false,
+ "font": "Arial",
+ "size": 20,
+ "description": "",
+ "plainText": false,
+ "collapsed": false,
+ "excludeFromSearch": false,
+ "id": 2453723143453745216,
+ "tag": null,
+ "preventDeletion": false
+ },
+ {
+ "name": "Back",
+ "ord": 1,
+ "sticky": false,
+ "rtl": false,
+ "font": "Arial",
+ "size": 20,
+ "description": "",
+ "plainText": false,
+ "collapsed": false,
+ "excludeFromSearch": false,
+ "id": -4853200230425436781,
+ "tag": null,
+ "preventDeletion": false
+ }
+ ],
+ "css": ".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n",
+ "latexPre": "\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n",
+ "latexPost": "\\end{document}",
+ "latexsvg": false,
+ "req": [
+ [
+ 0,
+ "any",
+ [
+ 0
+ ]
+ ]
+ ],
+ "originalStockKind": 1
+ },
+ {
+ "id": 1704387398570,
+ "name": "Basic (and reversed card)",
+ "type": 0,
+ "mod": 1704387398,
+ "usn": -1,
+ "sortf": 0,
+ "did": null,
+ "tmpls": [
+ {
+ "name": "Card 1",
+ "ord": 0,
+ "qfmt": "{{Front}}",
+ "afmt": "{{FrontSide}}\n\n
\n\n{{Back}}",
+ "bqfmt": "",
+ "bafmt": "",
+ "did": null,
+ "bfont": "",
+ "bsize": 0,
+ "id": 1689886528158874152
+ },
+ {
+ "name": "Card 2",
+ "ord": 1,
+ "qfmt": "{{Back}}",
+ "afmt": "{{FrontSide}}\n\n
\n\n{{Front}}",
+ "bqfmt": "",
+ "bafmt": "",
+ "did": null,
+ "bfont": "",
+ "bsize": 0,
+ "id": -7839609225644824587
+ }
+ ],
+ "flds": [
+ {
+ "name": "Front",
+ "ord": 0,
+ "sticky": false,
+ "rtl": false,
+ "font": "Arial",
+ "size": 20,
+ "description": "",
+ "plainText": false,
+ "collapsed": false,
+ "excludeFromSearch": false,
+ "id": -7787837672455357996,
+ "tag": null,
+ "preventDeletion": false
+ },
+ {
+ "name": "Back",
+ "ord": 1,
+ "sticky": false,
+ "rtl": false,
+ "font": "Arial",
+ "size": 20,
+ "description": "",
+ "plainText": false,
+ "collapsed": false,
+ "excludeFromSearch": false,
+ "id": 6364828289839985081,
+ "tag": null,
+ "preventDeletion": false
+ }
+ ],
+ "css": ".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n",
+ "latexPre": "\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n",
+ "latexPost": "\\end{document}",
+ "latexsvg": false,
+ "req": [
+ [
+ 0,
+ "any",
+ [
+ 0
+ ]
+ ],
+ [
+ 1,
+ "any",
+ [
+ 1
+ ]
+ ]
+ ],
+ "originalStockKind": 1
+ }
+ ],
+ "error": null
+ }
+ ```
+
+
+
+#### `findModelsByName`
+
+* Gets a list of models for the provided model names from the current user.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "findModelsByName",
+ "version": 6,
+ "params": {
+ "modelNames": ["Basic", "Basic (and reversed card)"]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": [
+ {
+ "id": 1704387367119,
+ "name": "Basic",
+ "type": 0,
+ "mod": 1704387367,
+ "usn": -1,
+ "sortf": 0,
+ "did": null,
+ "tmpls": [
+ {
+ "name": "Card 1",
+ "ord": 0,
+ "qfmt": "{{Front}}",
+ "afmt": "{{FrontSide}}\n\n
\n\n{{Back}}",
+ "bqfmt": "",
+ "bafmt": "",
+ "did": null,
+ "bfont": "",
+ "bsize": 0,
+ "id": 9176047152973362695
+ }
+ ],
+ "flds": [
+ {
+ "name": "Front",
+ "ord": 0,
+ "sticky": false,
+ "rtl": false,
+ "font": "Arial",
+ "size": 20,
+ "description": "",
+ "plainText": false,
+ "collapsed": false,
+ "excludeFromSearch": false,
+ "id": 2453723143453745216,
+ "tag": null,
+ "preventDeletion": false
+ },
+ {
+ "name": "Back",
+ "ord": 1,
+ "sticky": false,
+ "rtl": false,
+ "font": "Arial",
+ "size": 20,
+ "description": "",
+ "plainText": false,
+ "collapsed": false,
+ "excludeFromSearch": false,
+ "id": -4853200230425436781,
+ "tag": null,
+ "preventDeletion": false
+ }
+ ],
+ "css": ".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n",
+ "latexPre": "\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n",
+ "latexPost": "\\end{document}",
+ "latexsvg": false,
+ "req": [
+ [
+ 0,
+ "any",
+ [
+ 0
+ ]
+ ]
+ ],
+ "originalStockKind": 1
+ },
+ {
+ "id": 1704387398570,
+ "name": "Basic (and reversed card)",
+ "type": 0,
+ "mod": 1704387398,
+ "usn": -1,
+ "sortf": 0,
+ "did": null,
+ "tmpls": [
+ {
+ "name": "Card 1",
+ "ord": 0,
+ "qfmt": "{{Front}}",
+ "afmt": "{{FrontSide}}\n\n
\n\n{{Back}}",
+ "bqfmt": "",
+ "bafmt": "",
+ "did": null,
+ "bfont": "",
+ "bsize": 0,
+ "id": 1689886528158874152
+ },
+ {
+ "name": "Card 2",
+ "ord": 1,
+ "qfmt": "{{Back}}",
+ "afmt": "{{FrontSide}}\n\n
\n\n{{Front}}",
+ "bqfmt": "",
+ "bafmt": "",
+ "did": null,
+ "bfont": "",
+ "bsize": 0,
+ "id": -7839609225644824587
+ }
+ ],
+ "flds": [
+ {
+ "name": "Front",
+ "ord": 0,
+ "sticky": false,
+ "rtl": false,
+ "font": "Arial",
+ "size": 20,
+ "description": "",
+ "plainText": false,
+ "collapsed": false,
+ "excludeFromSearch": false,
+ "id": -7787837672455357996,
+ "tag": null,
+ "preventDeletion": false
+ },
+ {
+ "name": "Back",
+ "ord": 1,
+ "sticky": false,
+ "rtl": false,
+ "font": "Arial",
+ "size": 20,
+ "description": "",
+ "plainText": false,
+ "collapsed": false,
+ "excludeFromSearch": false,
+ "id": 6364828289839985081,
+ "tag": null,
+ "preventDeletion": false
+ }
+ ],
+ "css": ".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n",
+ "latexPre": "\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n",
+ "latexPost": "\\end{document}",
+ "latexsvg": false,
+ "req": [
+ [
+ 0,
+ "any",
+ [
+ 0
+ ]
+ ],
+ [
+ 1,
+ "any",
+ [
+ 1
+ ]
+ ]
+ ],
+ "originalStockKind": 1
+ }
+ ],
+ "error": null
+ }
+ ```
+
+
+#### `modelFieldNames`
+
+* Gets the complete list of field names for the provided model name.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "modelFieldNames",
+ "version": 6,
+ "params": {
+ "modelName": "Basic"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": ["Front", "Back"],
+ "error": null
+ }
+ ```
+
+
+#### `modelFieldDescriptions`
+
+* Gets the complete list of field descriptions (the text seen in the gui editor when a field is empty) for the provided model name.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "modelFieldDescriptions",
+ "version": 6,
+ "params": {
+ "modelName": "Basic"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": ["", ""],
+ "error": null
+ }
+ ```
+
+
+#### `modelFieldFonts`
+
+* Gets the complete list of fonts along with their font sizes.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "modelFieldFonts",
+ "version": 6,
+ "params": {
+ "modelName": "Basic"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": {
+ "Front": {
+ "font": "Arial",
+ "size": 20
+ },
+ "Back": {
+ "font": "Arial",
+ "size": 20
+ }
+ },
+ "error": null
+ }
+ ```
+
+
+#### `modelFieldsOnTemplates`
+
+* Returns an object indicating the fields on the question and answer side of each card template for the given model
+ name. The question side is given first in each array.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "modelFieldsOnTemplates",
+ "version": 6,
+ "params": {
+ "modelName": "Basic (and reversed card)"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": {
+ "Card 1": [["Front"], ["Back"]],
+ "Card 2": [["Back"], ["Front"]]
+ },
+ "error": null
+ }
+ ```
+
+
+#### `createModel`
+
+* Creates a new model to be used in Anki. User must provide the `modelName`, `inOrderFields` and `cardTemplates` to be
+ used in the model. There are optional fields `css` and `isCloze`. If not specified, `css` will use the default Anki css and `isCloze` will be equal to `false`. If `isCloze` is `true` then model will be created as Cloze.
+
+ Optionally the `Name` field can be provided for each entry of `cardTemplates`. By default the
+ card names will be `Card 1`, `Card 2`, and so on.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "createModel",
+ "version": 6,
+ "params": {
+ "modelName": "newModelName",
+ "inOrderFields": ["Field1", "Field2", "Field3"],
+ "css": "Optional CSS with default to builtin css",
+ "isCloze": false,
+ "cardTemplates": [
+ {
+ "Name": "My Card 1",
+ "Front": "Front html {{Field1}}",
+ "Back": "Back html {{Field2}}"
+ }
+ ]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result":{
+ "sortf":0,
+ "did":1,
+ "latexPre":"\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n",
+ "latexPost":"\\end{document}",
+ "mod":1551462107,
+ "usn":-1,
+ "vers":[
+
+ ],
+ "type":0,
+ "css":".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n",
+ "name":"TestApiModel",
+ "flds":[
+ {
+ "name":"Field1",
+ "ord":0,
+ "sticky":false,
+ "rtl":false,
+ "font":"Arial",
+ "size":20,
+ "media":[
+
+ ]
+ },
+ {
+ "name":"Field2",
+ "ord":1,
+ "sticky":false,
+ "rtl":false,
+ "font":"Arial",
+ "size":20,
+ "media":[
+
+ ]
+ }
+ ],
+ "tmpls":[
+ {
+ "name":"My Card 1",
+ "ord":0,
+ "qfmt":"",
+ "afmt":"This is the back of the card {{Field2}}",
+ "did":null,
+ "bqfmt":"",
+ "bafmt":""
+ }
+ ],
+ "tags":[
+
+ ],
+ "id":1551462107104,
+ "req":[
+ [
+ 0,
+ "none",
+ [
+
+ ]
+ ]
+ ]
+ },
+ "error":null
+ }
+ ```
+
+
+#### `modelTemplates`
+
+* Returns an object indicating the template content for each card connected to the provided model by name.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "modelTemplates",
+ "version": 6,
+ "params": {
+ "modelName": "Basic (and reversed card)"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": {
+ "Card 1": {
+ "Front": "{{Front}}",
+ "Back": "{{FrontSide}}\n\n
\n\n{{Back}}"
+ },
+ "Card 2": {
+ "Front": "{{Back}}",
+ "Back": "{{FrontSide}}\n\n
\n\n{{Front}}"
+ }
+ },
+ "error": null
+ }
+ ```
+
+
+#### `modelStyling`
+
+* Gets the CSS styling for the provided model by name.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "modelStyling",
+ "version": 6,
+ "params": {
+ "modelName": "Basic (and reversed card)"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": {
+ "css": ".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n"
+ },
+ "error": null
+ }
+ ```
+
+
+#### `updateModelTemplates`
+
+* Modify the templates of an existing model by name. Only specifies cards and specified sides will be modified.
+ If an existing card or side is not included in the request, it will be left unchanged.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "updateModelTemplates",
+ "version": 6,
+ "params": {
+ "model": {
+ "name": "Custom",
+ "templates": {
+ "Card 1": {
+ "Front": "{{Question}}?",
+ "Back": "{{Answer}}!"
+ }
+ }
+ }
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `updateModelStyling`
+
+* Modify the CSS styling of an existing model by name.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "updateModelStyling",
+ "version": 6,
+ "params": {
+ "model": {
+ "name": "Custom",
+ "css": "p { color: blue; }"
+ }
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `findAndReplaceInModels`
+
+* Find and replace string in existing model by model name. Customise to replace in front, back or css by setting to true/false.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "findAndReplaceInModels",
+ "version": 6,
+ "params": {
+ "model": {
+ "modelName": "",
+ "findText": "text_to_replace",
+ "replaceText": "replace_with_text",
+ "front": true,
+ "back": true,
+ "css": true
+ }
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": 1,
+ "error": null
+ }
+ ```
+
+
+#### `modelTemplateRename`
+
+* Renames a template in an existing model.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "modelTemplateRename",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "oldTemplateName": "Card 1",
+ "newTemplateName": "Card 1 renamed"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `modelTemplateReposition`
+
+* Repositions a template in an existing model.
+
+ The value of `index` starts at 0. For example, an index of `0` puts the template in the first position, and an index of `2` puts the template in the third position.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "modelTemplateReposition",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "templateName": "Card 1",
+ "index": 1
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `modelTemplateAdd`
+
+* Adds a template to an existing model by name. If you want to update an existing template, use `updateModelTemplates`.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "modelTemplateAdd",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "template": {
+ "Name": "Card 3",
+ "Front": "Front html {{Field1}}",
+ "Back": "Back html {{Field2}}"
+ }
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `modelTemplateRemove`
+
+* Removes a template from an existing model.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "modelTemplateRemove",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "templateName": "Card 1"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `modelFieldRename`
+
+* Rename the field name of a given model.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "modelFieldRename",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "oldFieldName": "Front",
+ "newFieldName": "FrontRenamed"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `modelFieldReposition`
+
+* Reposition the field within the field list of a given model.
+
+ The value of `index` starts at 0. For example, an index of `0` puts the field in the first position, and an index of `2` puts the field in the third position.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "modelFieldReposition",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "fieldName": "Back",
+ "index": 0
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `modelFieldAdd`
+
+* Creates a new field within a given model.
+
+ Optionally, the `index` value can be provided, which works exactly the same as the index in `modelFieldReposition`. By default, the field is added to the end of the field list.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "modelFieldAdd",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "fieldName": "NewField",
+ "index": 0
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `modelFieldRemove`
+
+* Deletes a field within a given model.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "modelFieldRemove",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "fieldName": "Front"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `modelFieldSetFont`
+
+* Sets the font for a field within a given model.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "modelFieldSetFont",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "fieldName": "Front",
+ "font": "Courier"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `modelFieldSetFontSize`
+
+* Sets the font size for a field within a given model.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "modelFieldSetFontSize",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "fieldName": "Front",
+ "fontSize": 10
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `modelFieldSetDescription`
+
+* Sets the description (the text seen in the gui editor when a field is empty) for a field within a given model.
+
+ Older versions of Anki (2.1.49 and below) do not have field descriptions. In that case, this will return with `false`.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "modelFieldSetDescription",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "fieldName": "Front",
+ "description": "example field description"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
+---
+
+### Note Actions
+
+#### `addNote`
+
+* Creates a note using the given deck and model, with the provided field values and tags. Returns the identifier of
+ the created note created on success, and `null` on failure.
+
+ Anki-Connect can download audio, video, and picture files and embed them in newly created notes. The corresponding `audio`, `video`, and `picture` note members are
+ optional and can be omitted. If you choose to include any of them, they should contain a single object or an array of objects
+ with the mandatory `filename` field and one of `data`, `path` or `url`. Refer to the documentation of `storeMediaFile` for an explanation of these fields.
+ The `skipHash` field can be optionally provided to skip the inclusion of files with an MD5 hash that matches the provided value.
+ This is useful for avoiding the saving of error pages and stub files.
+ The `fields` member is a list of fields that should play audio or video, or show a picture when the card is displayed in
+ Anki. The `allowDuplicate` member inside `options` group can be set to true to enable adding duplicate cards.
+ Normally duplicate cards can not be added and trigger exception.
+
+ The `duplicateScope` member inside `options` can be used to specify the scope for which duplicates are checked.
+ A value of `"deck"` will only check for duplicates in the target deck; any other value will check the entire collection.
+
+ The `duplicateScopeOptions` object can be used to specify some additional settings:
+
+ * `duplicateScopeOptions.deckName` will specify which deck to use for checking duplicates in. If undefined or `null`, the target deck will be used.
+ * `duplicateScopeOptions.checkChildren` will change whether or not duplicate cards are checked in child decks. The default value is `false`.
+ * `duplicateScopeOptions.checkAllModels` specifies whether duplicate checks are performed across all note types. The default value is `false`.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "addNote",
+ "version": 6,
+ "params": {
+ "note": {
+ "deckName": "Default",
+ "modelName": "Basic",
+ "fields": {
+ "Front": "front content",
+ "Back": "back content"
+ },
+ "options": {
+ "allowDuplicate": false,
+ "duplicateScope": "deck",
+ "duplicateScopeOptions": {
+ "deckName": "Default",
+ "checkChildren": false,
+ "checkAllModels": false
+ }
+ },
+ "tags": [
+ "yomichan"
+ ],
+ "audio": [{
+ "url": "https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kanji=猫&kana=ねこ",
+ "filename": "yomichan_ねこ_猫.mp3",
+ "skipHash": "7e2c2f954ef6051373ba916f000168dc",
+ "fields": [
+ "Front"
+ ]
+ }],
+ "video": [{
+ "url": "https://cdn.videvo.net/videvo_files/video/free/2015-06/small_watermarked/Contador_Glam_preview.mp4",
+ "filename": "countdown.mp4",
+ "skipHash": "4117e8aab0d37534d9c8eac362388bbe",
+ "fields": [
+ "Back"
+ ]
+ }],
+ "picture": [{
+ "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c7/A_black_cat_named_Tilly.jpg/220px-A_black_cat_named_Tilly.jpg",
+ "filename": "black_cat.jpg",
+ "skipHash": "8d6e4646dfae812bf39651b59d7429ce",
+ "fields": [
+ "Back"
+ ]
+ }]
+ }
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": 1496198395707,
+ "error": null
+ }
+ ```
+
+
+#### `addNotes`
+
+* Creates multiple notes using the given deck and model, with the provided field values and tags. Returns an array of
+ identifiers of the created notes. In the event of any errors, all errors are gathered and returned.
+* Please see the documentation for `addNote` for an explanation of objects in the `notes` array.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action":"addNotes",
+ "version":6,
+ "params":{
+ "notes":[
+ {
+ "deckName":"College::PluginDev",
+ "modelName":"non_existent_model",
+ "fields":{
+ "Front":"front",
+ "Back":"bak"
+ }
+ },
+ {
+ "deckName":"College::PluginDev",
+ "modelName":"Basic",
+ "fields":{
+ "Front":"front",
+ "Back":"bak"
+ }
+ }
+ ]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result":null,
+ "error":"['model was not found: non_existent_model']"
+ }
+ ```
+
+
+#### `canAddNotes`
+
+* Accepts an array of objects which define parameters for candidate notes (see `addNote`) and returns an array of
+ booleans indicating whether or not the parameters at the corresponding index could be used to create a new note.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "canAddNotes",
+ "version": 6,
+ "params": {
+ "notes": [
+ {
+ "deckName": "Default",
+ "modelName": "Basic",
+ "fields": {
+ "Front": "front content",
+ "Back": "back content"
+ },
+ "tags": [
+ "yomichan"
+ ]
+ }
+ ]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": [true],
+ "error": null
+ }
+ ```
+
+
+#### `canAddNotesWithErrorDetail`
+
+* Accepts an array of objects which define parameters for candidate notes (see `addNote`) and returns an array of
+ objects with fields `canAdd` and `error`.
+
+ * `canAdd` indicates whether or not the parameters at the corresponding index could be used to create a new note.
+ * `error` contains an explanation of why a note cannot be added.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "canAddNotesWithErrorDetail",
+ "version": 6,
+ "params": {
+ "notes": [
+ {
+ "deckName": "Default",
+ "modelName": "Basic",
+ "fields": {
+ "Front": "front content",
+ "Back": "back content"
+ },
+ "tags": [
+ "yomichan"
+ ]
+ },
+ {
+ "deckName": "Default",
+ "modelName": "Basic",
+ "fields": {
+ "Front": "front content 2",
+ "Back": "back content 2"
+ },
+ "tags": [
+ "yomichan"
+ ]
+ }
+ ]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": [
+ {
+ "canAdd": false,
+ "error": "cannot create note because it is a duplicate"
+ },
+ {
+ "canAdd": true
+ }
+ ],
+ "error": null
+ }
+ ```
+
+
+#### `updateNoteFields`
+
+* Modify the fields of an existing note. You can also include audio, video, or picture files which will be added to the note with an
+ optional `audio`, `video`, or `picture` property. Please see the documentation for `addNote` for an explanation of objects in the `audio`, `video`, or `picture` array.
+
+ > **Warning**:
+ > You must not be viewing the note that you are updating on your Anki browser, otherwise
+ > the fields will not update. See [this issue](https://github.com/FooSoft/anki-connect/issues/82)
+ > for further details.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "updateNoteFields",
+ "version": 6,
+ "params": {
+ "note": {
+ "id": 1514547547030,
+ "fields": {
+ "Front": "new front content",
+ "Back": "new back content"
+ },
+ "audio": [{
+ "url": "https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kanji=猫&kana=ねこ",
+ "filename": "yomichan_ねこ_猫.mp3",
+ "skipHash": "7e2c2f954ef6051373ba916f000168dc",
+ "fields": [
+ "Front"
+ ]
+ }]
+ }
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `updateNote`
+
+* Modify the fields and/or tags of an existing note.
+ In other words, combines `updateNoteFields` and `updateNoteTags`.
+ Please see their documentation for an explanation of all properties.
+
+ Either `fields` or `tags` property can be omitted without affecting the other.
+ Thus valid requests to `updateNoteFields` also work with `updateNote`.
+ The note must have the `fields` property in order to update the optional audio, video, or picture objects.
+
+ If neither `fields` nor `tags` are provided, the method will fail.
+ Fields are updated first and are not rolled back if updating tags fails.
+ Tags are not updated if updating fields fails.
+
+ > **Warning**
+ > You must not be viewing the note that you are updating on your Anki browser, otherwise
+ > the fields will not update. See [this issue](https://github.com/FooSoft/anki-connect/issues/82)
+ > for further details.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "updateNote",
+ "version": 6,
+ "params": {
+ "note": {
+ "id": 1514547547030,
+ "fields": {
+ "Front": "new front content",
+ "Back": "new back content"
+ },
+ "tags": ["new", "tags"]
+ }
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `updateNoteModel`
+
+* Update the model, fields, and tags of an existing note.
+ This allows you to change the note's model, update its fields with new content, and set new tags.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "updateNoteModel",
+ "version": 6,
+ "params": {
+ "note": {
+ "id": 1514547547030,
+ "modelName": "NewModel",
+ "fields": {
+ "NewField1": "new field 1",
+ "NewField2": "new field 2",
+ "NewField3": "new field 3"
+ },
+ "tags": ["new", "updated", "tags"]
+ }
+ }
+ }
+ ```
+
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+
+#### `updateNoteTags`
+
+* Set a note's tags by note ID. Old tags will be removed.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "updateNoteTags",
+ "version": 6,
+ "params": {
+ "note": 1483959289817,
+ "tags": ["european-languages"]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `getNoteTags`
+
+* Get a note's tags by note ID.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "getNoteTags",
+ "version": 6,
+ "params": {
+ "note": 1483959289817
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": ["european-languages"],
+ "error": null
+ }
+ ```
+
+
+#### `addTags`
+
+* Adds tags to notes by note ID.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "addTags",
+ "version": 6,
+ "params": {
+ "notes": [1483959289817, 1483959291695],
+ "tags": "european-languages"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `removeTags`
+
+* Remove tags from notes by note ID.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "removeTags",
+ "version": 6,
+ "params": {
+ "notes": [1483959289817, 1483959291695],
+ "tags": "european-languages"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `getTags`
+
+* Gets the complete list of tags for the current user.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "getTags",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": ["european-languages", "idioms"],
+ "error": null
+ }
+ ```
+
+
+#### `clearUnusedTags`
+
+* Clears all the unused tags in the notes for the current user.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "clearUnusedTags",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `replaceTags`
+
+* Replace tags in notes by note ID.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "replaceTags",
+ "version": 6,
+ "params": {
+ "notes": [1483959289817, 1483959291695],
+ "tag_to_replace": "european-languages",
+ "replace_with_tag": "french-languages"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `replaceTagsInAllNotes`
+
+* Replace tags in all the notes for the current user.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "replaceTagsInAllNotes",
+ "version": 6,
+ "params": {
+ "tag_to_replace": "european-languages",
+ "replace_with_tag": "french-languages"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `findNotes`
+
+* Returns an array of note IDs for a given query. Query syntax is [documented here](https://docs.ankiweb.net/searching.html).
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "findNotes",
+ "version": 6,
+ "params": {
+ "query": "deck:current"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": [1483959289817, 1483959291695],
+ "error": null
+ }
+ ```
+
+
+#### `notesInfo`
+
+* Returns a list of objects containing for each note ID the note fields, tags, note type, modification time,the cards belonging to
+ the note and the profile where the note was created.
+
+
+ Sample request (note ids):
+
+ ```json
+ {
+ "action": "notesInfo",
+ "version": 6,
+ "params": {
+ "notes": [1502298033753]
+ }
+ }
+ ```
+
+
+
+ Sample request (query):
+
+ ```json
+ {
+ "action": "notesInfo",
+ "version": 6,
+ "params": {
+ "query": "deck:current"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": [
+ {
+ "noteId":1502298033753,
+ "profile": "User_1",
+ "modelName": "Basic",
+ "tags":["tag","another_tag"],
+ "fields": {
+ "Front": {"value": "front content", "order": 0},
+ "Back": {"value": "back content", "order": 1}
+ },
+ "mod": 1718377864,
+ "cards": [1498938915662]
+ }
+ ],
+ "error": null
+ }
+ ```
+
+s
+#### `notesModTime`
+
+* Returns a list of objects containings for each note ID the modification time.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "notesModTime",
+ "version": 6,
+ "params": {
+ "notes": [1502298033753]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": [
+ {
+ "noteId": 1498938915662,
+ "mod": 1629454092
+ }
+ ],
+ "error": null
+ }
+ ```
+
+
+
+#### `deleteNotes`
+
+* Deletes notes with the given ids. If a note has several cards associated with it, all associated cards will be deleted.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "deleteNotes",
+ "version": 6,
+ "params": {
+ "notes": [1502298033753]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+#### `removeEmptyNotes`
+
+* Removes all the empty notes for the current user.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "removeEmptyNotes",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
+---
+
+### Statistic Actions
+
+#### `getNumCardsReviewedToday`
+
+* Gets the count of cards that have been reviewed in the current day (with day start time as configured by user in anki)
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "getNumCardsReviewedToday",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": 0,
+ "error": null
+ }
+ ```
+
+
+#### `getNumCardsReviewedByDay`
+
+* Gets the number of cards reviewed as a list of pairs of `(dateString, number)`
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "getNumCardsReviewedByDay",
+ "version": 6
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": [
+ ["2021-02-28", 124],
+ ["2021-02-27", 261]
+ ],
+ "error": null
+ }
+ ```
+
+
+#### `getCollectionStatsHTML`
+
+* Gets the collection statistics report
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "getCollectionStatsHTML",
+ "version": 6,
+ "params": {
+ "wholeCollection": true
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": " lots of HTML here ",
+ "error": null
+ }
+ ```
+
+
+#### `cardReviews`
+
+* Requests all card reviews for a specified deck after a certain time.
+ `startID` is the latest unix time not included in the result.
+ Returns a list of 9-tuples `(reviewTime, cardID, usn, buttonPressed, newInterval, previousInterval, newFactor, reviewDuration, reviewType)`
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "cardReviews",
+ "version": 6,
+ "params": {
+ "deck": "default",
+ "startID": 1594194095740
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": [
+ [1594194095746, 1485369733217, -1, 3, 4, -60, 2500, 6157, 0],
+ [1594201393292, 1485369902086, -1, 1, -60, -60, 0, 4846, 0]
+ ],
+ "error": null
+ }
+ ```
+
+
+#### `getReviewsOfCards`
+
+* Requests all card reviews for each card ID.
+ Returns a dictionary mapping each card ID to a list of dictionaries of the format:
+ ```
+ {
+ "id": reviewTime,
+ "usn": usn,
+ "ease": buttonPressed,
+ "ivl": newInterval,
+ "lastIvl": previousInterval,
+ "factor": newFactor,
+ "time": reviewDuration,
+ "type": reviewType,
+ }
+ ```
+ The reason why these key values are used instead of the more descriptive counterparts
+ is because these are the exact key values used in Anki's database.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "getReviewsOfCards",
+ "version": 6,
+ "params": {
+ "cards": [
+ "1653613948202"
+ ]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": {
+ "1653613948202": [
+ {
+ "id": 1653772912146,
+ "usn": 1750,
+ "ease": 1,
+ "ivl": -20,
+ "lastIvl": -20,
+ "factor": 0,
+ "time": 38192,
+ "type": 0
+ },
+ {
+ "id": 1653772965429,
+ "usn": 1750,
+ "ease": 3,
+ "ivl": -45,
+ "lastIvl": -20,
+ "factor": 0,
+ "time": 15337,
+ "type": 0
+ }
+ ]
+ },
+ "error": null
+ }
+ ```
+
+
+#### `getLatestReviewID`
+
+* Returns the unix time of the latest review for the given deck. 0 if no review has ever been made for the deck.
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "getLatestReviewID",
+ "version": 6,
+ "params": {
+ "deck": "default"
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": 1594194095746,
+ "error": null
+ }
+ ```
+
+
+#### `insertReviews`
+
+* Inserts the given reviews into the database. Required format: list of 9-tuples `(reviewTime, cardID, usn, buttonPressed, newInterval, previousInterval, newFactor, reviewDuration, reviewType)`
+
+
+ Sample request:
+
+ ```json
+ {
+ "action": "insertReviews",
+ "version": 6,
+ "params": {
+ "reviews": [
+ [1594194095746, 1485369733217, -1, 3, 4, -60, 2500, 6157, 0],
+ [1594201393292, 1485369902086, -1, 1, -60, -60, 0, 4846, 0]
+ ]
+ }
+ }
+ ```
+
+
+
+ Sample result:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
diff --git a/README-zh.md b/README-zh.md
deleted file mode 100644
index 72b94ca..0000000
--- a/README-zh.md
+++ /dev/null
@@ -1,8415 +0,0 @@
-# Anki-Connect
-
-Anki-Connect使外部应用程序(如Yomichan)能够通过简单的HTTP API与[Anki](https://apps.ankiweb.net/)进行通信。它的功能包括对用户卡片组执行查询、自动创建新卡片等。Anki-Connect与最新的稳定版(2.1.x)Anki兼容;旧版本(2.0.x及以下)不再受支持。
-
-## 安装
-
-安装过程与其他Anki插件类似,可以通过以下三个步骤完成:
-
-1. 在Anki中选择`工具` | `插件` | `获取插件...`,打开`安装插件`对话框。
-2. 在标有`代码`的文本框中输入[2055492159](https://ankiweb.net/shared/info/2055492159),然后按`确定`按钮继续。
-3. 当提示重启Anki时,请按照要求进行操作,以完成Anki-Connect的安装。
-
-Anki必须在后台保持运行,以便其他应用程序能够使用Anki-Connect。您可以随时通过在浏览器中访问`localhost:8765`来验证Anki-Connect是否在运行。如果服务器正在运行,您将在浏览器窗口中看到`Anki-Connect`的消息。
-
-### Windows用户注意事项
-
-Windows用户可能会在Anki启动时看到防火墙提示对话框。这是因为Anki-Connect运行了本地HTTP服务器,以便其他应用程序能够连接到它。主应用程序Anki必须被允许通过防火墙,此插件才能正常运行。
-
-### MacOS用户注意事项
-
-从[Mac OS X Mavericks](https://en.wikipedia.org/wiki/OS_X_Mavericks)开始,操作系统引入了名为*App Nap*的功能。此功能会使某些已打开但不可见的应用程序进入挂起状态。由于此行为会导致Anki-Connect在前台显示其他窗口时停止工作,因此应为Anki禁用App Nap:
-
-1. 启动终端应用程序。
-2. 在终端窗口中执行以下命令:
- ```bash
- defaults write net.ankiweb.dtop NSAppSleepDisabled -bool true
- defaults write net.ichi2.anki NSAppSleepDisabled -bool true
- defaults write org.qt-project.Qt.QtWebEngineCore NSAppSleepDisabled -bool true
- ```
-3. 重启Anki。
-
-## 开发者应用程序接口
-
-Anki-Connect通过易于使用的API向外部应用程序公开Anki的内部功能。安装后,只要启动Anki,该插件就会在8765端口启动HTTP服务器。其他应用程序(包括浏览器扩展)可以通过HTTP请求与其通信。
-
-默认情况下,Anki-Connect只会将HTTP服务器绑定到`127.0.0.1`IP地址,因此您只能从运行它的同一主机访问它。如果您需要通过网络访问,可以在配置中更改绑定地址。进入工具->插件->AnkiConnect->配置,更改"webBindAddress"值。例如,您可以将其设置为`0.0.0.0`,以将其绑定到主机上的所有网络接口。这也需要重启Anki。
-
-### 调用示例
-
-每个请求都由一个包含`action`、`version`、上下文`params`和用于认证的`key`值(可选,默认可以省略)的JSON编码对象组成。Anki-Connect将返回一个包含两个字段的对象:`result`和`error`。`result`字段包含执行的API的返回值,而`error`字段是在API执行期间抛出的任何异常的描述(如果执行成功,则使用值`null`)。
-
-*成功响应示例*:
-```json
-{"result": ["Default", "Filtered Deck 1"], "error": null}
-```
-
-*失败响应示例*:
-```json
-{"result": null, "error": "unsupported action"}
-```
-```json
-{"result": null, "error": "guiBrowse() got an unexpected keyword argument 'foobar'"}
-```
-
-为了与旧版本Anki-Connect设计的客户端兼容,如果请求中未提供`version`字段,版本将默认为4。此外,当提供的版本为4级或以下时,API响应将只包含`result`的值;没有`error`字段可用于错误处理。
-
-您可以使用任何语言或工具向Anki-Connect发出请求,但下面包含了几个简单的示例作为参考。
-
-#### Curl
-
-```bash
-curl localhost:8765 -X POST -d '{"action": "deckNames", "version": 6}'
-```
-
-#### Powershell
-
-```powershell
-(Invoke-RestMethod -Uri http://localhost:8765 -Method Post -Body '{"action": "deckNames", "version": 6}').result
-```
-
-#### Python
-
-```python
-import json
-import urllib.request
-
-def request(action, **params):
- return {'action': action, 'params': params, 'version': 6}
-
-def invoke(action, **params):
- requestJson = json.dumps(request(action, **params)).encode('utf-8')
- response = json.load(urllib.request.urlopen(urllib.request.Request('http://127.0.0.1:8765', requestJson)))
- if len(response) != 2:
- raise Exception('response has an unexpected number of fields')
- if 'error' not in response:
- raise Exception('response is missing required error field')
- if 'result' not in response:
- raise Exception('response is missing required result field')
- if response['error'] is not None:
- raise Exception(response['error'])
- return response['result']
-
-invoke('createDeck', deck='test1')
-result = invoke('deckNames')
-print('got list of decks: {}'.format(result))
-```
-
-#### JavaScript
-
-```javascript
-function invoke(action, version, params={}) {
- return new Promise((resolve, reject) => {
- const xhr = new XMLHttpRequest();
- xhr.addEventListener('error', () => reject('failed to issue request'));
- xhr.addEventListener('load', () => {
- try {
- const response = JSON.parse(xhr.responseText);
- if (Object.getOwnPropertyNames(response).length != 2) {
- throw 'response has an unexpected number of fields';
- }
- if (!response.hasOwnProperty('error')) {
- throw 'response is missing required error field';
- }
- if (!response.hasOwnProperty('result')) {
- throw 'response is missing required result field';
- }
- if (response.error) {
- throw response.error;
- }
- resolve(response.result);
- } catch (e) {
- reject(e);
- }
- });
-
- xhr.open('POST', 'http://127.0.0.1:8765');
- xhr.send(JSON.stringify({action, version, params}));
- });
-}
-
-await invoke('createDeck', 6, {deck: 'test1'});
-const result = await invoke('deckNames', 6);
-console.log(`got list of decks: ${result}`);
-```
-
-### 认证
-
-Anki-Connect支持要求认证以便进行API请求。
-默认情况下,此支持是*禁用*的,但可以通过在Anki-Config的设置(工具->插件->AnkiConnect->配置)中设置`apiKey`字段为所需的字符串来启用。
-如果您已经这样做,您应该会看到[`requestPermission`](#requestpermission) API请求返回`true`作为`requireApiKey`。
-然后您必须在任何进一步的API请求体中包含一个名为`key`的附加参数,其值必须与配置的API密钥匹配。
-
-### 嘿,你能添加一个新的action来支持$FEATURE吗?
-
-Anki-Connect的主要目标是支持来自Yomichan浏览器扩展的实时闪卡创建。当前的API提供了所有必要的动作来实现这一点。我认识到Anki-Connect的角色已经从这一最初愿景演变,而且我很乐意审查新的功能请求。
-
-话虽如此,*本项目采用自助服务模式*。如果你想要一个新功能,请创建一个PR。我会审查它,如果看起来不错,就会合并。*没有附带拉取请求的添加新功能的请求将不会得到处理*。确保你的拉取请求满足以下标准:
-
-* 尝试匹配周围代码的风格。
-* 有附带的文档和示例。
-* 有验证操作的附带测试。
-* 实现在其他应用中有用的功能。
-
-## 支持的动作
-
-当前支持的动作的文档按类别分类并在下面引用。请注意,已弃用的API将继续运行,尽管未在此页面上列出,只要您的请求标有对应API可用时的版本号。搜索参数传递给Anki,更多信息请查看文档:https://docs.ankiweb.net/searching.html
-
-* [卡片操作](#card-actions)
-* [卡组操作](#deck-actions)
-* [图形界面操作](#graphical-actions)
-* [媒体操作](#media-actions)
-* [杂项操作](#miscellaneous-actions)
-* [模型操作](#model-actions)
-* [笔记操作](#note-actions)
-* [统计操作](#statistic-actions)
-
----
-
-### 卡片操作
-
-#### `getEaseFactors`
-
-* 返回一个数组,包含给定卡片的简易度因子(按相同顺序)。
-
-
- 示例请求:
-
- ```json
- {
- "action": "getEaseFactors",
- "version": 6,
- "params": {
- "cards": [1483959291685, 1483959293217]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [4100, 3900],
- "error": null
- }
- ```
-
-
-#### `setEaseFactors`
-
-* 通过卡片ID设置卡片的简易度因子;如果成功(所有卡片都存在)则返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "setEaseFactors",
- "version": 6,
- "params": {
- "cards": [1483959291685, 1483959293217],
- "easeFactors": [4100, 3900]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [true, true],
- "error": null
- }
- ```
-
-
-
-#### `setSpecificValueOfCard`
-
-* 设置单个卡片的特定值。由于更改卡片的某些值可能会在数据库中造成混乱,一些键需要将参数"warning_check"设置为True。
- 这可用于设置卡片的标志、更改其简易度因子、更改筛选卡组中的复习顺序以及更改列"data"(目前显然未被anki使用),以及许多其他值。
- 可以在[AnkiDroid的wiki](https://github.com/ankidroid/Anki-Android/wiki/Database-Structure)上找到值的列表及其各自的用途解释。
-
-
- 示例请求:
-
- ```json
- {
- "action": "setSpecificValueOfCard",
- "version": 6,
- "params": {
- "card": 1483959291685,
- "keys": ["flags", "odue"],
- "newValues": ["1", "-100"]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [true, true],
- "error": null
- }
- ```
-
-
-
-#### `suspend`
-
-* 通过卡片ID暂停卡片;如果成功(至少有一张卡片之前没有被暂停)则返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "suspend",
- "version": 6,
- "params": {
- "cards": [1483959291685, 1483959293217]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `unsuspend`
-
-* 通过卡片ID取消暂停卡片;如果成功(至少有一张卡片之前被暂停)则返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "unsuspend",
- "version": 6,
- "params": {
- "cards": [1483959291685, 1483959293217]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `suspended`
-
-* 通过ID检查卡片是否被暂停。如果被暂停则返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "suspended",
- "version": 6,
- "params": {
- "card": 1483959293217
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `areSuspended`
-
-* 返回一个数组,表示每张给定卡片是否被暂停(按相同顺序)。如果卡片不存在,则返回`null`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "areSuspended",
- "version": 6,
- "params": {
- "cards": [1483959291685, 1483959293217, 1234567891234]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [false, true, null],
- "error": null
- }
- ```
-
-
-#### `areDue`
-
-* 返回一个数组,表示每张给定卡片是否到期(按相同顺序)。*注意*:学习队列中有大间隔(超过20分钟)的卡片被视为未到期,直到其间隔时间过去为止,这与Anki在复习时对待它们的方式相匹配。
-
-
- 示例请求:
-
- ```json
- {
- "action": "areDue",
- "version": 6,
- "params": {
- "cards": [1483959291685, 1483959293217]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [false, true],
- "error": null
- }
- ```
-
-
-#### `getIntervals`
-
-* 返回一个数组,包含每个给定卡片ID的最近间隔,或者当`complete`为`true`时,返回每个给定卡片ID的所有间隔的二维数组。负间隔以秒为单位,正间隔以天为单位。
-
-
- 示例请求1:
-
- ```json
- {
- "action": "getIntervals",
- "version": 6,
- "params": {
- "cards": [1502298033753, 1502298036657]
- }
- }
- ```
-
-
-
- 示例结果1:
-
- ```json
- {
- "result": [-14400, 3],
- "error": null
- }
- ```
-
-
-
- 示例请求2:
-
- ```json
- {
- "action": "getIntervals",
- "version": 6,
- "params": {
- "cards": [1502298033753, 1502298036657],
- "complete": true
- }
- }
- ```
-
-
-
- 示例结果2:
-
- ```json
- {
- "result": [
- [-120, -180, -240, -300, -360, -14400],
- [-120, -180, -240, -300, -360, -14400, 1, 3]
- ],
- "error": null
- }
- ```
-
-
-#### `findCards`
-
-* 返回给定查询的卡片ID数组。功能上与`guiBrowse`相同,但不使用GUI以获得更好的性能。
-
-
- 示例请求:
-
- ```json
- {
- "action": "findCards",
- "version": 6,
- "params": {
- "query": "deck:current"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [1494723142483, 1494703460437, 1494703479525],
- "error": null
- }
- ```
-
-
-#### `cardsToNotes`
-
-* 返回给定卡片ID的笔记ID的无序数组。对于具有相同笔记的卡片,ID在数组中只给出一次。
-
-
- 示例请求:
-
- ```json
- {
- "action": "cardsToNotes",
- "version": 6,
- "params": {
- "cards": [1502098034045, 1502098034048, 1502298033753]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [1502098029797, 1502298025183],
- "error": null
- }
- ```
-
-
-#### `cardsModTime`
-
-* 返回一个对象列表,包含每个卡片ID的修改时间。
- 此功能比执行`cardsInfo`快约15倍。
-
-
- 示例请求:
-
- ```json
- {
- "action": "cardsModTime",
- "version": 6,
- "params": {
- "cards": [1498938915662, 1502098034048]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [
- {
- "cardId": 1498938915662,
- "mod": 1629454092
- }
- ],
- "error": null
- }
- ```
-
-
-
-#### `cardsInfo`
-
-* 返回一个对象列表,包含每个卡片ID的卡片字段、正反面(包括CSS)、笔记类型、卡片所属的笔记、卡组名称、最后修改时间戳以及简易度和间隔。
-
-
- 示例请求:
-
- ```json
- {
- "action": "cardsInfo",
- "version": 6,
- "params": {
- "cards": [1498938915662, 1502098034048]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [
- {
- "answer": "back content",
- "question": "front content",
- "deckName": "Default",
- "modelName": "Basic",
- "fieldOrder": 1,
- "fields": {
- "Front": {"value": "front content", "order": 0},
- "Back": {"value": "back content", "order": 1}
- },
- "css":"p {font-family:Arial;}",
- "cardId": 1498938915662,
- "interval": 16,
- "note":1502298033753,
- "ord": 1,
- "type": 0,
- "queue": 0,
- "due": 1,
- "reps": 1,
- "lapses": 0,
- "left": 6,
- "mod": 1629454092
- },
- {
- "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}
- },
- "css":"p {font-family:Arial;}",
- "cardId": 1502098034048,
- "interval": 23,
- "note":1502298033753,
- "ord": 1,
- "type": 0,
- "queue": 0,
- "due": 1,
- "reps": 1,
- "lapses": 0,
- "left": 6
- }
- ],
- "error": null
- }
- ```
-
-
-#### `forgetCards`
-
-* 忘记卡片,使卡片再次成为新卡片。
-
-
- 示例请求:
-
- ```json
- {
- "action": "forgetCards",
- "version": 6,
- "params": {
- "cards": [1498938915662, 1502098034048]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `relearnCards`
-
-* 使卡片成为"重新学习"状态。
-
-
- 示例请求:
-
- ```json
- {
- "action": "relearnCards",
- "version": 6,
- "params": {
- "cards": [1498938915662, 1502098034048]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `answerCards`
-
-* 回答卡片。简易度在1(重来)到4(简单)之间。将在回答前立即开始计时器。如果卡片存在则返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "answerCards",
- "version": 6,
- "params": {
- "answers": [
- {
- "cardId": 1498938915662,
- "ease": 2
- },
- {
- "cardId": 1502098034048,
- "ease": 4
- }
- ]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [true, true],
- "error": null
- }
- ```
-
-
-#### `setDueDate`
-
-* 设置到期日期。如果是新卡片,则将其转为复习卡片,并使其在特定日期到期。
- * 0 = 今天
- * 1! = 明天 + 将间隔更改为1
- * 3-7 = 随机选择3-7天
-
-
- 示例请求:
-
- ```json
- {
- "action": "setDueDate",
- "version": 6,
- "params": {
- "cards": [1498938915662, 1502098034048],
- "days": "3-7"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
----
-
-### 卡组操作
-
-#### `deckNames`
-
-* 获取当前用户的完整卡组名称列表。
-
-
- 示例请求:
-
- ```json
- {
- "action": "deckNames",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": ["Default"],
- "error": null
- }
- ```
-
-
-#### `deckNamesAndIds`
-
-* 获取当前用户的完整卡组名称及其对应ID的列表。
-
-
- 示例请求:
-
- ```json
- {
- "action": "deckNamesAndIds",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": {"Default": 1},
- "error": null
- }
- ```
-
-
-#### `getDecks`
-
-* 接受一个卡片ID数组,并返回一个对象,其中每个卡组名称作为键,其值是属于该卡组的给定卡片数组。
-
-
- 示例请求:
-
- ```json
- {
- "action": "getDecks",
- "version": 6,
- "params": {
- "cards": [1502298036657, 1502298033753, 1502032366472]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": {
- "Default": [1502032366472],
- "Japanese::JLPT N3": [1502298036657, 1502298033753]
- },
- "error": null
- }
- ```
-
-
-#### `createDeck`
-
-* 创建一个新的空卡组。不会覆盖同名的已存在卡组。
-
-
- 示例请求:
-
- ```json
- {
- "action": "createDeck",
- "version": 6,
- "params": {
- "deck": "Japanese::Tokyo"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": 1519323742721,
- "error": null
- }
- ```
-
-
-#### `changeDeck`
-
-* 将具有给定ID的卡片移动到不同的卡组,如果卡组尚不存在则创建它。
-
-
- 示例请求:
-
- ```json
- {
- "action": "changeDeck",
- "version": 6,
- "params": {
- "cards": [1502098034045, 1502098034048, 1502298033753],
- "deck": "Japanese::JLPT N3"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `deleteDecks`
-
-* 删除具有给定名称的卡组。
- 参数`cardsToo` *必须*被指定并设置为`true`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "deleteDecks",
- "version": 6,
- "params": {
- "decks": ["Japanese::JLPT N5", "Easy Spanish"],
- "cardsToo": true
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `getDeckConfig`
-
-* 获取给定卡组的配置组对象。
-
-
- 示例请求:
-
- ```json
- {
- "action": "getDeckConfig",
- "version": 6,
- "params": {
- "deck": "Default"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": {
- "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
- },
- "error": null
- }
- ```
-
-
-#### `saveDeckConfig`
-
-* 保存给定的配置组,成功时返回`true`,如果配置组的ID无效(例如不存在)则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "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
- }
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `setDeckConfigId`
-
-* 将给定卡组的配置组更改为具有给定ID的配置组。成功时返回`true`,如果给定的配置组或任何给定的卡组不存在则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "setDeckConfigId",
- "version": 6,
- "params": {
- "decks": ["Default"],
- "configId": 1
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `cloneDeckConfigId`
-
-* 使用给定的名称创建一个新的配置组,从具有给定ID的组克隆,或者如果未指定,则从默认组克隆。返回新配置组的ID,或者如果指定的要克隆的组不存在,则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "cloneDeckConfigId",
- "version": 6,
- "params": {
- "name": "Copy of Default",
- "cloneFrom": 1
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": 1502972374573,
- "error": null
- }
- ```
-
-
-#### `removeDeckConfigId`
-
-* 移除具有给定ID的配置组,如果成功则返回`true`,如果尝试移除默认配置组(ID = 1)或不存在的配置组则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "removeDeckConfigId",
- "version": 6,
- "params": {
- "configId": 1502972374573
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `getDeckStats`
-
-* 获取给定卡组的统计信息,如总卡片数和到期卡片数。
-
-
- 示例请求:
-
- ```json
- {
- "action": "getDeckStats",
- "version": 6,
- "params": {
- "decks": ["Japanese::JLPT N5", "Easy Spanish"]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": {
- "1651445861967": {
- "deck_id": 1651445861967,
- "name": "Japanese::JLPT N5",
- "new_count": 20,
- "learn_count": 0,
- "review_count": 0,
- "total_in_deck": 1506
- },
- "1651445861960": {
- "deck_id": 1651445861960,
- "name": "Easy Spanish",
- "new_count": 26,
- "learn_count": 10,
- "review_count": 5,
- "total_in_deck": 852
- }
- },
- "error": null
- }
- ```
-
-
----
-
-### 图形界面操作
-
-#### `guiBrowse`
-
-* 调用*卡片浏览器*对话框并搜索给定查询。返回找到的卡片标识符数组。查询语法[在此处有文档](https://docs.ankiweb.net/searching.html)。
-
- 可选地,可以提供`reorderCards`属性来重新排序*卡片浏览器*中显示的卡片。
- 这是一个包含`order`和`columnId`对象的数组。`order`可以是`ascending`或`descending`,而`columnId`可以是几个列标识符之一(如在[Anki源代码](https://github.com/ankitects/anki/blob/main/rslib/src/browser_table.rs)中记录的)。
- 指定的列需要在*卡片浏览器*中可见。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiBrowse",
- "version": 6,
- "params": {
- "query": "deck:current",
- "reorderCards": {
- "order": "descending",
- "columnId": "noteCrt"
- }
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [1494723142483, 1494703460437, 1494703479525],
- "error": null
- }
- ```
-
-
-#### `guiSelectCard`
-
-* 找到*卡片浏览器*对话框的打开实例,并根据卡片标识符选择一张卡片。
- 如果*卡片浏览器*是打开的,返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiSelectCard",
- "version": 6,
- "params": {
- "card": 1494723142483
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `guiSelectedNotes`
-
-* 找到*卡片浏览器*对话框的打开实例,并返回选中笔记的标识符数组。如果浏览器未打开,则返回空列表。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiSelectedNotes",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [1494723142483, 1494703460437, 1494703479525],
- "error": null
- }
- ```
-
-
-#### `guiAddCards`
-
-* 调用*添加卡片*对话框,使用给定的卡组和模型预设笔记,带有提供的字段值和标签。
- 多次调用会关闭旧窗口并_重新打开窗口_,使用新提供的值。
-
- 可以通过`audio`、`video`和`picture`键将音频、视频和图片文件嵌入到字段中。
- 请参考`addNote`和`storeMediaFile`的文档,了解这些字段的说明。
-
- 结果是如果用户选择确认*添加卡片*对话框,将添加的笔记的ID。
-
-
- 示例请求:
-
- ```json
- {
- "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"
- ],
- "picture": [{
- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/1/13/EU-Romania.svg/285px-EU-Romania.svg.png",
- "filename": "romania.png",
- "fields": [
- "Extra"
- ]
- }]
- }
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": 1496198395707,
- "error": null
- }
- ```
-
-
-#### `guiEditNote`
-
-* 打开*编辑*对话框,显示对应于给定笔记ID的笔记。
- 该对话框类似于*编辑当前*对话框,但:
-
- * 有一个预览按钮,用于预览笔记的卡片
- * 有一个浏览按钮,用于打开浏览器并显示这些卡片
- * 有上一个/后退按钮,用于导航对话框的历史
- * 没有带有关闭按钮的栏
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiEditNote",
- "version": 6,
- "params": {
- "note": 1649198355435
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `guiCurrentCard`
-
-* 返回有关当前卡片的信息,如果不在复习模式,则返回`null`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiCurrentCard",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "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`
-
-* 启动或重置当前卡片的`timerStarted`值。这对于将开始时间推迟到通过API显示卡片时很有用,从而在调用`guiAnswerCard`时使记录的回答卡片所花费的时间更准确。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiStartCardTimer",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `guiShowQuestion`
-
-* 显示当前卡片的问题文本;如果处于复习模式则返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiShowQuestion",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `guiShowAnswer`
-
-* 显示当前卡片的答案文本;如果处于复习模式则返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiShowAnswer",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `guiAnswerCard`
-
-* 回答当前卡片;如果成功则返回`true`,否则返回`false`。注意,在Anki接受任何答案之前,必须先显示当前卡片的答案。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiAnswerCard",
- "version": 6,
- "params": {
- "ease": 1
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `guiUndo`
-
-* 撤销最后一个动作/卡片;如果成功则返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiUndo",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `guiDeckOverview`
-
-* 为具有给定名称的卡组打开*卡组概览*对话框;如果成功则返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiDeckOverview",
- "version": 6,
- "params": {
- "name": "Default"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `guiDeckBrowser`
-
-* 打开*卡组浏览器*对话框。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiDeckBrowser",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `guiDeckReview`
-
-* 开始复习具有给定名称的卡组;如果成功则返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiDeckReview",
- "version": 6,
- "params": {
- "name": "Default"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `guiImportFile`
-
-* 调用*导入...(Ctrl+Shift+I)*对话框,并可选择提供文件路径。弹出对话框供用户审核导入。支持Anki支持的所有文件类型。如果未提供路径,则显示打开文件对话框。在Windows上的路径中必须使用正斜杠。仅支持Anki 2.1.52+。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiImportFile",
- "version": 6,
- "params": {
- "path": "C:/Users/Desktop/cards.txt"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `guiExitAnki`
-
-* 安排一个请求来优雅地关闭Anki。此操作是异步的,因此它会立即返回,而不会等待Anki进程实际终止。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiExitAnki",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `guiCheckDatabase`
-
-* 请求进行数据库检查,但立即返回而不等待检查完成。因此,即使在数据库检查过程中检测到错误,此操作也将始终返回`true`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiCheckDatabase",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
----
-
-### 媒体操作
-
-#### `storeMediaFile`
-
-* 将具有指定base64编码内容的文件存储在媒体文件夹中。或者,您可以指定绝对文件路径,或者从中下载文件的URL。如果提供了`data`、`path`和`url`中的多个,将首先使用`data`字段,然后是`path`,最后是`url`。为了防止Anki删除不被任何卡片使用的文件(例如配置文件),请在文件名前加下划线。这些文件仍然会同步到AnkiWeb。
- 默认情况下,将删除任何同名的现有文件。设置`deleteExisting`为false可以通过[让Anki为新文件提供非冲突的名称](https://github.com/ankitects/anki/blob/aeba725d3ea9628c73300648f748140db3fdd5ed/rslib/src/media/files.rs#L194)来防止这种情况。
-
-
- 示例请求(相对路径):
-
- ```json
- {
- "action": "storeMediaFile",
- "version": 6,
- "params": {
- "filename": "_hello.txt",
- "data": "SGVsbG8sIHdvcmxkIQ=="
- }
- }
- ```
-
- *`_hello.txt`的内容*:
-
- ```
- Hello world!
- ```
-
-
-
- 示例结果(相对路径):
-
- ```json
- {
- "result": "_hello.txt",
- "error": null
- }
- ```
-
-
-
- 示例请求(绝对路径):
-
- ```json
- {
- "action": "storeMediaFile",
- "version": 6,
- "params": {
- "filename": "_hello.txt",
- "path": "/path/to/file"
- }
- }
- ```
-
-
-
- 示例结果(绝对路径):
-
- ```json
- {
- "result": "_hello.txt",
- "error": null
- }
- ```
-
-
-
- 示例请求(url):
-
- ```json
- {
- "action": "storeMediaFile",
- "version": 6,
- "params": {
- "filename": "_hello.txt",
- "url": "https://url.to.file"
- }
- }
- ```
-
-
-
- 示例结果(url):
-
- ```json
- {
- "result": "_hello.txt",
- "error": null
- }
- ```
-
-
-#### `retrieveMediaFile`
-
-* 检索指定文件的base64编码内容,如果文件不存在则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "retrieveMediaFile",
- "version": 6,
- "params": {
- "filename": "_hello.txt"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": "SGVsbG8sIHdvcmxkIQ==",
- "error": null
- }
- ```
-
-
-#### `getMediaFilesNames`
-
-* 获取与模式匹配的媒体文件名。默认返回所有名称。
-
-
- 示例请求:
-
- ```json
- {
- "action": "getMediaFilesNames",
- "version": 6,
- "params": {
- "pattern": "_hell*.txt"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": ["_hello.txt"],
- "error": null
- }
- ```
-
-
-#### `getMediaDirPath`
-
-* 获取当前打开的配置文件的`collection.media`文件夹的完整路径。
-
-
- 示例请求:
-
- ```json
- {
- "action": "getMediaDirPath",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": "/home/user/.local/share/Anki2/Main/collection.media",
- "error": null
- }
- ```
-
-
-#### `deleteMediaFile`
-
-* 删除媒体文件夹中的指定文件。
-
-
- 示例请求:
-
- ```json
- {
- "action": "deleteMediaFile",
- "version": 6,
- "params": {
- "filename": "_hello.txt"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
----
-
-### 杂项操作
-
-#### `requestPermission`
-
-* 请求使用此插件公开的API的权限。此方法不需要API密钥,是唯一接受来自任何来源的请求的方法;其他方法只接受来自受信任来源的请求,这些来源列在插件配置的`webCorsOriginList`下。默认情况下,`localhost`是受信任的。
-
- 从不受信任的来源调用此方法将在Anki中显示一个弹出窗口,询问用户是否允许您的来源使用API;来自受信任来源的调用将返回结果而不显示弹出窗口。
- 在拒绝许可时,用户还可以选择忽略来自该来源的进一步许可请求。这些来源最终会出现在`ignoreOriginList`中,可通过插件配置进行编辑。
-
- 结果始终包含`permission`字段,该字段反过来包含字符串`granted`或`denied`,对应于您的来源是否受信任。如果您的来源受信任,还将返回字段`requireApiKey`(如果需要则为`true`)和`version`。
-
- 这应该是您进行的第一个调用,以确保您的应用程序和Anki-Connect能够相互正确通信。新版本的Anki-Connect向后兼容;只要您使用在报告的Anki-Connect版本或更早版本中可用的操作,一切都应该正常工作。
-
-
- 示例请求:
-
- ```json
- {
- "action": "requestPermission",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": {
- "permission": "granted",
- "requireApiKey": false,
- "version": 6
- },
- "error": null
- }
- ```
-
- ```json
- {
- "result": {
- "permission": "denied"
- },
- "error": null
- }
- ```
-
-
-#### `version`
-
-* 获取此插件公开的API的版本。目前定义了版本`1`到`6`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "version",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": 6,
- "error": null
- }
- ```
-
-
-
-#### `apiReflect`
-
-* 获取有关可用AnkiConnect API的信息。请求支持以下参数:
-
-
-# Anki-Connect
-
-Anki-Connect使外部应用程序(如Yomichan)能够通过简单的HTTP API与[Anki](https://apps.ankiweb.net/)进行通信。它的功能包括对用户卡片组执行查询、自动创建新卡片等。Anki-Connect与最新的稳定版(2.1.x)Anki兼容;旧版本(2.0.x及以下)不再受支持。
-
-## 安装
-
-安装过程与其他Anki插件类似,可以通过以下三个步骤完成:
-
-1. 在Anki中选择`工具` | `插件` | `获取插件...`,打开`安装插件`对话框。
-2. 在标有`代码`的文本框中输入[2055492159](https://ankiweb.net/shared/info/2055492159),然后按`确定`按钮继续。
-3. 当提示重启Anki时,请按照要求进行操作,以完成Anki-Connect的安装。
-
-Anki必须在后台保持运行,以便其他应用程序能够使用Anki-Connect。您可以随时通过在浏览器中访问`localhost:8765`来验证Anki-Connect是否在运行。如果服务器正在运行,您将在浏览器窗口中看到`Anki-Connect`的消息。
-
-### Windows用户注意事项
-
-Windows用户可能会在Anki启动时看到防火墙提示对话框。这是因为Anki-Connect运行了本地HTTP服务器,以便其他应用程序能够连接到它。主应用程序Anki必须被允许通过防火墙,此插件才能正常运行。
-
-### MacOS用户注意事项
-
-从[Mac OS X Mavericks](https://en.wikipedia.org/wiki/OS_X_Mavericks)开始,操作系统引入了名为*App Nap*的功能。此功能会使某些已打开但不可见的应用程序进入挂起状态。由于此行为会导致Anki-Connect在前台显示其他窗口时停止工作,因此应为Anki禁用App Nap:
-
-1. 启动终端应用程序。
-2. 在终端窗口中执行以下命令:
- ```bash
- defaults write net.ankiweb.dtop NSAppSleepDisabled -bool true
- defaults write net.ichi2.anki NSAppSleepDisabled -bool true
- defaults write org.qt-project.Qt.QtWebEngineCore NSAppSleepDisabled -bool true
- ```
-3. 重启Anki。
-
-## 开发者应用程序接口
-
-Anki-Connect通过易于使用的API向外部应用程序公开Anki的内部功能。安装后,只要启动Anki,该插件就会在8765端口启动HTTP服务器。其他应用程序(包括浏览器扩展)可以通过HTTP请求与其通信。
-
-默认情况下,Anki-Connect只会将HTTP服务器绑定到`127.0.0.1`IP地址,因此您只能从运行它的同一主机访问它。如果您需要通过网络访问,可以在配置中更改绑定地址。进入工具->插件->AnkiConnect->配置,更改"webBindAddress"值。例如,您可以将其设置为`0.0.0.0`,以将其绑定到主机上的所有网络接口。这也需要重启Anki。
-
-### 调用示例
-
-每个请求都由一个包含`action`、`version`、上下文`params`和用于认证的`key`值(可选,默认可以省略)的JSON编码对象组成。Anki-Connect将返回一个包含两个字段的对象:`result`和`error`。`result`字段包含执行的API的返回值,而`error`字段是在API执行期间抛出的任何异常的描述(如果执行成功,则使用值`null`)。
-
-*成功响应示例*:
-```json
-{"result": ["Default", "Filtered Deck 1"], "error": null}
-```
-
-*失败响应示例*:
-```json
-{"result": null, "error": "unsupported action"}
-```
-```json
-{"result": null, "error": "guiBrowse() got an unexpected keyword argument 'foobar'"}
-```
-
-为了与旧版本Anki-Connect设计的客户端兼容,如果请求中未提供`version`字段,版本将默认为4。此外,当提供的版本为4级或以下时,API响应将只包含`result`的值;没有`error`字段可用于错误处理。
-
-您可以使用任何语言或工具向Anki-Connect发出请求,但下面包含了几个简单的示例作为参考。
-
-#### Curl
-
-```bash
-curl localhost:8765 -X POST -d '{"action": "deckNames", "version": 6}'
-```
-
-#### Powershell
-
-```powershell
-(Invoke-RestMethod -Uri http://localhost:8765 -Method Post -Body '{"action": "deckNames", "version": 6}').result
-```
-
-#### Python
-
-```python
-import json
-import urllib.request
-
-def request(action, **params):
- return {'action': action, 'params': params, 'version': 6}
-
-def invoke(action, **params):
- requestJson = json.dumps(request(action, **params)).encode('utf-8')
- response = json.load(urllib.request.urlopen(urllib.request.Request('http://127.0.0.1:8765', requestJson)))
- if len(response) != 2:
- raise Exception('response has an unexpected number of fields')
- if 'error' not in response:
- raise Exception('response is missing required error field')
- if 'result' not in response:
- raise Exception('response is missing required result field')
- if response['error'] is not None:
- raise Exception(response['error'])
- return response['result']
-
-invoke('createDeck', deck='test1')
-result = invoke('deckNames')
-print('got list of decks: {}'.format(result))
-```
-
-#### JavaScript
-
-```javascript
-function invoke(action, version, params={}) {
- return new Promise((resolve, reject) => {
- const xhr = new XMLHttpRequest();
- xhr.addEventListener('error', () => reject('failed to issue request'));
- xhr.addEventListener('load', () => {
- try {
- const response = JSON.parse(xhr.responseText);
- if (Object.getOwnPropertyNames(response).length != 2) {
- throw 'response has an unexpected number of fields';
- }
- if (!response.hasOwnProperty('error')) {
- throw 'response is missing required error field';
- }
- if (!response.hasOwnProperty('result')) {
- throw 'response is missing required result field';
- }
- if (response.error) {
- throw response.error;
- }
- resolve(response.result);
- } catch (e) {
- reject(e);
- }
- });
-
- xhr.open('POST', 'http://127.0.0.1:8765');
- xhr.send(JSON.stringify({action, version, params}));
- });
-}
-
-await invoke('createDeck', 6, {deck: 'test1'});
-const result = await invoke('deckNames', 6);
-console.log(`got list of decks: ${result}`);
-```
-
-### 认证
-
-Anki-Connect支持要求认证以便进行API请求。
-默认情况下,此支持是*禁用*的,但可以通过在Anki-Config的设置(工具->插件->AnkiConnect->配置)中设置`apiKey`字段为所需的字符串来启用。
-如果您已经这样做,您应该会看到[`requestPermission`](#requestpermission) API请求返回`true`作为`requireApiKey`。
-然后您必须在任何进一步的API请求体中包含一个名为`key`的附加参数,其值必须与配置的API密钥匹配。
-
-### 嘿,你能添加一个新的action来支持$FEATURE吗?
-
-Anki-Connect的主要目标是支持来自Yomichan浏览器扩展的实时闪卡创建。当前的API提供了所有必要的动作来实现这一点。我认识到Anki-Connect的角色已经从这一最初愿景演变,而且我很乐意审查新的功能请求。
-
-话虽如此,*本项目采用自助服务模式*。如果你想要一个新功能,请创建一个PR。我会审查它,如果看起来不错,就会合并。*没有附带拉取请求的添加新功能的请求将不会得到处理*。确保你的拉取请求满足以下标准:
-
-* 尝试匹配周围代码的风格。
-* 有附带的文档和示例。
-* 有验证操作的附带测试。
-* 实现在其他应用中有用的功能。
-
-## 支持的动作
-
-当前支持的动作的文档按类别分类并在下面引用。请注意,已弃用的API将继续运行,尽管未在此页面上列出,只要您的请求标有对应API可用时的版本号。搜索参数传递给Anki,更多信息请查看文档:https://docs.ankiweb.net/searching.html
-
-* [卡片操作](#card-actions)
-* [卡组操作](#deck-actions)
-* [图形界面操作](#graphical-actions)
-* [媒体操作](#media-actions)
-* [杂项操作](#miscellaneous-actions)
-* [模型操作](#model-actions)
-* [笔记操作](#note-actions)
-* [统计操作](#statistic-actions)
-
----
-
-### 卡片操作
-
-#### `getEaseFactors`
-
-* 返回一个数组,包含给定卡片的简易度因子(按相同顺序)。
-
-
- 示例请求:
-
- ```json
- {
- "action": "getEaseFactors",
- "version": 6,
- "params": {
- "cards": [1483959291685, 1483959293217]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [4100, 3900],
- "error": null
- }
- ```
-
-
-#### `setEaseFactors`
-
-* 通过卡片ID设置卡片的简易度因子;如果成功(所有卡片都存在)则返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "setEaseFactors",
- "version": 6,
- "params": {
- "cards": [1483959291685, 1483959293217],
- "easeFactors": [4100, 3900]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [true, true],
- "error": null
- }
- ```
-
-
-
-#### `setSpecificValueOfCard`
-
-* 设置单个卡片的特定值。由于更改卡片的某些值可能会在数据库中造成混乱,一些键需要将参数"warning_check"设置为True。
- 这可用于设置卡片的标志、更改其简易度因子、更改筛选卡组中的复习顺序以及更改列"data"(目前显然未被anki使用),以及许多其他值。
- 可以在[AnkiDroid的wiki](https://github.com/ankidroid/Anki-Android/wiki/Database-Structure)上找到值的列表及其各自的用途解释。
-
-
- 示例请求:
-
- ```json
- {
- "action": "setSpecificValueOfCard",
- "version": 6,
- "params": {
- "card": 1483959291685,
- "keys": ["flags", "odue"],
- "newValues": ["1", "-100"]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [true, true],
- "error": null
- }
- ```
-
-
-
-#### `suspend`
-
-* 通过卡片ID暂停卡片;如果成功(至少有一张卡片之前没有被暂停)则返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "suspend",
- "version": 6,
- "params": {
- "cards": [1483959291685, 1483959293217]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `unsuspend`
-
-* 通过卡片ID取消暂停卡片;如果成功(至少有一张卡片之前被暂停)则返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "unsuspend",
- "version": 6,
- "params": {
- "cards": [1483959291685, 1483959293217]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `suspended`
-
-* 通过ID检查卡片是否被暂停。如果被暂停则返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "suspended",
- "version": 6,
- "params": {
- "card": 1483959293217
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `areSuspended`
-
-* 返回一个数组,表示每张给定卡片是否被暂停(按相同顺序)。如果卡片不存在,则返回`null`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "areSuspended",
- "version": 6,
- "params": {
- "cards": [1483959291685, 1483959293217, 1234567891234]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [false, true, null],
- "error": null
- }
- ```
-
-
-#### `areDue`
-
-* 返回一个数组,表示每张给定卡片是否到期(按相同顺序)。*注意*:学习队列中有大间隔(超过20分钟)的卡片被视为未到期,直到其间隔时间过去为止,这与Anki在复习时对待它们的方式相匹配。
-
-
- 示例请求:
-
- ```json
- {
- "action": "areDue",
- "version": 6,
- "params": {
- "cards": [1483959291685, 1483959293217]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [false, true],
- "error": null
- }
- ```
-
-
-#### `getIntervals`
-
-* 返回一个数组,包含每个给定卡片ID的最近间隔,或者当`complete`为`true`时,返回每个给定卡片ID的所有间隔的二维数组。负间隔以秒为单位,正间隔以天为单位。
-
-
- 示例请求1:
-
- ```json
- {
- "action": "getIntervals",
- "version": 6,
- "params": {
- "cards": [1502298033753, 1502298036657]
- }
- }
- ```
-
-
-
- 示例结果1:
-
- ```json
- {
- "result": [-14400, 3],
- "error": null
- }
- ```
-
-
-
- 示例请求2:
-
- ```json
- {
- "action": "getIntervals",
- "version": 6,
- "params": {
- "cards": [1502298033753, 1502298036657],
- "complete": true
- }
- }
- ```
-
-
-
- 示例结果2:
-
- ```json
- {
- "result": [
- [-120, -180, -240, -300, -360, -14400],
- [-120, -180, -240, -300, -360, -14400, 1, 3]
- ],
- "error": null
- }
- ```
-
-
-#### `findCards`
-
-* 返回给定查询的卡片ID数组。功能上与`guiBrowse`相同,但不使用GUI以获得更好的性能。
-
-
- 示例请求:
-
- ```json
- {
- "action": "findCards",
- "version": 6,
- "params": {
- "query": "deck:current"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [1494723142483, 1494703460437, 1494703479525],
- "error": null
- }
- ```
-
-
-#### `cardsToNotes`
-
-* 返回给定卡片ID的笔记ID的无序数组。对于具有相同笔记的卡片,ID在数组中只给出一次。
-
-
- 示例请求:
-
- ```json
- {
- "action": "cardsToNotes",
- "version": 6,
- "params": {
- "cards": [1502098034045, 1502098034048, 1502298033753]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [1502098029797, 1502298025183],
- "error": null
- }
- ```
-
-
-#### `cardsModTime`
-
-* 返回一个对象列表,包含每个卡片ID的修改时间。
- 此功能比执行`cardsInfo`快约15倍。
-
-
- 示例请求:
-
- ```json
- {
- "action": "cardsModTime",
- "version": 6,
- "params": {
- "cards": [1498938915662, 1502098034048]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [
- {
- "cardId": 1498938915662,
- "mod": 1629454092
- }
- ],
- "error": null
- }
- ```
-
-
-
-#### `cardsInfo`
-
-* 返回一个对象列表,包含每个卡片ID的卡片字段、正反面(包括CSS)、笔记类型、卡片所属的笔记、卡组名称、最后修改时间戳以及简易度和间隔。
-
-
- 示例请求:
-
- ```json
- {
- "action": "cardsInfo",
- "version": 6,
- "params": {
- "cards": [1498938915662, 1502098034048]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [
- {
- "answer": "back content",
- "question": "front content",
- "deckName": "Default",
- "modelName": "Basic",
- "fieldOrder": 1,
- "fields": {
- "Front": {"value": "front content", "order": 0},
- "Back": {"value": "back content", "order": 1}
- },
- "css":"p {font-family:Arial;}",
- "cardId": 1498938915662,
- "interval": 16,
- "note":1502298033753,
- "ord": 1,
- "type": 0,
- "queue": 0,
- "due": 1,
- "reps": 1,
- "lapses": 0,
- "left": 6,
- "mod": 1629454092
- },
- {
- "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}
- },
- "css":"p {font-family:Arial;}",
- "cardId": 1502098034048,
- "interval": 23,
- "note":1502298033753,
- "ord": 1,
- "type": 0,
- "queue": 0,
- "due": 1,
- "reps": 1,
- "lapses": 0,
- "left": 6
- }
- ],
- "error": null
- }
- ```
-
-
-#### `forgetCards`
-
-* 忘记卡片,使卡片再次成为新卡片。
-
-
- 示例请求:
-
- ```json
- {
- "action": "forgetCards",
- "version": 6,
- "params": {
- "cards": [1498938915662, 1502098034048]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `relearnCards`
-
-* 使卡片成为"重新学习"状态。
-
-
- 示例请求:
-
- ```json
- {
- "action": "relearnCards",
- "version": 6,
- "params": {
- "cards": [1498938915662, 1502098034048]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `answerCards`
-
-* 回答卡片。简易度在1(重来)到4(简单)之间。将在回答前立即开始计时器。如果卡片存在则返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "answerCards",
- "version": 6,
- "params": {
- "answers": [
- {
- "cardId": 1498938915662,
- "ease": 2
- },
- {
- "cardId": 1502098034048,
- "ease": 4
- }
- ]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [true, true],
- "error": null
- }
- ```
-
-
-#### `setDueDate`
-
-* 设置到期日期。如果是新卡片,则将其转为复习卡片,并使其在特定日期到期。
- * 0 = 今天
- * 1! = 明天 + 将间隔更改为1
- * 3-7 = 随机选择3-7天
-
-
- 示例请求:
-
- ```json
- {
- "action": "setDueDate",
- "version": 6,
- "params": {
- "cards": [1498938915662, 1502098034048],
- "days": "3-7"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
----
-
-### 卡组操作
-
-#### `deckNames`
-
-* 获取当前用户的完整卡组名称列表。
-
-
- 示例请求:
-
- ```json
- {
- "action": "deckNames",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": ["Default"],
- "error": null
- }
- ```
-
-
-#### `deckNamesAndIds`
-
-* 获取当前用户的完整卡组名称及其对应ID的列表。
-
-
- 示例请求:
-
- ```json
- {
- "action": "deckNamesAndIds",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": {"Default": 1},
- "error": null
- }
- ```
-
-
-#### `getDecks`
-
-* 接受一个卡片ID数组,并返回一个对象,其中每个卡组名称作为键,其值是属于该卡组的给定卡片数组。
-
-
- 示例请求:
-
- ```json
- {
- "action": "getDecks",
- "version": 6,
- "params": {
- "cards": [1502298036657, 1502298033753, 1502032366472]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": {
- "Default": [1502032366472],
- "Japanese::JLPT N3": [1502298036657, 1502298033753]
- },
- "error": null
- }
- ```
-
-
-#### `createDeck`
-
-* 创建一个新的空卡组。不会覆盖同名的已存在卡组。
-
-
- 示例请求:
-
- ```json
- {
- "action": "createDeck",
- "version": 6,
- "params": {
- "deck": "Japanese::Tokyo"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": 1519323742721,
- "error": null
- }
- ```
-
-
-#### `changeDeck`
-
-* 将具有给定ID的卡片移动到不同的卡组,如果卡组尚不存在则创建它。
-
-
- 示例请求:
-
- ```json
- {
- "action": "changeDeck",
- "version": 6,
- "params": {
- "cards": [1502098034045, 1502098034048, 1502298033753],
- "deck": "Japanese::JLPT N3"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `deleteDecks`
-
-* 删除具有给定名称的卡组。
- 参数`cardsToo` *必须*被指定并设置为`true`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "deleteDecks",
- "version": 6,
- "params": {
- "decks": ["Japanese::JLPT N5", "Easy Spanish"],
- "cardsToo": true
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `getDeckConfig`
-
-* 获取给定卡组的配置组对象。
-
-
- 示例请求:
-
- ```json
- {
- "action": "getDeckConfig",
- "version": 6,
- "params": {
- "deck": "Default"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": {
- "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
- },
- "error": null
- }
- ```
-
-
-#### `saveDeckConfig`
-
-* 保存给定的配置组,成功时返回`true`,如果配置组的ID无效(例如不存在)则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "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
- }
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `setDeckConfigId`
-
-* 将给定卡组的配置组更改为具有给定ID的配置组。成功时返回`true`,如果给定的配置组或任何给定的卡组不存在则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "setDeckConfigId",
- "version": 6,
- "params": {
- "decks": ["Default"],
- "configId": 1
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `cloneDeckConfigId`
-
-* 使用给定的名称创建一个新的配置组,从具有给定ID的组克隆,或者如果未指定,则从默认组克隆。返回新配置组的ID,或者如果指定的要克隆的组不存在,则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "cloneDeckConfigId",
- "version": 6,
- "params": {
- "name": "Copy of Default",
- "cloneFrom": 1
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": 1502972374573,
- "error": null
- }
- ```
-
-
-#### `removeDeckConfigId`
-
-* 移除具有给定ID的配置组,如果成功则返回`true`,如果尝试移除默认配置组(ID = 1)或不存在的配置组则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "removeDeckConfigId",
- "version": 6,
- "params": {
- "configId": 1502972374573
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `getDeckStats`
-
-* 获取给定卡组的统计信息,如总卡片数和到期卡片数。
-
-
- 示例请求:
-
- ```json
- {
- "action": "getDeckStats",
- "version": 6,
- "params": {
- "decks": ["Japanese::JLPT N5", "Easy Spanish"]
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": {
- "1651445861967": {
- "deck_id": 1651445861967,
- "name": "Japanese::JLPT N5",
- "new_count": 20,
- "learn_count": 0,
- "review_count": 0,
- "total_in_deck": 1506
- },
- "1651445861960": {
- "deck_id": 1651445861960,
- "name": "Easy Spanish",
- "new_count": 26,
- "learn_count": 10,
- "review_count": 5,
- "total_in_deck": 852
- }
- },
- "error": null
- }
- ```
-
-
----
-
-### 图形界面操作
-
-#### `guiBrowse`
-
-* 调用*卡片浏览器*对话框并搜索给定查询。返回找到的卡片标识符数组。查询语法[在此处有文档](https://docs.ankiweb.net/searching.html)。
-
- 可选地,可以提供`reorderCards`属性来重新排序*卡片浏览器*中显示的卡片。
- 这是一个包含`order`和`columnId`对象的数组。`order`可以是`ascending`或`descending`,而`columnId`可以是几个列标识符之一(如在[Anki源代码](https://github.com/ankitects/anki/blob/main/rslib/src/browser_table.rs)中记录的)。
- 指定的列需要在*卡片浏览器*中可见。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiBrowse",
- "version": 6,
- "params": {
- "query": "deck:current",
- "reorderCards": {
- "order": "descending",
- "columnId": "noteCrt"
- }
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [1494723142483, 1494703460437, 1494703479525],
- "error": null
- }
- ```
-
-
-#### `guiSelectCard`
-
-* 找到*卡片浏览器*对话框的打开实例,并根据卡片标识符选择一张卡片。
- 如果*卡片浏览器*是打开的,返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiSelectCard",
- "version": 6,
- "params": {
- "card": 1494723142483
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `guiSelectedNotes`
-
-* 找到*卡片浏览器*对话框的打开实例,并返回选中笔记的标识符数组。如果浏览器未打开,则返回空列表。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiSelectedNotes",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": [1494723142483, 1494703460437, 1494703479525],
- "error": null
- }
- ```
-
-
-#### `guiAddCards`
-
-* 调用*添加卡片*对话框,使用给定的卡组和模型预设笔记,带有提供的字段值和标签。
- 多次调用会关闭旧窗口并_重新打开窗口_,使用新提供的值。
-
- 可以通过`audio`、`video`和`picture`键将音频、视频和图片文件嵌入到字段中。
- 请参考`addNote`和`storeMediaFile`的文档,了解这些字段的说明。
-
- 结果是如果用户选择确认*添加卡片*对话框,将添加的笔记的ID。
-
-
- 示例请求:
-
- ```json
- {
- "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"
- ],
- "picture": [{
- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/1/13/EU-Romania.svg/285px-EU-Romania.svg.png",
- "filename": "romania.png",
- "fields": [
- "Extra"
- ]
- }]
- }
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": 1496198395707,
- "error": null
- }
- ```
-
-
-#### `guiEditNote`
-
-* 打开*编辑*对话框,显示对应于给定笔记ID的笔记。
- 该对话框类似于*编辑当前*对话框,但:
-
- * 有一个预览按钮,用于预览笔记的卡片
- * 有一个浏览按钮,用于打开浏览器并显示这些卡片
- * 有上一个/后退按钮,用于导航对话框的历史
- * 没有带有关闭按钮的栏
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiEditNote",
- "version": 6,
- "params": {
- "note": 1649198355435
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `guiCurrentCard`
-
-* 返回有关当前卡片的信息,如果不在复习模式,则返回`null`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiCurrentCard",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "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`
-
-* 启动或重置当前卡片的`timerStarted`值。这对于将开始时间推迟到通过API显示卡片时很有用,从而在调用`guiAnswerCard`时使记录的回答卡片所花费的时间更准确。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiStartCardTimer",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `guiShowQuestion`
-
-* 显示当前卡片的问题文本;如果处于复习模式则返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiShowQuestion",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `guiShowAnswer`
-
-* 显示当前卡片的答案文本;如果处于复习模式则返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiShowAnswer",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `guiAnswerCard`
-
-* 回答当前卡片;如果成功则返回`true`,否则返回`false`。注意,在Anki接受任何答案之前,必须先显示当前卡片的答案。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiAnswerCard",
- "version": 6,
- "params": {
- "ease": 1
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `guiUndo`
-
-* 撤销最后一个动作/卡片;如果成功则返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiUndo",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `guiDeckOverview`
-
-* 为具有给定名称的卡组打开*卡组概览*对话框;如果成功则返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiDeckOverview",
- "version": 6,
- "params": {
- "name": "Default"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `guiDeckBrowser`
-
-* 打开*卡组浏览器*对话框。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiDeckBrowser",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `guiDeckReview`
-
-* 开始复习具有给定名称的卡组;如果成功则返回`true`,否则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiDeckReview",
- "version": 6,
- "params": {
- "name": "Default"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `guiImportFile`
-
-* 调用*导入...(Ctrl+Shift+I)*对话框,并可选择提供文件路径。弹出对话框供用户审核导入。支持Anki支持的所有文件类型。如果未提供路径,则显示打开文件对话框。在Windows上的路径中必须使用正斜杠。仅支持Anki 2.1.52+。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiImportFile",
- "version": 6,
- "params": {
- "path": "C:/Users/Desktop/cards.txt"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `guiExitAnki`
-
-* 安排一个请求来优雅地关闭Anki。此操作是异步的,因此它会立即返回,而不会等待Anki进程实际终止。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiExitAnki",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `guiCheckDatabase`
-
-* 请求进行数据库检查,但立即返回而不等待检查完成。因此,即使在数据库检查过程中检测到错误,此操作也将始终返回`true`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "guiCheckDatabase",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
----
-
-### 媒体操作
-
-#### `storeMediaFile`
-
-* 将具有指定base64编码内容的文件存储在媒体文件夹中。或者,您可以指定绝对文件路径,或者从中下载文件的URL。如果提供了`data`、`path`和`url`中的多个,将首先使用`data`字段,然后是`path`,最后是`url`。为了防止Anki删除不被任何卡片使用的文件(例如配置文件),请在文件名前加下划线。这些文件仍然会同步到AnkiWeb。
- 默认情况下,将删除任何同名的现有文件。设置`deleteExisting`为false可以通过[让Anki为新文件提供非冲突的名称](https://github.com/ankitects/anki/blob/aeba725d3ea9628c73300648f748140db3fdd5ed/rslib/src/media/files.rs#L194)来防止这种情况。
-
-
- 示例请求(相对路径):
-
- ```json
- {
- "action": "storeMediaFile",
- "version": 6,
- "params": {
- "filename": "_hello.txt",
- "data": "SGVsbG8sIHdvcmxkIQ=="
- }
- }
- ```
-
- *`_hello.txt`的内容*:
-
- ```
- Hello world!
- ```
-
-
-
- 示例结果(相对路径):
-
- ```json
- {
- "result": "_hello.txt",
- "error": null
- }
- ```
-
-
-
- 示例请求(绝对路径):
-
- ```json
- {
- "action": "storeMediaFile",
- "version": 6,
- "params": {
- "filename": "_hello.txt",
- "path": "/path/to/file"
- }
- }
- ```
-
-
-
- 示例结果(绝对路径):
-
- ```json
- {
- "result": "_hello.txt",
- "error": null
- }
- ```
-
-
-
- 示例请求(url):
-
- ```json
- {
- "action": "storeMediaFile",
- "version": 6,
- "params": {
- "filename": "_hello.txt",
- "url": "https://url.to.file"
- }
- }
- ```
-
-
-
- 示例结果(url):
-
- ```json
- {
- "result": "_hello.txt",
- "error": null
- }
- ```
-
-
-#### `retrieveMediaFile`
-
-* 检索指定文件的base64编码内容,如果文件不存在则返回`false`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "retrieveMediaFile",
- "version": 6,
- "params": {
- "filename": "_hello.txt"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": "SGVsbG8sIHdvcmxkIQ==",
- "error": null
- }
- ```
-
-
-#### `getMediaFilesNames`
-
-* 获取与模式匹配的媒体文件名。默认返回所有名称。
-
-
- 示例请求:
-
- ```json
- {
- "action": "getMediaFilesNames",
- "version": 6,
- "params": {
- "pattern": "_hell*.txt"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": ["_hello.txt"],
- "error": null
- }
- ```
-
-
-#### `getMediaDirPath`
-
-* 获取当前打开的配置文件的`collection.media`文件夹的完整路径。
-
-
- 示例请求:
-
- ```json
- {
- "action": "getMediaDirPath",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": "/home/user/.local/share/Anki2/Main/collection.media",
- "error": null
- }
- ```
-
-
-#### `deleteMediaFile`
-
-* 删除媒体文件夹中的指定文件。
-
-
- 示例请求:
-
- ```json
- {
- "action": "deleteMediaFile",
- "version": 6,
- "params": {
- "filename": "_hello.txt"
- }
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
----
-
-### 杂项操作
-
-#### `requestPermission`
-
-* 请求使用此插件公开的API的权限。此方法不需要API密钥,是唯一接受来自任何来源的请求的方法;其他方法只接受来自受信任来源的请求,这些来源列在插件配置的`webCorsOriginList`下。默认情况下,`localhost`是受信任的。
-
- 从不受信任的来源调用此方法将在Anki中显示一个弹出窗口,询问用户是否允许您的来源使用API;来自受信任来源的调用将返回结果而不显示弹出窗口。
- 在拒绝许可时,用户还可以选择忽略来自该来源的进一步许可请求。这些来源最终会出现在`ignoreOriginList`中,可通过插件配置进行编辑。
-
- 结果始终包含`permission`字段,该字段反过来包含字符串`granted`或`denied`,对应于您的来源是否受信任。如果您的来源受信任,还将返回字段`requireApiKey`(如果需要则为`true`)和`version`。
-
- 这应该是您进行的第一个调用,以确保您的应用程序和Anki-Connect能够相互正确通信。新版本的Anki-Connect向后兼容;只要您使用在报告的Anki-Connect版本或更早版本中可用的操作,一切都应该正常工作。
-
-
- 示例请求:
-
- ```json
- {
- "action": "requestPermission",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": {
- "permission": "granted",
- "requireApiKey": false,
- "version": 6
- },
- "error": null
- }
- ```
-
- ```json
- {
- "result": {
- "permission": "denied"
- },
- "error": null
- }
- ```
-
-
-#### `version`
-
-* 获取此插件公开的API的版本。目前定义了版本`1`到`6`。
-
-
- 示例请求:
-
- ```json
- {
- "action": "version",
- "version": 6
- }
- ```
-
-
-
- 示例结果:
-
- ```json
- {
- "result": 6,
- "error": null
- }
- ```
-
-
-
-#### `apiReflect`
-
-* 获取有关可用 AnkiConnect API 的信息。请求支持以下参数:
-
- * `scopes` - 要获取反射信息的作用域数组。
- 目前唯一支持的值是 `"actions"`。
- * `actions` - 可以是 `null` 或者 API 方法名称的数组。
- 如果值为 `null`,结果将列出所有可用的 API 动作。
- 如果值是字符串数组,结果将只包含该数组中存在的动作。
-
- 结果将包含使用了哪些作用域及每个作用域的值。
- 例如,`"actions"` 作用域将包含一个 `"actions"` 属性,其中包含支持的动作名称列表。
-
-
- 请求示例:
-
- ```json
- {
- "action": "apiReflect",
- "version": 6,
- "params": {
- "scopes": ["actions", "invalidType"],
- "actions": ["apiReflect", "invalidMethod"]
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": {
- "scopes": ["actions"],
- "actions": ["apiReflect"]
- },
- "error": null
- }
- ```
-
-
-#### `sync`
-
-* 将本地 Anki 集合与 AnkiWeb 同步。
-
-
- 请求示例:
-
- ```json
- {
- "action": "sync",
- "version": 6
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `getProfiles`
-
-* 获取个人资料列表。
-
-
- 请求示例:
-
- ```json
- {
- "action": "getProfiles",
- "version": 6
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": ["User 1"],
- "error": null
- }
- ```
-
-
-#### `getActiveProfile`
-
-* 获取当前活动个人资料。
-
-
- 请求示例:
-
- ```json
- {
- "action": "getActiveProfile",
- "version": 6
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": "User 1",
- "error": null
- }
- ```
-
-
-
-#### `loadProfile`
-
-* 选择请求中指定的个人资料。
-
-
- 请求示例:
-
- ```json
- {
- "action": "loadProfile",
- "version": 6,
- "params": {
- "name": "user1"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `multi`
-
-* 在一个请求中执行多个操作,返回一个数组,其中包含每个操作的响应(按给定顺序)。
-
-
- 请求示例:
-
- ```json
- {
- "action": "multi",
- "version": 6,
- "params": {
- "actions": [
- {
- "action": "deckNames"
- },
- {
- "action": "deckNames",
- "version": 6
- },
- {
- "action": "invalidAction",
- "params": {"useless": "param"}
- },
- {
- "action": "invalidAction",
- "params": {"useless": "param"},
- "version": 6
- }
- ]
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": [
- ["Default"],
- {"result": ["Default"], "error": null},
- {"result": null, "error": "unsupported action"},
- {"result": null, "error": "unsupported action"}
- ],
- "error": null
- }
- ```
-
-
-#### `exportPackage`
-
-* 将指定的牌组以 `.apkg` 格式导出。如果成功则返回 `true`,否则返回 `false`。可以指定可选属性
- `includeSched`(默认为 `false`)以包含卡片的调度数据。
-
-
- 请求示例:
-
- ```json
- {
- "action": "exportPackage",
- "version": 6,
- "params": {
- "deck": "Default",
- "path": "/data/Deck.apkg",
- "includeSched": true
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `importPackage`
-
-* 将 `.apkg` 格式的文件导入集合中。如果成功则返回 `true`,否则返回 `false`。
- 注意,文件路径是相对于 Anki 的 collection.media 文件夹,而不是相对于客户端。
-
-
- 请求示例:
-
- ```json
- {
- "action": "importPackage",
- "version": 6,
- "params": {
- "path": "/data/Deck.apkg"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `reloadCollection`
-
-* 告诉 Anki 从数据库重新加载所有数据。
-
-
- 请求示例:
-
- ```json
- {
- "action": "reloadCollection",
- "version": 6
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
----
-
-### 模型(笔记类型)操作
-
-#### `modelNames`
-
-* 获取当前用户的完整模型名称列表。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelNames",
- "version": 6
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": ["Basic", "Basic (and reversed card)"],
- "error": null
- }
- ```
-
-
-#### `modelNamesAndIds`
-
-* 获取当前用户的完整模型名称及其对应的 ID 列表。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelNamesAndIds",
- "version": 6
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": {
- "Basic": 1483883011648,
- "Basic (and reversed card)": 1483883011644,
- "Basic (optional reversed card)": 1483883011631,
- "Cloze": 1483883011630
- },
- "error": null
- }
- ```
-
-
-#### `findModelsById`
-
-* 根据提供的模型 ID 从当前用户获取模型列表。
-
-
- 请求示例:
-
- ```json
- {
- "action": "findModelsById",
- "version": 6,
- "params": {
- "modelIds": [1704387367119, 1704387398570]
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": [
- {
- "id": 1704387367119,
- "name": "Basic",
- "type": 0,
- "mod": 1704387367,
- "usn": -1,
- "sortf": 0,
- "did": null,
- "tmpls": [
- {
- "name": "Card 1",
- "ord": 0,
- "qfmt": "{{Front}}",
- "afmt": "{{FrontSide}}\n\n
\n\n{{Back}}",
- "bqfmt": "",
- "bafmt": "",
- "did": null,
- "bfont": "",
- "bsize": 0,
- "id": 9176047152973362695
- }
- ],
- "flds": [
- {
- "name": "Front",
- "ord": 0,
- "sticky": false,
- "rtl": false,
- "font": "Arial",
- "size": 20,
- "description": "",
- "plainText": false,
- "collapsed": false,
- "excludeFromSearch": false,
- "id": 2453723143453745216,
- "tag": null,
- "preventDeletion": false
- },
- {
- "name": "Back",
- "ord": 1,
- "sticky": false,
- "rtl": false,
- "font": "Arial",
- "size": 20,
- "description": "",
- "plainText": false,
- "collapsed": false,
- "excludeFromSearch": false,
- "id": -4853200230425436781,
- "tag": null,
- "preventDeletion": false
- }
- ],
- "css": ".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n",
- "latexPre": "\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n",
- "latexPost": "\\end{document}",
- "latexsvg": false,
- "req": [
- [
- 0,
- "any",
- [
- 0
- ]
- ]
- ],
- "originalStockKind": 1
- },
- {
- "id": 1704387398570,
- "name": "Basic (and reversed card)",
- "type": 0,
- "mod": 1704387398,
- "usn": -1,
- "sortf": 0,
- "did": null,
- "tmpls": [
- {
- "name": "Card 1",
- "ord": 0,
- "qfmt": "{{Front}}",
- "afmt": "{{FrontSide}}\n\n
\n\n{{Back}}",
- "bqfmt": "",
- "bafmt": "",
- "did": null,
- "bfont": "",
- "bsize": 0,
- "id": 1689886528158874152
- },
- {
- "name": "Card 2",
- "ord": 1,
- "qfmt": "{{Back}}",
- "afmt": "{{FrontSide}}\n\n
\n\n{{Front}}",
- "bqfmt": "",
- "bafmt": "",
- "did": null,
- "bfont": "",
- "bsize": 0,
- "id": -7839609225644824587
- }
- ],
- "flds": [
- {
- "name": "Front",
- "ord": 0,
- "sticky": false,
- "rtl": false,
- "font": "Arial",
- "size": 20,
- "description": "",
- "plainText": false,
- "collapsed": false,
- "excludeFromSearch": false,
- "id": -7787837672455357996,
- "tag": null,
- "preventDeletion": false
- },
- {
- "name": "Back",
- "ord": 1,
- "sticky": false,
- "rtl": false,
- "font": "Arial",
- "size": 20,
- "description": "",
- "plainText": false,
- "collapsed": false,
- "excludeFromSearch": false,
- "id": 6364828289839985081,
- "tag": null,
- "preventDeletion": false
- }
- ],
- "css": ".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n",
- "latexPre": "\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n",
- "latexPost": "\\end{document}",
- "latexsvg": false,
- "req": [
- [
- 0,
- "any",
- [
- 0
- ]
- ],
- [
- 1,
- "any",
- [
- 1
- ]
- ]
- ],
- "originalStockKind": 1
- }
- ],
- "error": null
- }
- ```
-
-
-
-#### `findModelsByName`
-
-* 根据提供的模型名称从当前用户获取模型列表。
-
-
- 请求示例:
-
- ```json
- {
- "action": "findModelsByName",
- "version": 6,
- "params": {
- "modelNames": ["Basic", "Basic (and reversed card)"]
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": [
- {
- "id": 1704387367119,
- "name": "Basic",
- "type": 0,
- "mod": 1704387367,
- "usn": -1,
- "sortf": 0,
- "did": null,
- "tmpls": [
- {
- "name": "Card 1",
- "ord": 0,
- "qfmt": "{{Front}}",
- "afmt": "{{FrontSide}}\n\n
\n\n{{Back}}",
- "bqfmt": "",
- "bafmt": "",
- "did": null,
- "bfont": "",
- "bsize": 0,
- "id": 9176047152973362695
- }
- ],
- "flds": [
- {
- "name": "Front",
- "ord": 0,
- "sticky": false,
- "rtl": false,
- "font": "Arial",
- "size": 20,
- "description": "",
- "plainText": false,
- "collapsed": false,
- "excludeFromSearch": false,
- "id": 2453723143453745216,
- "tag": null,
- "preventDeletion": false
- },
- {
- "name": "Back",
- "ord": 1,
- "sticky": false,
- "rtl": false,
- "font": "Arial",
- "size": 20,
- "description": "",
- "plainText": false,
- "collapsed": false,
- "excludeFromSearch": false,
- "id": -4853200230425436781,
- "tag": null,
- "preventDeletion": false
- }
- ],
- "css": ".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n",
- "latexPre": "\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n",
- "latexPost": "\\end{document}",
- "latexsvg": false,
- "req": [
- [
- 0,
- "any",
- [
- 0
- ]
- ]
- ],
- "originalStockKind": 1
- },
- {
- "id": 1704387398570,
- "name": "Basic (and reversed card)",
- "type": 0,
- "mod": 1704387398,
- "usn": -1,
- "sortf": 0,
- "did": null,
- "tmpls": [
- {
- "name": "Card 1",
- "ord": 0,
- "qfmt": "{{Front}}",
- "afmt": "{{FrontSide}}\n\n
\n\n{{Back}}",
- "bqfmt": "",
- "bafmt": "",
- "did": null,
- "bfont": "",
- "bsize": 0,
- "id": 1689886528158874152
- },
- {
- "name": "Card 2",
- "ord": 1,
- "qfmt": "{{Back}}",
- "afmt": "{{FrontSide}}\n\n
\n\n{{Front}}",
- "bqfmt": "",
- "bafmt": "",
- "did": null,
- "bfont": "",
- "bsize": 0,
- "id": -7839609225644824587
- }
- ],
- "flds": [
- {
- "name": "Front",
- "ord": 0,
- "sticky": false,
- "rtl": false,
- "font": "Arial",
- "size": 20,
- "description": "",
- "plainText": false,
- "collapsed": false,
- "excludeFromSearch": false,
- "id": -7787837672455357996,
- "tag": null,
- "preventDeletion": false
- },
- {
- "name": "Back",
- "ord": 1,
- "sticky": false,
- "rtl": false,
- "font": "Arial",
- "size": 20,
- "description": "",
- "plainText": false,
- "collapsed": false,
- "excludeFromSearch": false,
- "id": 6364828289839985081,
- "tag": null,
- "preventDeletion": false
- }
- ],
- "css": ".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n",
- "latexPre": "\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n",
- "latexPost": "\\end{document}",
- "latexsvg": false,
- "req": [
- [
- 0,
- "any",
- [
- 0
- ]
- ],
- [
- 1,
- "any",
- [
- 1
- ]
- ]
- ],
- "originalStockKind": 1
- }
- ],
- "error": null
- }
- ```
-
-
-#### `modelFieldNames`
-
-* 获取提供的模型名称的完整字段名称列表。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldNames",
- "version": 6,
- "params": {
- "modelName": "Basic"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": ["Front", "Back"],
- "error": null
- }
- ```
-
-
-#### `modelFieldDescriptions`
-
-* 获取提供的模型名称的完整字段描述列表(当字段为空时在 GUI 编辑器中显示的文本)。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldDescriptions",
- "version": 6,
- "params": {
- "modelName": "Basic"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": ["", ""],
- "error": null
- }
- ```
-
-
-#### `modelFieldFonts`
-
-* 获取完整的字体列表及其字体大小。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldFonts",
- "version": 6,
- "params": {
- "modelName": "Basic"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": {
- "Front": {
- "font": "Arial",
- "size": 20
- },
- "Back": {
- "font": "Arial",
- "size": 20
- }
- },
- "error": null
- }
- ```
-
-
-#### `modelFieldsOnTemplates`
-
-* 返回一个对象,指示给定模型名称的每个卡片模板的问题侧和答案侧的字段。
- 问题侧在每个数组中首先给出。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldsOnTemplates",
- "version": 6,
- "params": {
- "modelName": "Basic (and reversed card)"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": {
- "Card 1": [["Front"], ["Back"]],
- "Card 2": [["Back"], ["Front"]]
- },
- "error": null
- }
- ```
-
-
-#### `createModel`
-
-* 创建一个新模型以在 Anki 中使用。用户必须提供 `modelName`、`inOrderFields` 和 `cardTemplates` 来
- 在模型中使用。有可选字段 `css` 和 `isCloze`。如果未指定,`css` 将使用默认的 Anki CSS,`isCloze` 将等于 `false`。如果 `isCloze` 为 `true`,则模型将创建为填空题型。
-
- 可以为 `cardTemplates` 的每个条目提供可选的 `Name` 字段。默认情况下,
- 卡片名称将是 `Card 1`, `Card 2` 等。
-
-
- 请求示例:
-
- ```json
- {
- "action": "createModel",
- "version": 6,
- "params": {
- "modelName": "newModelName",
- "inOrderFields": ["Field1", "Field2", "Field3"],
- "css": "Optional CSS with default to builtin css",
- "isCloze": false,
- "cardTemplates": [
- {
- "Name": "My Card 1",
- "Front": "Front html {{Field1}}",
- "Back": "Back html {{Field2}}"
- }
- ]
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result":{
- "sortf":0,
- "did":1,
- "latexPre":"\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n",
- "latexPost":"\\end{document}",
- "mod":1551462107,
- "usn":-1,
- "vers":[
-
- ],
- "type":0,
- "css":".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n",
- "name":"TestApiModel",
- "flds":[
- {
- "name":"Field1",
- "ord":0,
- "sticky":false,
- "rtl":false,
- "font":"Arial",
- "size":20,
- "media":[
-
- ]
- },
- {
- "name":"Field2",
- "ord":1,
- "sticky":false,
- "rtl":false,
- "font":"Arial",
- "size":20,
- "media":[
-
- ]
- }
- ],
- "tmpls":[
- {
- "name":"My Card 1",
- "ord":0,
- "qfmt":"",
- "afmt":"This is the back of the card {{Field2}}",
- "did":null,
- "bqfmt":"",
- "bafmt":""
- }
- ],
- "tags":[
-
- ],
- "id":1551462107104,
- "req":[
- [
- 0,
- "none",
- [
-
- ]
- ]
- ]
- },
- "error":null
- }
- ```
-
-
-#### `modelTemplates`
-
-* 返回一个对象,指示与提供的模型名称相连接的每个卡片的模板内容。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelTemplates",
- "version": 6,
- "params": {
- "modelName": "Basic (and reversed card)"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": {
- "Card 1": {
- "Front": "{{Front}}",
- "Back": "{{FrontSide}}\n\n
\n\n{{Back}}"
- },
- "Card 2": {
- "Front": "{{Back}}",
- "Back": "{{FrontSide}}\n\n
\n\n{{Front}}"
- }
- },
- "error": null
- }
- ```
-
-
-#### `modelStyling`
-
-* 获取按名称提供的模型的 CSS 样式。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelStyling",
- "version": 6,
- "params": {
- "modelName": "Basic (and reversed card)"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": {
- "css": ".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n"
- },
- "error": null
- }
- ```
-
-
-#### `updateModelTemplates`
-
-* 修改现有模型的模板(通过名称指定)。只有指定的卡片和指定的侧面会被修改。
- 如果请求中不包括现有卡片或侧面,它将保持不变。
-
-
- 请求示例:
-
- ```json
- {
- "action": "updateModelTemplates",
- "version": 6,
- "params": {
- "model": {
- "name": "Custom",
- "templates": {
- "Card 1": {
- "Front": "{{Question}}?",
- "Back": "{{Answer}}!"
- }
- }
- }
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `updateModelStyling`
-
-* 修改现有模型的 CSS 样式(通过名称指定)。
-
-
- 请求示例:
-
- ```json
- {
- "action": "updateModelStyling",
- "version": 6,
- "params": {
- "model": {
- "name": "Custom",
- "css": "p { color: blue; }"
- }
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `findAndReplaceInModels`
-
-* 在现有模型中查找并替换字符串(通过模型名称)。通过设置为 true/false 自定义在前面、后面或 CSS 中替换。
-
-
- 请求示例:
-
- ```json
- {
- "action": "findAndReplaceInModels",
- "version": 6,
- "params": {
- "model": {
- "modelName": "",
- "findText": "text_to_replace",
- "replaceText": "replace_with_text",
- "front": true,
- "back": true,
- "css": true
- }
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": 1,
- "error": null
- }
- ```
-
-
-#### `modelTemplateRename`
-
-* 重命名现有模型中的模板。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelTemplateRename",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "oldTemplateName": "Card 1",
- "newTemplateName": "Card 1 renamed"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `modelTemplateReposition`
-
-* 重新定位现有模型中的模板。
-
- `index` 的值从 0 开始。例如,索引 `0` 将模板放在第一个位置,索引 `2` 将模板放在第三个位置。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelTemplateReposition",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "templateName": "Card 1",
- "index": 1
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `modelTemplateAdd`
-
-* 通过名称向现有模型添加模板。如果要更新现有模板,请使用 `updateModelTemplates`。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelTemplateAdd",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "template": {
- "Name": "Card 3",
- "Front": "Front html {{Field1}}",
- "Back": "Back html {{Field2}}"
- }
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `modelTemplateRemove`
-
-* 从现有模型中移除模板。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelTemplateRemove",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "templateName": "Card 1"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `modelFieldRename`
-
-* 重命名给定模型的字段名称。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldRename",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "oldFieldName": "Front",
- "newFieldName": "FrontRenamed"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `modelFieldReposition`
-
-* 重新定位给定模型的字段列表中的字段。
-
- `index` 的值从 0 开始。例如,索引 `0` 将字段放在第一个位置,索引 `2` 将字段放在第三个位置。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldReposition",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "fieldName": "Back",
- "index": 0
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `modelFieldAdd`
-
-* 在给定模型中创建新字段。
-
- 可以选择提供 `index` 值,其工作方式与 `modelFieldReposition` 中的索引完全相同。默认情况下,字段将添加到字段列表的末尾。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldAdd",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "fieldName": "NewField",
- "index": 0
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `modelFieldRemove`
-
-* 删除给定模型中的字段。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldRemove",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "fieldName": "Front"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `modelFieldSetFont`
-
-* 设置给定模型中字段的字体。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldSetFont",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "fieldName": "Front",
- "font": "Courier"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `modelFieldSetFontSize`
-
-* 设置给定模型中字段的字体大小。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldSetFontSize",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "fieldName": "Front",
- "fontSize": 10
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `modelFieldSetDescription`
-
-* 设置给定模型中字段的描述(当字段为空时在 GUI 编辑器中看到的文本)。
-
- 旧版本的 Anki(2.1.49 及以下)没有字段描述。在这种情况下,将返回 `false`。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldSetDescription",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "fieldName": "Front",
- "description": "example field description"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
----
-
-### 笔记操作
-
-#### `addNote`
-
-* 使用给定的牌组和模型创建一个笔记,包含提供的字段值和标签。成功时返回创建的笔记的标识符,
- 失败时返回 `null`。
-
- Anki-Connect 可以下载音频、视频和图片文件,并将它们嵌入到新创建的笔记中。相应的 `audio`、`video` 和 `picture` 笔记成员是
- 可选的,可以省略。如果选择包含它们中的任何一个,它们应该包含一个对象或一个对象数组,
- 带有必填的 `filename` 字段和 `data`、`path` 或 `url` 之一。有关这些字段的解释,请参阅 `storeMediaFile` 的文档。
- 可以选择提供 `skipHash` 字段,以跳过包含与提供的值匹配的 MD5 哈希的文件。
- 这对于避免保存错误页面和存根文件很有用。
- `fields` 成员是一个字段列表,这些字段应该在卡片显示在 Anki 中时播放音频或视频,或显示图片。
- `options` 组中的 `allowDuplicate` 成员可以设置为 true 以启用添加重复卡片。
- 通常不能添加重复卡片,会触发异常。
-
- `options` 中的 `duplicateScope` 成员可用于指定检查重复项的范围。
- 值为 `"deck"` 将只检查目标牌组中的重复项;任何其他值将检查整个集合。
-
- `duplicateScopeOptions` 对象可用于指定一些附加设置:
-
- * `duplicateScopeOptions.deckName` 将指定用于检查重复项的牌组。如果未定义或为 `null`,将使用目标牌组。
- * `duplicateScopeOptions.checkChildren` 将更改是否在子牌组中检查重复卡片。默认值为 `false`。
- * `duplicateScopeOptions.checkAllModels` 指定是否在所有笔记类型中执行重复检查。默认值为 `false`。
-
-
- 请求示例:
-
- ```json
- {
- "action": "addNote",
- "version": 6,
- "params": {
- "note": {
- "deckName": "Default",
- "modelName": "Basic",
- "fields": {
- "Front": "front content",
- "Back": "back content"
- },
- "options": {
- "allowDuplicate": false,
- "duplicateScope": "deck",
- "duplicateScopeOptions": {
- "deckName": "Default",
- "checkChildren": false,
- "checkAllModels": false
- }
- },
- "tags": [
- "yomichan"
- ],
- "audio": [{
- "url": "https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kanji=猫&kana=ねこ",
- "filename": "yomichan_ねこ_猫.mp3",
- "skipHash": "7e2c2f954ef6051373ba916f000168dc",
- "fields": [
- "Front"
- ]
- }],
- "video": [{
- "url": "https://cdn.videvo.net/videvo_files/video/free/2015-06/small_watermarked/Contador_Glam_preview.mp4",
- "filename": "countdown.mp4",
- "skipHash": "4117e8aab0d37534d9c8eac362388bbe",
- "fields": [
- "Back"
- ]
- }],
- "picture": [{
- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c7/A_black_cat_named_Tilly.jpg/220px-A_black_cat_named_Tilly.jpg",
- "filename": "black_cat.jpg",
- "skipHash": "8d6e4646dfae812bf39651b59d7429ce",
- "fields": [
- "Back"
- ]
- }]
- }
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": 1496198395707,
- "error": null
- }
- ```
-
-
-#### `addNotes`
-
-* 使用给定的牌组和模型创建多个笔记,包含提供的字段值和标签。返回一个数组,
- 包含创建的笔记的标识符。如有任何错误,将收集并返回所有错误。
-* 有关 `notes` 数组中对象的解释,请参阅 `addNote` 的文档。
-
-
- 请求示例:
-
- ```json
- {
- "action":"addNotes",
- "version":6,
- "params":{
- "notes":[
- {
- "deckName":"College::PluginDev",
- "modelName":"non_existent_model",
- "fields":{
- "Front":"front",
- "Back":"bak"
- }
- },
- {
- "deckName":"College::PluginDev",
- "modelName":"Basic",
- "fields":{
- "Front":"front",
- "Back":"bak"
- }
- }
- ]
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result":null,
- "error":"['model was not found: non_existent_model']"
- }
- ```
-
-
-#### `canAddNotes`
-
-* 接受一个对象数组,这些对象定义候选笔记的参数(参见 `addNote`),并返回一个布尔值数组,
- 指示相应索引处的参数是否可用于创建新笔记。
-
-
- 请求示例:
-
- ```json
- {
- "action": "canAddNotes",
- "version": 6,
- "params": {
- "notes": [
- {
- "deckName": "Default",
- "modelName": "Basic",
- "fields": {
- "Front": "front content",
- "Back": "back content"
- },
- "tags": [
- "yomichan"
- ]
- }
- ]
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": [true],
- "error": null
- }
- ```
-
-
-#### `canAddNotesWithErrorDetail`
-
-* 接受一个对象数组,这些对象定义候选笔记的参数(参见 `addNote`),并返回一个对象数组,
- 包含 `canAdd` 和 `error` 字段。
-
- * `canAdd` 指示相应索引处的参数是否可用于创建新笔记。
- * `error` 包含无法添加笔记的原因说明。
-
-
- 请求示例:
-
- ```json
- {
- "action": "canAddNotesWithErrorDetail",
- "version": 6,
- "params": {
- "notes": [
- {
- "deckName": "Default",
- "modelName": "Basic",
- "fields": {
- "Front": "front content",
- "Back": "back content"
- },
- "tags": [
- "yomichan"
- ]
- },
- {
- "deckName": "Default",
- "modelName": "Basic",
- "fields": {
- "Front": "front content 2",
- "Back": "back content 2"
- },
- "tags": [
- "yomichan"
- ]
- }
- ]
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": [
- {
- "canAdd": false,
- "error": "cannot create note because it is a duplicate"
- },
- {
- "canAdd": true
- }
- ],
- "error": null
- }
- ```
-
-
-#### `updateNoteFields`
-
-* 修改现有笔记的字段。您还可以包含音频、视频或图片文件,这些文件将添加到笔记中,并带有
- 可选的 `audio`、`video` 或 `picture` 属性。有关 `audio`、`video` 或 `picture` 数组中对象的解释,请参阅 `addNote` 的文档。
-
- > **警告**:
- > 您不能在 Anki 浏览器中查看您正在更新的笔记,否则
- > 字段将不会更新。有关更多详细信息,请参阅[此问题](https://github.com/FooSoft/anki-connect/issues/82)。
-
-
- 请求示例:
-
- ```json
- {
- "action": "updateNoteFields",
- "version": 6,
- "params": {
- "note": {
- "id": 1514547547030,
- "fields": {
- "Front": "new front content",
- "Back": "new back content"
- },
- "audio": [{
- "url": "https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kanji=猫&kana=ねこ",
- "filename": "yomichan_ねこ_猫.mp3",
- "skipHash": "7e2c2f954ef6051373ba916f000168dc",
- "fields": [
- "Front"
- ]
- }]
- }
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `updateNote`
-
-* 修改现有笔记的字段和/或标签。
- 换句话说,结合了 `updateNoteFields` 和 `updateNoteTags` 的功能。
- 请参阅它们的文档以了解所有属性。
-
- 可以省略 `fields` 或 `tags` 属性,而不影响另一个。
- 因此有效的 `updateNoteFields` 请求也适用于 `updateNote`。
- 笔记必须具有 `fields` 属性才能更新可选的音频、视频或图片对象。
-
- 如果既没有提供 `fields` 也没有提供 `tags`,则该方法将失败。
- 首先更新字段,如果更新标签失败,则不会回滚字段更新。
- 如果更新字段失败,则不会更新标签。
-
- > **警告**
- > 您不能在 Anki 浏览器中查看您正在更新的笔记,否则
- > 字段将不会更新。有关更多详细信息,请参阅[此问题](https://github.com/FooSoft/anki-connect/issues/82)。
-
-
- 请求示例:
-
- ```json
- {
- "action": "updateNote",
- "version": 6,
- "params": {
- "note": {
- "id": 1514547547030,
- "fields": {
- "Front": "new front content",
- "Back": "new back content"
- },
- "tags": ["new", "tags"]
- }
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `updateNoteModel`
-
-* 更新现有笔记的模型、字段和标签。
- 这允许您更改笔记的模型,用新内容更新其字段,并设置新标签。
-
-
- 请求示例:
-
- ```json
- {
- "action": "updateNoteModel",
- "version": 6,
- "params": {
- "note": {
- "id": 1514547547030,
- "modelName": "NewModel",
- "fields": {
- "NewField1": "new field 1",
- "NewField2": "new field 2",
- "NewField3": "new field 3"
- },
- "tags": ["new", "updated", "tags"]
- }
- }
- }
- ```
-
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-
-#### `updateNoteTags`
-
-* 通过笔记 ID 设置笔记的标签。旧标签将被移除。
-
-
- 请求示例:
-
- ```json
- {
- "action": "updateNoteTags",
- "version": 6,
- "params": {
- "note": 1483959289817,
- "tags": ["european-languages"]
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `getNoteTags`
-
-* 通过笔记 ID 获取笔记的标签。
-
-
- 请求示例:
-
- ```json
- {
- "action": "getNoteTags",
- "version": 6,
- "params": {
- "note": 1483959289817
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": ["european-languages"],
- "error": null
- }
- ```
-
-
-#### `addTags`
-
-* 通过笔记 ID 向笔记添加标签。
-
-
- 请求示例:
-
- ```json
- {
- "action": "addTags",
- "version": 6,
- "params": {
- "notes": [1483959289817, 1483959291695],
- "tags": "european-languages"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `removeTags`
-
-* 通过笔记 ID 从笔记中移除标签。
-
-
- 请求示例:
-
- ```json
- {
- "action": "removeTags",
- "version": 6,
- "params": {
- "notes": [1483959289817, 1483959291695],
- "tags": "european-languages"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `getTags`
-
-* 获取当前用户的标签完整列表。
-
-
- 请求示例:
-
- ```json
- {
- "action": "getTags",
- "version": 6
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": ["european-languages", "idioms"],
- "error": null
- }
- ```
-
-
-#### `clearUnusedTags`
-
-* 清除当前用户笔记中所有未使用的标签。
-
-
- 请求示例:
-
- ```json
- {
- "action": "clearUnusedTags",
- "version": 6
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `replaceTags`
-
-* 通过笔记 ID 替换笔记中的标签。
-
-
- 请求示例:
-
- ```json
- {
- "action": "replaceTags",
- "version": 6,
- "params": {
- "notes": [1483959289817, 1483959291695],
- "tag_to_replace": "european-languages",
- "replace_with_tag": "french-languages"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `replaceTagsInAllNotes`
-
-* 替换当前用户所有笔记中的标签。
-
-
- 请求示例:
-
- ```json
- {
- "action": "replaceTagsInAllNotes",
- "version": 6,
- "params": {
- "tag_to_replace": "european-languages",
- "replace_with_tag": "french-languages"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `findNotes`
-
-* 返回给定查询的笔记 ID 数组。查询语法[在此处有文档](https://docs.ankiweb.net/searching.html)。
-
-
- 请求示例:
-
- ```json
- {
- "action": "findNotes",
- "version": 6,
- "params": {
- "query": "deck:current"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": [1483959289817, 1483959291695],
- "error": null
- }
- ```
-
-
-#### `notesInfo`
-
-* 返回一个对象列表,每个笔记 ID 包含笔记字段、标签、笔记类型、修改时间、属于该笔记的卡片以及创建笔记的个人资料。
-
-
- 请求示例(笔记 id):
-
- ```json
- {
- "action": "notesInfo",
- "version": 6,
- "params": {
- "notes": [1502298033753]
- }
- }
- ```
-
-
-
- 请求示例(查询):
-
- ```json
- {
- "action": "notesInfo",
- "version": 6,
- "params": {
- "query": "deck:current"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": [
- {
- "noteId":1502298033753,
- "profile": "User_1",
- "modelName": "Basic",
- "tags":["tag","another_tag"],
- "fields": {
- "Front": {"value": "front content", "order": 0},
- "Back": {"value": "back content", "order": 1}
- },
- "mod": 1718377864,
- "cards": [1498938915662]
- }
- ],
- "error": null
- }
- ```
-
-s
-#### `notesModTime`
-
-* 返回一个对象列表,每个笔记 ID 包含修改时间。
-
-
- 请求示例:
-#### `apiReflect`
-
-* 获取有关可用 AnkiConnect API 的信息。请求支持以下参数:
-
- * `scopes` - 要获取反射信息的作用域数组。
- 目前唯一支持的值是 `"actions"`。
- * `actions` - 可以是 `null` 或者 API 方法名称的数组。
- 如果值为 `null`,结果将列出所有可用的 API 动作。
- 如果值是字符串数组,结果将只包含该数组中存在的动作。
-
- 结果将包含使用了哪些作用域及每个作用域的值。
- 例如,`"actions"` 作用域将包含一个 `"actions"` 属性,其中包含支持的动作名称列表。
-
-
- 请求示例:
-
- ```json
- {
- "action": "apiReflect",
- "version": 6,
- "params": {
- "scopes": ["actions", "invalidType"],
- "actions": ["apiReflect", "invalidMethod"]
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": {
- "scopes": ["actions"],
- "actions": ["apiReflect"]
- },
- "error": null
- }
- ```
-
-
-#### `sync`
-
-* 将本地 Anki 集合与 AnkiWeb 同步。
-
-
- 请求示例:
-
- ```json
- {
- "action": "sync",
- "version": 6
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `getProfiles`
-
-* 获取个人资料列表。
-
-
- 请求示例:
-
- ```json
- {
- "action": "getProfiles",
- "version": 6
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": ["User 1"],
- "error": null
- }
- ```
-
-
-#### `getActiveProfile`
-
-* 获取当前活动个人资料。
-
-
- 请求示例:
-
- ```json
- {
- "action": "getActiveProfile",
- "version": 6
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": "User 1",
- "error": null
- }
- ```
-
-
-
-#### `loadProfile`
-
-* 选择请求中指定的个人资料。
-
-
- 请求示例:
-
- ```json
- {
- "action": "loadProfile",
- "version": 6,
- "params": {
- "name": "user1"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `multi`
-
-* 在一个请求中执行多个操作,返回一个数组,其中包含每个操作的响应(按给定顺序)。
-
-
- 请求示例:
-
- ```json
- {
- "action": "multi",
- "version": 6,
- "params": {
- "actions": [
- {
- "action": "deckNames"
- },
- {
- "action": "deckNames",
- "version": 6
- },
- {
- "action": "invalidAction",
- "params": {"useless": "param"}
- },
- {
- "action": "invalidAction",
- "params": {"useless": "param"},
- "version": 6
- }
- ]
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": [
- ["Default"],
- {"result": ["Default"], "error": null},
- {"result": null, "error": "unsupported action"},
- {"result": null, "error": "unsupported action"}
- ],
- "error": null
- }
- ```
-
-
-#### `exportPackage`
-
-* 将指定的牌组以 `.apkg` 格式导出。如果成功则返回 `true`,否则返回 `false`。可以指定可选属性
- `includeSched`(默认为 `false`)以包含卡片的调度数据。
-
-
- 请求示例:
-
- ```json
- {
- "action": "exportPackage",
- "version": 6,
- "params": {
- "deck": "Default",
- "path": "/data/Deck.apkg",
- "includeSched": true
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `importPackage`
-
-* 将 `.apkg` 格式的文件导入集合中。如果成功则返回 `true`,否则返回 `false`。
- 注意,文件路径是相对于 Anki 的 collection.media 文件夹,而不是相对于客户端。
-
-
- 请求示例:
-
- ```json
- {
- "action": "importPackage",
- "version": 6,
- "params": {
- "path": "/data/Deck.apkg"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
-#### `reloadCollection`
-
-* 告诉 Anki 从数据库重新加载所有数据。
-
-
- 请求示例:
-
- ```json
- {
- "action": "reloadCollection",
- "version": 6
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
----
-
-### 模型(笔记类型)操作
-
-#### `modelNames`
-
-* 获取当前用户的完整模型名称列表。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelNames",
- "version": 6
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": ["Basic", "Basic (and reversed card)"],
- "error": null
- }
- ```
-
-
-#### `modelNamesAndIds`
-
-* 获取当前用户的完整模型名称及其对应的 ID 列表。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelNamesAndIds",
- "version": 6
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": {
- "Basic": 1483883011648,
- "Basic (and reversed card)": 1483883011644,
- "Basic (optional reversed card)": 1483883011631,
- "Cloze": 1483883011630
- },
- "error": null
- }
- ```
-
-
-#### `findModelsById`
-
-* 根据提供的模型 ID 从当前用户获取模型列表。
-
-
- 请求示例:
-
- ```json
- {
- "action": "findModelsById",
- "version": 6,
- "params": {
- "modelIds": [1704387367119, 1704387398570]
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": [
- {
- "id": 1704387367119,
- "name": "Basic",
- "type": 0,
- "mod": 1704387367,
- "usn": -1,
- "sortf": 0,
- "did": null,
- "tmpls": [
- {
- "name": "Card 1",
- "ord": 0,
- "qfmt": "{{Front}}",
- "afmt": "{{FrontSide}}\n\n
\n\n{{Back}}",
- "bqfmt": "",
- "bafmt": "",
- "did": null,
- "bfont": "",
- "bsize": 0,
- "id": 9176047152973362695
- }
- ],
- "flds": [
- {
- "name": "Front",
- "ord": 0,
- "sticky": false,
- "rtl": false,
- "font": "Arial",
- "size": 20,
- "description": "",
- "plainText": false,
- "collapsed": false,
- "excludeFromSearch": false,
- "id": 2453723143453745216,
- "tag": null,
- "preventDeletion": false
- },
- {
- "name": "Back",
- "ord": 1,
- "sticky": false,
- "rtl": false,
- "font": "Arial",
- "size": 20,
- "description": "",
- "plainText": false,
- "collapsed": false,
- "excludeFromSearch": false,
- "id": -4853200230425436781,
- "tag": null,
- "preventDeletion": false
- }
- ],
- "css": ".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n",
- "latexPre": "\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n",
- "latexPost": "\\end{document}",
- "latexsvg": false,
- "req": [
- [
- 0,
- "any",
- [
- 0
- ]
- ]
- ],
- "originalStockKind": 1
- },
- {
- "id": 1704387398570,
- "name": "Basic (and reversed card)",
- "type": 0,
- "mod": 1704387398,
- "usn": -1,
- "sortf": 0,
- "did": null,
- "tmpls": [
- {
- "name": "Card 1",
- "ord": 0,
- "qfmt": "{{Front}}",
- "afmt": "{{FrontSide}}\n\n
\n\n{{Back}}",
- "bqfmt": "",
- "bafmt": "",
- "did": null,
- "bfont": "",
- "bsize": 0,
- "id": 1689886528158874152
- },
- {
- "name": "Card 2",
- "ord": 1,
- "qfmt": "{{Back}}",
- "afmt": "{{FrontSide}}\n\n
\n\n{{Front}}",
- "bqfmt": "",
- "bafmt": "",
- "did": null,
- "bfont": "",
- "bsize": 0,
- "id": -7839609225644824587
- }
- ],
- "flds": [
- {
- "name": "Front",
- "ord": 0,
- "sticky": false,
- "rtl": false,
- "font": "Arial",
- "size": 20,
- "description": "",
- "plainText": false,
- "collapsed": false,
- "excludeFromSearch": false,
- "id": -7787837672455357996,
- "tag": null,
- "preventDeletion": false
- },
- {
- "name": "Back",
- "ord": 1,
- "sticky": false,
- "rtl": false,
- "font": "Arial",
- "size": 20,
- "description": "",
- "plainText": false,
- "collapsed": false,
- "excludeFromSearch": false,
- "id": 6364828289839985081,
- "tag": null,
- "preventDeletion": false
- }
- ],
- "css": ".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n",
- "latexPre": "\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n",
- "latexPost": "\\end{document}",
- "latexsvg": false,
- "req": [
- [
- 0,
- "any",
- [
- 0
- ]
- ],
- [
- 1,
- "any",
- [
- 1
- ]
- ]
- ],
- "originalStockKind": 1
- }
- ],
- "error": null
- }
- ```
-
-
-
-#### `findModelsByName`
-
-* 根据提供的模型名称从当前用户获取模型列表。
-
-
- 请求示例:
-
- ```json
- {
- "action": "findModelsByName",
- "version": 6,
- "params": {
- "modelNames": ["Basic", "Basic (and reversed card)"]
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": [
- {
- "id": 1704387367119,
- "name": "Basic",
- "type": 0,
- "mod": 1704387367,
- "usn": -1,
- "sortf": 0,
- "did": null,
- "tmpls": [
- {
- "name": "Card 1",
- "ord": 0,
- "qfmt": "{{Front}}",
- "afmt": "{{FrontSide}}\n\n
\n\n{{Back}}",
- "bqfmt": "",
- "bafmt": "",
- "did": null,
- "bfont": "",
- "bsize": 0,
- "id": 9176047152973362695
- }
- ],
- "flds": [
- {
- "name": "Front",
- "ord": 0,
- "sticky": false,
- "rtl": false,
- "font": "Arial",
- "size": 20,
- "description": "",
- "plainText": false,
- "collapsed": false,
- "excludeFromSearch": false,
- "id": 2453723143453745216,
- "tag": null,
- "preventDeletion": false
- },
- {
- "name": "Back",
- "ord": 1,
- "sticky": false,
- "rtl": false,
- "font": "Arial",
- "size": 20,
- "description": "",
- "plainText": false,
- "collapsed": false,
- "excludeFromSearch": false,
- "id": -4853200230425436781,
- "tag": null,
- "preventDeletion": false
- }
- ],
- "css": ".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n",
- "latexPre": "\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n",
- "latexPost": "\\end{document}",
- "latexsvg": false,
- "req": [
- [
- 0,
- "any",
- [
- 0
- ]
- ]
- ],
- "originalStockKind": 1
- },
- {
- "id": 1704387398570,
- "name": "Basic (and reversed card)",
- "type": 0,
- "mod": 1704387398,
- "usn": -1,
- "sortf": 0,
- "did": null,
- "tmpls": [
- {
- "name": "Card 1",
- "ord": 0,
- "qfmt": "{{Front}}",
- "afmt": "{{FrontSide}}\n\n
\n\n{{Back}}",
- "bqfmt": "",
- "bafmt": "",
- "did": null,
- "bfont": "",
- "bsize": 0,
- "id": 1689886528158874152
- },
- {
- "name": "Card 2",
- "ord": 1,
- "qfmt": "{{Back}}",
- "afmt": "{{FrontSide}}\n\n
\n\n{{Front}}",
- "bqfmt": "",
- "bafmt": "",
- "did": null,
- "bfont": "",
- "bsize": 0,
- "id": -7839609225644824587
- }
- ],
- "flds": [
- {
- "name": "Front",
- "ord": 0,
- "sticky": false,
- "rtl": false,
- "font": "Arial",
- "size": 20,
- "description": "",
- "plainText": false,
- "collapsed": false,
- "excludeFromSearch": false,
- "id": -7787837672455357996,
- "tag": null,
- "preventDeletion": false
- },
- {
- "name": "Back",
- "ord": 1,
- "sticky": false,
- "rtl": false,
- "font": "Arial",
- "size": 20,
- "description": "",
- "plainText": false,
- "collapsed": false,
- "excludeFromSearch": false,
- "id": 6364828289839985081,
- "tag": null,
- "preventDeletion": false
- }
- ],
- "css": ".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n",
- "latexPre": "\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n",
- "latexPost": "\\end{document}",
- "latexsvg": false,
- "req": [
- [
- 0,
- "any",
- [
- 0
- ]
- ],
- [
- 1,
- "any",
- [
- 1
- ]
- ]
- ],
- "originalStockKind": 1
- }
- ],
- "error": null
- }
- ```
-
-
-#### `modelFieldNames`
-
-* 获取提供的模型名称的完整字段名称列表。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldNames",
- "version": 6,
- "params": {
- "modelName": "Basic"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": ["Front", "Back"],
- "error": null
- }
- ```
-
-
-#### `modelFieldDescriptions`
-
-* 获取提供的模型名称的完整字段描述列表(当字段为空时在 GUI 编辑器中显示的文本)。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldDescriptions",
- "version": 6,
- "params": {
- "modelName": "Basic"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": ["", ""],
- "error": null
- }
- ```
-
-
-#### `modelFieldFonts`
-
-* 获取完整的字体列表及其字体大小。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldFonts",
- "version": 6,
- "params": {
- "modelName": "Basic"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": {
- "Front": {
- "font": "Arial",
- "size": 20
- },
- "Back": {
- "font": "Arial",
- "size": 20
- }
- },
- "error": null
- }
- ```
-
-
-#### `modelFieldsOnTemplates`
-
-* 返回一个对象,指示给定模型名称的每个卡片模板的问题侧和答案侧的字段。
- 问题侧在每个数组中首先给出。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldsOnTemplates",
- "version": 6,
- "params": {
- "modelName": "Basic (and reversed card)"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": {
- "Card 1": [["Front"], ["Back"]],
- "Card 2": [["Back"], ["Front"]]
- },
- "error": null
- }
- ```
-
-
-#### `createModel`
-
-* 创建一个新模型以在 Anki 中使用。用户必须提供 `modelName`、`inOrderFields` 和 `cardTemplates` 来
- 在模型中使用。有可选字段 `css` 和 `isCloze`。如果未指定,`css` 将使用默认的 Anki CSS,`isCloze` 将等于 `false`。如果 `isCloze` 为 `true`,则模型将创建为填空题型。
-
- 可以为 `cardTemplates` 的每个条目提供可选的 `Name` 字段。默认情况下,
- 卡片名称将是 `Card 1`, `Card 2` 等。
-
-
- 请求示例:
-
- ```json
- {
- "action": "createModel",
- "version": 6,
- "params": {
- "modelName": "newModelName",
- "inOrderFields": ["Field1", "Field2", "Field3"],
- "css": "Optional CSS with default to builtin css",
- "isCloze": false,
- "cardTemplates": [
- {
- "Name": "My Card 1",
- "Front": "Front html {{Field1}}",
- "Back": "Back html {{Field2}}"
- }
- ]
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result":{
- "sortf":0,
- "did":1,
- "latexPre":"\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n",
- "latexPost":"\\end{document}",
- "mod":1551462107,
- "usn":-1,
- "vers":[
-
- ],
- "type":0,
- "css":".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n",
- "name":"TestApiModel",
- "flds":[
- {
- "name":"Field1",
- "ord":0,
- "sticky":false,
- "rtl":false,
- "font":"Arial",
- "size":20,
- "media":[
-
- ]
- },
- {
- "name":"Field2",
- "ord":1,
- "sticky":false,
- "rtl":false,
- "font":"Arial",
- "size":20,
- "media":[
-
- ]
- }
- ],
- "tmpls":[
- {
- "name":"My Card 1",
- "ord":0,
- "qfmt":"",
- "afmt":"This is the back of the card {{Field2}}",
- "did":null,
- "bqfmt":"",
- "bafmt":""
- }
- ],
- "tags":[
-
- ],
- "id":1551462107104,
- "req":[
- [
- 0,
- "none",
- [
-
- ]
- ]
- ]
- },
- "error":null
- }
- ```
-
-
-#### `modelTemplates`
-
-* 返回一个对象,指示与提供的模型名称相连接的每个卡片的模板内容。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelTemplates",
- "version": 6,
- "params": {
- "modelName": "Basic (and reversed card)"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": {
- "Card 1": {
- "Front": "{{Front}}",
- "Back": "{{FrontSide}}\n\n
\n\n{{Back}}"
- },
- "Card 2": {
- "Front": "{{Back}}",
- "Back": "{{FrontSide}}\n\n
\n\n{{Front}}"
- }
- },
- "error": null
- }
- ```
-
-
-#### `modelStyling`
-
-* 获取按名称提供的模型的 CSS 样式。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelStyling",
- "version": 6,
- "params": {
- "modelName": "Basic (and reversed card)"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": {
- "css": ".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n"
- },
- "error": null
- }
- ```
-
-
-#### `updateModelTemplates`
-
-* 修改现有模型的模板(通过名称指定)。只有指定的卡片和指定的侧面会被修改。
- 如果请求中不包括现有卡片或侧面,它将保持不变。
-
-
- 请求示例:
-
- ```json
- {
- "action": "updateModelTemplates",
- "version": 6,
- "params": {
- "model": {
- "name": "Custom",
- "templates": {
- "Card 1": {
- "Front": "{{Question}}?",
- "Back": "{{Answer}}!"
- }
- }
- }
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `updateModelStyling`
-
-* 修改现有模型的 CSS 样式(通过名称指定)。
-
-
- 请求示例:
-
- ```json
- {
- "action": "updateModelStyling",
- "version": 6,
- "params": {
- "model": {
- "name": "Custom",
- "css": "p { color: blue; }"
- }
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `findAndReplaceInModels`
-
-* 在现有模型中查找并替换字符串(通过模型名称)。通过设置为 true/false 自定义在前面、后面或 CSS 中替换。
-
-
- 请求示例:
-
- ```json
- {
- "action": "findAndReplaceInModels",
- "version": 6,
- "params": {
- "model": {
- "modelName": "",
- "findText": "text_to_replace",
- "replaceText": "replace_with_text",
- "front": true,
- "back": true,
- "css": true
- }
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": 1,
- "error": null
- }
- ```
-
-
-#### `modelTemplateRename`
-
-* 重命名现有模型中的模板。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelTemplateRename",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "oldTemplateName": "Card 1",
- "newTemplateName": "Card 1 renamed"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `modelTemplateReposition`
-
-* 重新定位现有模型中的模板。
-
- `index` 的值从 0 开始。例如,索引 `0` 将模板放在第一个位置,索引 `2` 将模板放在第三个位置。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelTemplateReposition",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "templateName": "Card 1",
- "index": 1
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `modelTemplateAdd`
-
-* 通过名称向现有模型添加模板。如果要更新现有模板,请使用 `updateModelTemplates`。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelTemplateAdd",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "template": {
- "Name": "Card 3",
- "Front": "Front html {{Field1}}",
- "Back": "Back html {{Field2}}"
- }
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `modelTemplateRemove`
-
-* 从现有模型中移除模板。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelTemplateRemove",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "templateName": "Card 1"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `modelFieldRename`
-
-* 重命名给定模型的字段名称。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldRename",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "oldFieldName": "Front",
- "newFieldName": "FrontRenamed"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `modelFieldReposition`
-
-* 重新定位给定模型的字段列表中的字段。
-
- `index` 的值从 0 开始。例如,索引 `0` 将字段放在第一个位置,索引 `2` 将字段放在第三个位置。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldReposition",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "fieldName": "Back",
- "index": 0
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `modelFieldAdd`
-
-* 在给定模型中创建新字段。
-
- 可以选择提供 `index` 值,其工作方式与 `modelFieldReposition` 中的索引完全相同。默认情况下,字段将添加到字段列表的末尾。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldAdd",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "fieldName": "NewField",
- "index": 0
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `modelFieldRemove`
-
-* 删除给定模型中的字段。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldRemove",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "fieldName": "Front"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `modelFieldSetFont`
-
-* 设置给定模型中字段的字体。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldSetFont",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "fieldName": "Front",
- "font": "Courier"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `modelFieldSetFontSize`
-
-* 设置给定模型中字段的字体大小。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldSetFontSize",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "fieldName": "Front",
- "fontSize": 10
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `modelFieldSetDescription`
-
-* 设置给定模型中字段的描述(当字段为空时在 GUI 编辑器中看到的文本)。
-
- 旧版本的 Anki(2.1.49 及以下)没有字段描述。在这种情况下,将返回 `false`。
-
-
- 请求示例:
-
- ```json
- {
- "action": "modelFieldSetDescription",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "fieldName": "Front",
- "description": "example field description"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
-
----
-
-### 笔记操作
-
-#### `addNote`
-
-* 使用给定的牌组和模型创建一个笔记,包含提供的字段值和标签。成功时返回创建的笔记的标识符,
- 失败时返回 `null`。
-
- Anki-Connect 可以下载音频、视频和图片文件,并将它们嵌入到新创建的笔记中。相应的 `audio`、`video` 和 `picture` 笔记成员是
- 可选的,可以省略。如果选择包含它们中的任何一个,它们应该包含一个对象或一个对象数组,
- 带有必填的 `filename` 字段和 `data`、`path` 或 `url` 之一。有关这些字段的解释,请参阅 `storeMediaFile` 的文档。
- 可以选择提供 `skipHash` 字段,以跳过包含与提供的值匹配的 MD5 哈希的文件。
- 这对于避免保存错误页面和存根文件很有用。
- `fields` 成员是一个字段列表,这些字段应该在卡片显示在 Anki 中时播放音频或视频,或显示图片。
- `options` 组中的 `allowDuplicate` 成员可以设置为 true 以启用添加重复卡片。
- 通常不能添加重复卡片,会触发异常。
-
- `options` 中的 `duplicateScope` 成员可用于指定检查重复项的范围。
- 值为 `"deck"` 将只检查目标牌组中的重复项;任何其他值将检查整个集合。
-
- `duplicateScopeOptions` 对象可用于指定一些附加设置:
-
- * `duplicateScopeOptions.deckName` 将指定用于检查重复项的牌组。如果未定义或为 `null`,将使用目标牌组。
- * `duplicateScopeOptions.checkChildren` 将更改是否在子牌组中检查重复卡片。默认值为 `false`。
- * `duplicateScopeOptions.checkAllModels` 指定是否在所有笔记类型中执行重复检查。默认值为 `false`。
-
-
- 请求示例:
-
- ```json
- {
- "action": "addNote",
- "version": 6,
- "params": {
- "note": {
- "deckName": "Default",
- "modelName": "Basic",
- "fields": {
- "Front": "front content",
- "Back": "back content"
- },
- "options": {
- "allowDuplicate": false,
- "duplicateScope": "deck",
- "duplicateScopeOptions": {
- "deckName": "Default",
- "checkChildren": false,
- "checkAllModels": false
- }
- },
- "tags": [
- "yomichan"
- ],
- "audio": [{
- "url": "https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kanji=猫&kana=ねこ",
- "filename": "yomichan_ねこ_猫.mp3",
- "skipHash": "7e2c2f954ef6051373ba916f000168dc",
- "fields": [
- "Front"
- ]
- }],
- "video": [{
- "url": "https://cdn.videvo.net/videvo_files/video/free/2015-06/small_watermarked/Contador_Glam_preview.mp4",
- "filename": "countdown.mp4",
- "skipHash": "4117e8aab0d37534d9c8eac362388bbe",
- "fields": [
- "Back"
- ]
- }],
- "picture": [{
- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c7/A_black_cat_named_Tilly.jpg/220px-A_black_cat_named_Tilly.jpg",
- "filename": "black_cat.jpg",
- "skipHash": "8d6e4646dfae812bf39651b59d7429ce",
- "fields": [
- "Back"
- ]
- }]
- }
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": 1496198395707,
- "error": null
- }
- ```
-
-
-#### `addNotes`
-
-* 使用给定的牌组和模型创建多个笔记,包含提供的字段值和标签。返回一个数组,
- 包含创建的笔记的标识符。如有任何错误,将收集并返回所有错误。
-* 有关 `notes` 数组中对象的解释,请参阅 `addNote` 的文档。
-
-
- 请求示例:
-
- ```json
- {
- "action":"addNotes",
- "version":6,
- "params":{
- "notes":[
- {
- "deckName":"College::PluginDev",
- "modelName":"non_existent_model",
- "fields":{
- "Front":"front",
- "Back":"bak"
- }
- },
- {
- "deckName":"College::PluginDev",
- "modelName":"Basic",
- "fields":{
- "Front":"front",
- "Back":"bak"
- }
- }
- ]
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result":null,
- "error":"['model was not found: non_existent_model']"
- }
- ```
-
-
-#### `canAddNotes`
-
-* 接受一个对象数组,这些对象定义候选笔记的参数(参见 `addNote`),并返回一个布尔值数组,
- 指示相应索引处的参数是否可用于创建新笔记。
-
-
- 请求示例:
-
- ```json
- {
- "action": "canAddNotes",
- "version": 6,
- "params": {
- "notes": [
- {
- "deckName": "Default",
- "modelName": "Basic",
- "fields": {
- "Front": "front content",
- "Back": "back content"
- },
- "tags": [
- "yomichan"
- ]
- }
- ]
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": [true],
- "error": null
- }
- ```
-
-
-#### `canAddNotesWithErrorDetail`
-
-* 接受一个对象数组,这些对象定义候选笔记的参数(参见 `addNote`),并返回一个对象数组,
- 包含 `canAdd` 和 `error` 字段。
-
- * `canAdd` 指示相应索引处的参数是否可用于创建新笔记。
- * `error` 包含无法添加笔记的原因说明。
-
-
- 请求示例:
-
- ```json
- {
- "action": "canAddNotesWithErrorDetail",
- "version": 6,
- "params": {
- "notes": [
- {
- "deckName": "Default",
- "modelName": "Basic",
- "fields": {
- "Front": "front content",
- "Back": "back content"
- },
- "tags": [
- "yomichan"
- ]
- },
- {
- "deckName": "Default",
- "modelName": "Basic",
- "fields": {
- "Front": "front content 2",
- "Back": "back content 2"
- },
- "tags": [
- "yomichan"
- ]
- }
- ]
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": [
- {
- "canAdd": false,
- "error": "cannot create note because it is a duplicate"
- },
- {
- "canAdd": true
- }
- ],
- "error": null
- }
- ```
-
-
-#### `updateNoteFields`
-
-* 修改现有笔记的字段。您还可以包含音频、视频或图片文件,这些文件将添加到笔记中,并带有
- 可选的 `audio`、`video` 或 `picture` 属性。有关 `audio`、`video` 或 `picture` 数组中对象的解释,请参阅 `addNote` 的文档。
-
- > **警告**:
- > 您不能在 Anki 浏览器中查看您正在更新的笔记,否则
- > 字段将不会更新。有关更多详细信息,请参阅[此问题](https://github.com/FooSoft/anki-connect/issues/82)。
-
-
- 请求示例:
-
- ```json
- {
- "action": "updateNoteFields",
- "version": 6,
- "params": {
- "note": {
- "id": 1514547547030,
- "fields": {
- "Front": "new front content",
- "Back": "new back content"
- },
- "audio": [{
- "url": "https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kanji=猫&kana=ねこ",
- "filename": "yomichan_ねこ_猫.mp3",
- "skipHash": "7e2c2f954ef6051373ba916f000168dc",
- "fields": [
- "Front"
- ]
- }]
- }
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `updateNote`
-
-* 修改现有笔记的字段和/或标签。
- 换句话说,结合了 `updateNoteFields` 和 `updateNoteTags` 的功能。
- 请参阅它们的文档以了解所有属性。
-
- 可以省略 `fields` 或 `tags` 属性,而不影响另一个。
- 因此有效的 `updateNoteFields` 请求也适用于 `updateNote`。
- 笔记必须具有 `fields` 属性才能更新可选的音频、视频或图片对象。
-
- 如果既没有提供 `fields` 也没有提供 `tags`,则该方法将失败。
- 首先更新字段,如果更新标签失败,则不会回滚字段更新。
- 如果更新字段失败,则不会更新标签。
-
- > **警告**
- > 您不能在 Anki 浏览器中查看您正在更新的笔记,否则
- > 字段将不会更新。有关更多详细信息,请参阅[此问题](https://github.com/FooSoft/anki-connect/issues/82)。
-
-
- 请求示例:
-
- ```json
- {
- "action": "updateNote",
- "version": 6,
- "params": {
- "note": {
- "id": 1514547547030,
- "fields": {
- "Front": "new front content",
- "Back": "new back content"
- },
- "tags": ["new", "tags"]
- }
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `updateNoteModel`
-
-* 更新现有笔记的模型、字段和标签。
- 这允许您更改笔记的模型,用新内容更新其字段,并设置新标签。
-
-
- 请求示例:
-
- ```json
- {
- "action": "updateNoteModel",
- "version": 6,
- "params": {
- "note": {
- "id": 1514547547030,
- "modelName": "NewModel",
- "fields": {
- "NewField1": "new field 1",
- "NewField2": "new field 2",
- "NewField3": "new field 3"
- },
- "tags": ["new", "updated", "tags"]
- }
- }
- }
- ```
-
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-
-#### `updateNoteTags`
-
-* 通过笔记 ID 设置笔记的标签。旧标签将被移除。
-
-
- 请求示例:
-
- ```json
- {
- "action": "updateNoteTags",
- "version": 6,
- "params": {
- "note": 1483959289817,
- "tags": ["european-languages"]
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `getNoteTags`
-
-* 通过笔记 ID 获取笔记的标签。
-
-
- 请求示例:
-
- ```json
- {
- "action": "getNoteTags",
- "version": 6,
- "params": {
- "note": 1483959289817
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": ["european-languages"],
- "error": null
- }
- ```
-
-
-#### `addTags`
-
-* 通过笔记 ID 向笔记添加标签。
-
-
- 请求示例:
-
- ```json
- {
- "action": "addTags",
- "version": 6,
- "params": {
- "notes": [1483959289817, 1483959291695],
- "tags": "european-languages"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `removeTags`
-
-* 通过笔记 ID 从笔记中移除标签。
-
-
- 请求示例:
-
- ```json
- {
- "action": "removeTags",
- "version": 6,
- "params": {
- "notes": [1483959289817, 1483959291695],
- "tags": "european-languages"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `getTags`
-
-* 获取当前用户的标签完整列表。
-
-
- 请求示例:
-
- ```json
- {
- "action": "getTags",
- "version": 6
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": ["european-languages", "idioms"],
- "error": null
- }
- ```
-
-
-#### `clearUnusedTags`
-
-* 清除当前用户笔记中所有未使用的标签。
-
-
- 请求示例:
-
- ```json
- {
- "action": "clearUnusedTags",
- "version": 6
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `replaceTags`
-
-* 通过笔记 ID 替换笔记中的标签。
-
-
- 请求示例:
-
- ```json
- {
- "action": "replaceTags",
- "version": 6,
- "params": {
- "notes": [1483959289817, 1483959291695],
- "tag_to_replace": "european-languages",
- "replace_with_tag": "french-languages"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `replaceTagsInAllNotes`
-
-* 替换当前用户所有笔记中的标签。
-
-
- 请求示例:
-
- ```json
- {
- "action": "replaceTagsInAllNotes",
- "version": 6,
- "params": {
- "tag_to_replace": "european-languages",
- "replace_with_tag": "french-languages"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
-
-#### `findNotes`
-
-* 返回给定查询的笔记 ID 数组。查询语法[在此处有文档](https://docs.ankiweb.net/searching.html)。
-
-
- 请求示例:
-
- ```json
- {
- "action": "findNotes",
- "version": 6,
- "params": {
- "query": "deck:current"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": [1483959289817, 1483959291695],
- "error": null
- }
- ```
-
-
-#### `notesInfo`
-
-* 返回一个对象列表,每个笔记 ID 包含笔记字段、标签、笔记类型、修改时间、属于该笔记的卡片以及创建笔记的个人资料。
-
-
- 请求示例(笔记 id):
-
- ```json
- {
- "action": "notesInfo",
- "version": 6,
- "params": {
- "notes": [1502298033753]
- }
- }
- ```
-
-
-
- 请求示例(查询):
-
- ```json
- {
- "action": "notesInfo",
- "version": 6,
- "params": {
- "query": "deck:current"
- }
- }
- ```
-
-
-
- 结果示例:
-
- ```json
- {
- "result": [
- {
- "noteId":1502298033753,
- "profile": "User_1",
- "modelName": "Basic",
- "tags":["tag","another_tag"],
- "fields": {
- "Front": {"value": "front content", "order": 0},
- "Back": {"value": "back content", "order": 1}
- },
- "mod": 1718377864,
- "cards": [1498938915662]
- }
- ],
- "error": null
- }
- ```
-
-
-#### `notesModTime`
-
-* 返回一个对象列表,每个笔记 ID 包含修改时间。
-
-
- 请求示例:
\ No newline at end of file
diff --git a/README.md b/README.md
index 9ffe4b3..8c1f934 100644
--- a/README.md
+++ b/README.md
@@ -1,67 +1,63 @@
# Anki-Connect
-Anki-Connect enables external applications such as Yomichan to communicate with [Anki](https://apps.ankiweb.net/) over a simple HTTP API. Its capabilities include executing queries against the user's card deck, automatically creating new cards, and more. Anki-Connect is compatible with the latest stable (2.1.x) releases of Anki; older versions (2.0.x and below) are no longer supported.
+Anki-Connect 使外部应用程序(如 Yomichan)能够通过简单的 HTTP API 与[Anki](https://apps.ankiweb.net/)进行通信。它的功能包括对用户卡片组执行查询、自动创建新卡片等。Anki-Connect 与最新的稳定版(2.1.x)Anki 兼容;旧版本(2.0.x 及以下)不再受支持。
-## Installation
+## 安装
-The installation process is similar to other Anki plugins and can be accomplished in three steps:
+安装过程与其他 Anki 插件类似,可以通过以下三个步骤完成:
-1. Open the `Install Add-on` dialog by selecting `Tools` | `Add-ons` | `Get Add-ons...` in Anki.
-2. Input [2055492159](https://ankiweb.net/shared/info/2055492159) into the text box labeled `Code` and press the `OK` button to proceed.
-3. Restart Anki when prompted to do so in order to complete the installation of Anki-Connect.
+1. 在 Anki 中选择`工具` | `插件` | `获取插件...`,打开`安装插件`对话框。
+2. 在标有`代码`的文本框中输入[2055492159](https://ankiweb.net/shared/info/2055492159),然后按`确定`按钮继续。
+3. 当提示重启 Anki 时,请按照要求进行操作,以完成 Anki-Connect 的安装。
-Anki must be kept running in the background in order for other applications to be able to use Anki-Connect. You can verify that Anki-Connect is running at any time by accessing `localhost:8765` in your browser. If the server is running, you will see the message `Anki-Connect` displayed in your browser window.
+Anki 必须在后台保持运行,以便其他应用程序能够使用 Anki-Connect。您可以随时通过在浏览器中访问`localhost:8765`来验证 Anki-Connect 是否在运行。如果服务器正在运行,您将在浏览器窗口中看到`Anki-Connect`的消息。
-### Notes for Windows Users
+### Windows 用户注意事项
-Windows users may see a firewall nag dialog box appear on Anki startup. This occurs because Anki-Connect runs a local HTTP server in order to enable other applications to connect to it. The host application, Anki, must be unblocked for this plugin to function correctly.
+Windows 用户可能会在 Anki 启动时看到防火墙提示对话框。这是因为 Anki-Connect 运行了本地 HTTP 服务器,以便其他应用程序能够连接到它。主应用程序 Anki 必须被允许通过防火墙,此插件才能正常运行。
-### Notes for MacOS Users
+### MacOS 用户注意事项
-Starting with [Mac OS X Mavericks](https://en.wikipedia.org/wiki/OS_X_Mavericks), a feature named *App Nap* has been introduced to the operating system. This feature causes certain applications which are open (but not visible) to be placed in a suspended state. As this behavior causes Anki-Connect to stop working while you have another window in the foreground, App Nap should be disabled for Anki:
+从[Mac OS X Mavericks](https://en.wikipedia.org/wiki/OS_X_Mavericks)开始,操作系统引入了名为*App Nap*的功能。此功能会使某些已打开但不可见的应用程序进入挂起状态。由于此行为会导致 Anki-Connect 在前台显示其他窗口时停止工作,因此应为 Anki 禁用 App Nap:
-1. Start the Terminal application.
-2. Execute the following commands in the terminal window:
+1. 启动终端应用程序。
+2. 在终端窗口中执行以下命令:
```bash
defaults write net.ankiweb.dtop NSAppSleepDisabled -bool true
defaults write net.ichi2.anki NSAppSleepDisabled -bool true
defaults write org.qt-project.Qt.QtWebEngineCore NSAppSleepDisabled -bool true
```
-3. Restart Anki.
+3. 重启 Anki。
-## Application Interface for Developers
+## 开发者应用程序接口
-Anki-Connect exposes internal Anki features to external applications via an easy to use API. After being installed, this plugin will start an HTTP server on port 8765 whenever Anki is launched. Other applications (including browser extensions) can then communicate with it via HTTP requests.
+Anki-Connect 通过易于使用的 API 向外部应用程序公开 Anki 的内部功能。安装后,只要启动 Anki,该插件就会在 8765 端口启动 HTTP 服务器。其他应用程序(包括浏览器扩展)可以通过 HTTP 请求与其通信。
-By default, Anki-Connect will only bind the HTTP server to the `127.0.0.1` IP address, so that you will only be able to access it from the same host on which it is running. If you need to access it over a network, you can change the binding address in the configuration. Go to Tools->Add-ons->AnkiConnect->Config and change the "webBindAddress" value. For example, you can set it to `0.0.0.0` in order to bind it to all network interfaces on your host. This also requires a restart for Anki.
+默认情况下,Anki-Connect 只会将 HTTP 服务器绑定到`127.0.0.1`IP 地址,因此您只能从运行它的同一主机访问它。如果您需要通过网络访问,可以在配置中更改绑定地址。进入工具->插件->AnkiConnect->配置,更改"webBindAddress"值。例如,您可以将其设置为`0.0.0.0`,以将其绑定到主机上的所有网络接口。这也需要重启 Anki。
-### Sample Invocation
+### 调用示例
-Every request consists of a JSON-encoded object containing an `action`, a `version`, contextual `params`, and a `key`
-value used for authentication (which is optional and can be omitted by default). Anki-Connect will respond with an
-object containing two fields: `result` and `error`. The `result` field contains the return value of the executed API,
-and the `error` field is a description of any exception thrown during API execution (the value `null` is used if
-execution completed successfully).
+每个请求都由一个包含`action`、`version`、上下文`params`和用于认证的`key`值(可选,默认可以省略)的 JSON 编码对象组成。Anki-Connect 将返回一个包含两个字段的对象:`result`和`error`。`result`字段包含执行的 API 的返回值,而`error`字段是在 API 执行期间抛出的任何异常的描述(如果执行成功,则使用值`null`)。
+
+_成功响应示例_:
-*Sample successful response*:
```json
-{"result": ["Default", "Filtered Deck 1"], "error": null}
+{ "result": ["Default", "Filtered Deck 1"], "error": null }
```
-*Samples of failed responses*:
+_失败响应示例_:
+
```json
-{"result": null, "error": "unsupported action"}
-```
-```json
-{"result": null, "error": "guiBrowse() got an unexpected keyword argument 'foobar'"}
+{ "result": null, "error": "unsupported action" }
```
-For compatibility with clients designed to work with older versions of Anki-Connect, failing to provide a `version`
-field in the request will make the version default to 4. Furthermore, when the provided version is level 4 or below, the
-API response will only contain the value of the `result`; no `error` field is available for error handling.
+```json
+{ "result": null, "error": "guiBrowse() got an unexpected keyword argument 'foobar'" }
+```
-You can use whatever language or tool you like to issue request to Anki-Connect, but a couple of simple examples are
-included below as reference.
+为了与旧版本 Anki-Connect 设计的客户端兼容,如果请求中未提供`version`字段,版本将默认为 4。此外,当提供的版本为 4 级或以下时,API 响应将只包含`result`的值;没有`error`字段可用于错误处理。
+
+您可以使用任何语言或工具向 Anki-Connect 发出请求,但下面包含了几个简单的示例作为参考。
#### Curl
@@ -105,2306 +101,2333 @@ print('got list of decks: {}'.format(result))
#### JavaScript
```javascript
-function invoke(action, version, params={}) {
- return new Promise((resolve, reject) => {
- const xhr = new XMLHttpRequest();
- xhr.addEventListener('error', () => reject('failed to issue request'));
- xhr.addEventListener('load', () => {
- try {
- const response = JSON.parse(xhr.responseText);
- if (Object.getOwnPropertyNames(response).length != 2) {
- throw 'response has an unexpected number of fields';
- }
- if (!response.hasOwnProperty('error')) {
- throw 'response is missing required error field';
- }
- if (!response.hasOwnProperty('result')) {
- throw 'response is missing required result field';
- }
- if (response.error) {
- throw response.error;
- }
- resolve(response.result);
- } catch (e) {
- reject(e);
- }
- });
-
- xhr.open('POST', 'http://127.0.0.1:8765');
- xhr.send(JSON.stringify({action, version, params}));
+function invoke(action, version, params = {}) {
+ return new Promise((resolve, reject) => {
+ const xhr = new XMLHttpRequest();
+ xhr.addEventListener('error', () => reject('failed to issue request'));
+ xhr.addEventListener('load', () => {
+ try {
+ const response = JSON.parse(xhr.responseText);
+ if (Object.getOwnPropertyNames(response).length != 2) {
+ throw 'response has an unexpected number of fields';
+ }
+ if (!response.hasOwnProperty('error')) {
+ throw 'response is missing required error field';
+ }
+ if (!response.hasOwnProperty('result')) {
+ throw 'response is missing required result field';
+ }
+ if (response.error) {
+ throw response.error;
+ }
+ resolve(response.result);
+ } catch (e) {
+ reject(e);
+ }
});
+
+ xhr.open('POST', 'http://127.0.0.1:8765');
+ xhr.send(JSON.stringify({ action, version, params }));
+ });
}
-await invoke('createDeck', 6, {deck: 'test1'});
+await invoke('createDeck', 6, { deck: 'test1' });
const result = await invoke('deckNames', 6);
console.log(`got list of decks: ${result}`);
```
-### Authentication
+### 认证
-Anki-Connect supports requiring authentication in order to make API requests.
-This support is *disabled* by default, but can be enabled by setting the `apiKey` field of Anki-Config's settings (Tools->Add-ons->AnkiConnect->Config) to a desired string.
-If you have done so, you should see the [`requestPermission`](#requestpermission) API request return `true` for `requireApiKey`.
-You then must include an additional parameter called `key` in any further API request bodies, whose value must match the configured API key.
+Anki-Connect 支持要求认证以便进行 API 请求。
+默认情况下,此支持是*禁用*的,但可以通过在 Anki-Config 的设置(工具->插件->AnkiConnect->配置)中设置`apiKey`字段为所需的字符串来启用。
+如果您已经这样做,您应该会看到[`requestPermission`](#requestpermission) API 请求返回`true`作为`requireApiKey`。
+然后您必须在任何进一步的 API 请求体中包含一个名为`key`的附加参数,其值必须与配置的 API 密钥匹配。
-### Hey, could you add a new action to support $FEATURE?
+### 嘿,你能添加一个新的 action 来支持$FEATURE 吗?
-The primary goal for Anki-Connect was to support real-time flash card creation from the Yomichan browser extension. The current API provides all the required actions to make this happen. I recognise that the role of Anki-Connect has evolved from this original vision, and I am happy to review new feature requests.
+Anki-Connect 的主要目标是支持来自 Yomichan 浏览器扩展的实时闪卡创建。当前的 API 提供了所有必要的动作来实现这一点。我认识到 Anki-Connect 的角色已经从这一最初愿景演变,而且我很乐意审查新的功能请求。
-With that said, *this project operates on a self-serve model*. If you would like a new feature, create a PR. I'll review it and if it looks good, it will be merged in. *Requests to add new features without accompanying pull requests will not be serviced*. Make sure that your pull request meets the following criteria:
+话虽如此,_本项目采用自助服务模式_。如果你想要一个新功能,请创建一个 PR。我会审查它,如果看起来不错,就会合并。_没有附带拉取请求的添加新功能的请求将不会得到处理_。确保你的拉取请求满足以下标准:
-* Attempt to match style of the surrounding code.
-* Have accompanying documentation with examples.
-* Have accompanying tests that verify operation.
-* Implement features useful in other applications.
+- 尝试匹配周围代码的风格。
+- 有附带的文档和示例。
+- 有验证操作的附带测试。
+- 实现在其他应用中有用的功能。
-## Supported Actions
+## 支持的动作
-Documentation for currently supported actions is split up by category and is referenced below. Note that deprecated APIs will continue to function despite not being listed on this page as long as your request is labeled with a version number corresponding to when the API was available for use. Search parameters are passed to Anki, check the docs for more information: https://docs.ankiweb.net/searching.html
+当前支持的动作的文档按类别分类并在下面引用。请注意,已弃用的 API 将继续运行,尽管未在此页面上列出,只要您的请求标有对应 API 可用时的版本号。搜索参数传递给 Anki,更多信息请查看文档:https://docs.ankiweb.net/searching.html
-* [Card Actions](#card-actions)
-* [Deck Actions](#deck-actions)
-* [Graphical Actions](#graphical-actions)
-* [Media Actions](#media-actions)
-* [Miscellaneous Actions](#miscellaneous-actions)
-* [Model Actions](#model-actions)
-* [Note Actions](#note-actions)
-* [Statistic Actions](#statistic-actions)
+- [卡片操作](#card-actions)
+- [卡组操作](#deck-actions)
+- [图形界面操作](#graphical-actions)
+- [媒体操作](#media-actions)
+- [杂项操作](#miscellaneous-actions)
+- [模型操作](#model-actions)
+- [笔记操作](#note-actions)
+- [统计操作](#statistic-actions)
---
-### Card Actions
+### 卡片操作
#### `getEaseFactors`
-* Returns an array with the ease factor for each of the given cards (in the same order).
+- 返回一个数组,包含给定卡片的简易度因子(按相同顺序)。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "getEaseFactors",
- "version": 6,
- "params": {
- "cards": [1483959291685, 1483959293217]
- }
+ ```json
+ {
+ "action": "getEaseFactors",
+ "version": 6,
+ "params": {
+ "cards": [1483959291685, 1483959293217]
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": [4100, 3900],
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": [4100, 3900],
+ "error": null
+ }
+ ```
+
+
#### `setEaseFactors`
-* Sets ease factor of cards by card ID; returns `true` if successful (all cards existed) or `false` otherwise.
+- 通过卡片 ID 设置卡片的简易度因子;如果成功(所有卡片都存在)则返回`true`,否则返回`false`。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "setEaseFactors",
- "version": 6,
- "params": {
- "cards": [1483959291685, 1483959293217],
- "easeFactors": [4100, 3900]
- }
+ ```json
+ {
+ "action": "setEaseFactors",
+ "version": 6,
+ "params": {
+ "cards": [1483959291685, 1483959293217],
+ "easeFactors": [4100, 3900]
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": [true, true],
- "error": null
- }
- ```
-
+
+ 示例结果:
+ ```json
+ {
+ "result": [true, true],
+ "error": null
+ }
+ ```
+
+
#### `setSpecificValueOfCard`
-* Sets specific value of a single card. Given the risk of wreaking havor in the database when changing some of the values of a card, some of the keys require the argument "warning_check" set to True.
- This can be used to set a card's flag, change it's ease factor, change the review order in a filtered deck and change the column "data" (not currently used by anki apparantly), and many other values.
- A list of values and explanation of their respective utility can be found at [AnkiDroid's wiki](https://github.com/ankidroid/Anki-Android/wiki/Database-Structure).
+- 设置单个卡片的特定值。由于更改卡片的某些值可能会在数据库中造成混乱,一些键需要将参数"warning_check"设置为 True。
+ 这可用于设置卡片的标志、更改其简易度因子、更改筛选卡组中的复习顺序以及更改列"data"(目前显然未被 anki 使用),以及许多其他值。
+ 可以在[AnkiDroid 的 wiki](https://github.com/ankidroid/Anki-Android/wiki/Database-Structure)上找到值的列表及其各自的用途解释。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "setSpecificValueOfCard",
- "version": 6,
- "params": {
- "card": 1483959291685,
- "keys": ["flags", "odue"],
- "newValues": ["1", "-100"]
- }
+ ```json
+ {
+ "action": "setSpecificValueOfCard",
+ "version": 6,
+ "params": {
+ "card": 1483959291685,
+ "keys": ["flags", "odue"],
+ "newValues": ["1", "-100"]
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": [true, true],
- "error": null
- }
- ```
-
+
+ 示例结果:
+ ```json
+ {
+ "result": [true, true],
+ "error": null
+ }
+ ```
+
+
#### `suspend`
-* Suspend cards by card ID; returns `true` if successful (at least one card wasn't already suspended) or `false`
- otherwise.
+- 通过卡片 ID 暂停卡片;如果成功(至少有一张卡片之前没有被暂停)则返回`true`,否则返回`false`。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "suspend",
- "version": 6,
- "params": {
- "cards": [1483959291685, 1483959293217]
- }
+ ```json
+ {
+ "action": "suspend",
+ "version": 6,
+ "params": {
+ "cards": [1483959291685, 1483959293217]
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
#### `unsuspend`
-* Unsuspend cards by card ID; returns `true` if successful (at least one card was previously suspended) or `false`
- otherwise.
+- 通过卡片 ID 取消暂停卡片;如果成功(至少有一张卡片之前被暂停)则返回`true`,否则返回`false`。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "unsuspend",
- "version": 6,
- "params": {
- "cards": [1483959291685, 1483959293217]
- }
+ ```json
+ {
+ "action": "unsuspend",
+ "version": 6,
+ "params": {
+ "cards": [1483959291685, 1483959293217]
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
#### `suspended`
-* Check if card is suspended by its ID. Returns `true` if suspended, `false` otherwise.
+- 通过 ID 检查卡片是否被暂停。如果被暂停则返回`true`,否则返回`false`。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "suspended",
- "version": 6,
- "params": {
- "card": 1483959293217
- }
+ ```json
+ {
+ "action": "suspended",
+ "version": 6,
+ "params": {
+ "card": 1483959293217
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
#### `areSuspended`
-* Returns an array indicating whether each of the given cards is suspended (in the same order). If card doesn't
- exist returns `null`.
+- 返回一个数组,表示每张给定卡片是否被暂停(按相同顺序)。如果卡片不存在,则返回`null`。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "areSuspended",
- "version": 6,
- "params": {
- "cards": [1483959291685, 1483959293217, 1234567891234]
- }
+ ```json
+ {
+ "action": "areSuspended",
+ "version": 6,
+ "params": {
+ "cards": [1483959291685, 1483959293217, 1234567891234]
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": [false, true, null],
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": [false, true, null],
+ "error": null
+ }
+ ```
+
+
#### `areDue`
-* Returns an array indicating whether each of the given cards is due (in the same order). *Note*: cards in the
- learning queue with a large interval (over 20 minutes) are treated as not due until the time of their interval has
- passed, to match the way Anki treats them when reviewing.
+- 返回一个数组,表示每张给定卡片是否到期(按相同顺序)。_注意_:学习队列中有大间隔(超过 20 分钟)的卡片被视为未到期,直到其间隔时间过去为止,这与 Anki 在复习时对待它们的方式相匹配。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "areDue",
- "version": 6,
- "params": {
- "cards": [1483959291685, 1483959293217]
- }
+ ```json
+ {
+ "action": "areDue",
+ "version": 6,
+ "params": {
+ "cards": [1483959291685, 1483959293217]
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": [false, true],
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": [false, true],
+ "error": null
+ }
+ ```
+
+
#### `getIntervals`
-* Returns an array of the most recent intervals for each given card ID, or a 2-dimensional array of all the intervals
- for each given card ID when `complete` is `true`. Negative intervals are in seconds and positive intervals in days.
+- 返回一个数组,包含每个给定卡片 ID 的最近间隔,或者当`complete`为`true`时,返回每个给定卡片 ID 的所有间隔的二维数组。负间隔以秒为单位,正间隔以天为单位。
-
- Sample request 1:
+
+ 示例请求1:
- ```json
- {
- "action": "getIntervals",
- "version": 6,
- "params": {
- "cards": [1502298033753, 1502298036657]
- }
+ ```json
+ {
+ "action": "getIntervals",
+ "version": 6,
+ "params": {
+ "cards": [1502298033753, 1502298036657]
}
- ```
-
+ }
+ ```
-
- Sample result 1:
+
- ```json
- {
- "result": [-14400, 3],
- "error": null
+
+ 示例结果1:
+
+ ```json
+ {
+ "result": [-14400, 3],
+ "error": null
+ }
+ ```
+
+
+
+
+ 示例请求2:
+
+ ```json
+ {
+ "action": "getIntervals",
+ "version": 6,
+ "params": {
+ "cards": [1502298033753, 1502298036657],
+ "complete": true
}
- ```
-
+ }
+ ```
-
- Sample request 2:
+
- ```json
- {
- "action": "getIntervals",
- "version": 6,
- "params": {
- "cards": [1502298033753, 1502298036657],
- "complete": true
- }
- }
- ```
-
+
+ 示例结果2:
-
- Sample result 2:
+ ```json
+ {
+ "result": [
+ [-120, -180, -240, -300, -360, -14400],
+ [-120, -180, -240, -300, -360, -14400, 1, 3]
+ ],
+ "error": null
+ }
+ ```
- ```json
- {
- "result": [
- [-120, -180, -240, -300, -360, -14400],
- [-120, -180, -240, -300, -360, -14400, 1, 3]
- ],
- "error": null
- }
- ```
-
+
#### `findCards`
-* Returns an array of card IDs for a given query. Functionally identical to `guiBrowse` but doesn't use the GUI for
- better performance.
+- 返回给定查询的卡片 ID 数组。功能上与`guiBrowse`相同,但不使用 GUI 以获得更好的性能。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "findCards",
- "version": 6,
- "params": {
- "query": "deck:current"
- }
+ ```json
+ {
+ "action": "findCards",
+ "version": 6,
+ "params": {
+ "query": "deck:current"
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": [1494723142483, 1494703460437, 1494703479525],
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": [1494723142483, 1494703460437, 1494703479525],
+ "error": null
+ }
+ ```
+
+
#### `cardsToNotes`
-* Returns an unordered array of note IDs for the given card IDs. For cards with the same note, the ID is only given
- once in the array.
+- 返回给定卡片 ID 的笔记 ID 的无序数组。对于具有相同笔记的卡片,ID 在数组中只给出一次。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "cardsToNotes",
- "version": 6,
- "params": {
- "cards": [1502098034045, 1502098034048, 1502298033753]
- }
+ ```json
+ {
+ "action": "cardsToNotes",
+ "version": 6,
+ "params": {
+ "cards": [1502098034045, 1502098034048, 1502298033753]
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": [1502098029797, 1502298025183],
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": [1502098029797, 1502298025183],
+ "error": null
+ }
+ ```
+
+
#### `cardsModTime`
-* Returns a list of objects containings for each card ID the modification time.
- This function is about 15 times faster than executing `cardsInfo`.
+- 返回一个对象列表,包含每个卡片 ID 的修改时间。
+ 此功能比执行`cardsInfo`快约 15 倍。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "cardsModTime",
- "version": 6,
- "params": {
- "cards": [1498938915662, 1502098034048]
- }
+ ```json
+ {
+ "action": "cardsModTime",
+ "version": 6,
+ "params": {
+ "cards": [1498938915662, 1502098034048]
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": [
- {
- "cardId": 1498938915662,
- "mod": 1629454092
- }
- ],
- "error": null
- }
- ```
-
+
+ 示例结果:
+ ```json
+ {
+ "result": [
+ {
+ "cardId": 1498938915662,
+ "mod": 1629454092
+ }
+ ],
+ "error": null
+ }
+ ```
+
+
#### `cardsInfo`
-* Returns a list of objects containing for each card ID the card fields, front and back sides including CSS, note
- type, the note that the card belongs to, and deck name, last modification timestamp as well as ease and interval.
+- 返回一个对象列表,包含每个卡片 ID 的卡片字段、正反面(包括 CSS)、笔记类型、卡片所属的笔记、卡组名称、最后修改时间戳以及简易度和间隔。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "cardsInfo",
- "version": 6,
- "params": {
- "cards": [1498938915662, 1502098034048]
- }
+ ```json
+ {
+ "action": "cardsInfo",
+ "version": 6,
+ "params": {
+ "cards": [1498938915662, 1502098034048]
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": [
- {
- "answer": "back content",
- "question": "front content",
- "deckName": "Default",
- "modelName": "Basic",
- "fieldOrder": 1,
- "fields": {
- "Front": {"value": "front content", "order": 0},
- "Back": {"value": "back content", "order": 1}
- },
- "css":"p {font-family:Arial;}",
- "cardId": 1498938915662,
- "interval": 16,
- "note":1502298033753,
- "ord": 1,
- "type": 0,
- "queue": 0,
- "due": 1,
- "reps": 1,
- "lapses": 0,
- "left": 6,
- "mod": 1629454092
- },
- {
- "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}
- },
- "css":"p {font-family:Arial;}",
- "cardId": 1502098034048,
- "interval": 23,
- "note":1502298033753,
- "ord": 1,
- "type": 0,
- "queue": 0,
- "due": 1,
- "reps": 1,
- "lapses": 0,
- "left": 6
- }
- ],
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": [
+ {
+ "answer": "back content",
+ "question": "front content",
+ "deckName": "Default",
+ "modelName": "Basic",
+ "fieldOrder": 1,
+ "fields": {
+ "Front": { "value": "front content", "order": 0 },
+ "Back": { "value": "back content", "order": 1 }
+ },
+ "css": "p {font-family:Arial;}",
+ "cardId": 1498938915662,
+ "interval": 16,
+ "note": 1502298033753,
+ "ord": 1,
+ "type": 0,
+ "queue": 0,
+ "due": 1,
+ "reps": 1,
+ "lapses": 0,
+ "left": 6,
+ "mod": 1629454092
+ },
+ {
+ "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 }
+ },
+ "css": "p {font-family:Arial;}",
+ "cardId": 1502098034048,
+ "interval": 23,
+ "note": 1502298033753,
+ "ord": 1,
+ "type": 0,
+ "queue": 0,
+ "due": 1,
+ "reps": 1,
+ "lapses": 0,
+ "left": 6
+ }
+ ],
+ "error": null
+ }
+ ```
+
+
#### `forgetCards`
-* Forget cards, making the cards new again.
+- 忘记卡片,使卡片再次成为新卡片。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "forgetCards",
- "version": 6,
- "params": {
- "cards": [1498938915662, 1502098034048]
- }
+ ```json
+ {
+ "action": "forgetCards",
+ "version": 6,
+ "params": {
+ "cards": [1498938915662, 1502098034048]
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
#### `relearnCards`
-* Make cards be "relearning".
+- 使卡片成为"重新学习"状态。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "relearnCards",
- "version": 6,
- "params": {
- "cards": [1498938915662, 1502098034048]
- }
+ ```json
+ {
+ "action": "relearnCards",
+ "version": 6,
+ "params": {
+ "cards": [1498938915662, 1502098034048]
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
#### `answerCards`
-* Answer cards. Ease is between 1 (Again) and 4 (Easy). Will start the timer immediately before answering. Returns `true` if card exists, `false` otherwise.
+- 回答卡片。简易度在 1(重来)到 4(简单)之间。将在回答前立即开始计时器。如果卡片存在则返回`true`,否则返回`false`。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "answerCards",
- "version": 6,
- "params": {
- "answers": [
- {
- "cardId": 1498938915662,
- "ease": 2
- },
- {
- "cardId": 1502098034048,
- "ease": 4
- }
- ]
+ ```json
+ {
+ "action": "answerCards",
+ "version": 6,
+ "params": {
+ "answers": [
+ {
+ "cardId": 1498938915662,
+ "ease": 2
+ },
+ {
+ "cardId": 1502098034048,
+ "ease": 4
}
+ ]
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": [true, true],
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": [true, true],
+ "error": null
+ }
+ ```
+
+
#### `setDueDate`
-* Set Due Date. Turns cards into review cards if they are new, and makes them due on a certain date.
- * 0 = today
- * 1! = tomorrow + change interval to 1
- * 3-7 = random choice of 3-7 days
+- 设置到期日期。如果是新卡片,则将其转为复习卡片,并使其在特定日期到期。
-
- Sample request:
+ - 0 = 今天
+ - 1! = 明天 + 将间隔更改为 1
+ - 3-7 = 随机选择 3-7 天
- ```json
- {
- "action": "setDueDate",
- "version": 6,
- "params": {
- "cards": [1498938915662, 1502098034048],
- "days": "3-7"
- }
+
+ 示例请求:
+
+ ```json
+ {
+ "action": "setDueDate",
+ "version": 6,
+ "params": {
+ "cards": [1498938915662, 1502098034048],
+ "days": "3-7"
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
---
-### Deck Actions
+### 卡组操作
#### `deckNames`
-* Gets the complete list of deck names for the current user.
+- 获取当前用户的完整卡组名称列表。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "deckNames",
- "version": 6
- }
- ```
-
+ ```json
+ {
+ "action": "deckNames",
+ "version": 6
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": ["Default"],
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": ["Default"],
+ "error": null
+ }
+ ```
+
+
#### `deckNamesAndIds`
-* Gets the complete list of deck names and their respective IDs for the current user.
+- 获取当前用户的完整卡组名称及其对应 ID 的列表。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "deckNamesAndIds",
- "version": 6
- }
- ```
-
+ ```json
+ {
+ "action": "deckNamesAndIds",
+ "version": 6
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": {"Default": 1},
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": { "Default": 1 },
+ "error": null
+ }
+ ```
+
+
#### `getDecks`
-* Accepts an array of card IDs and returns an object with each deck name as a key, and its value an array of the given
- cards which belong to it.
+- 接受一个卡片 ID 数组,并返回一个对象,其中每个卡组名称作为键,其值是属于该卡组的给定卡片数组。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "getDecks",
- "version": 6,
- "params": {
- "cards": [1502298036657, 1502298033753, 1502032366472]
- }
+ ```json
+ {
+ "action": "getDecks",
+ "version": 6,
+ "params": {
+ "cards": [1502298036657, 1502298033753, 1502032366472]
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": {
- "Default": [1502032366472],
- "Japanese::JLPT N3": [1502298036657, 1502298033753]
- },
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": {
+ "Default": [1502032366472],
+ "Japanese::JLPT N3": [1502298036657, 1502298033753]
+ },
+ "error": null
+ }
+ ```
+
+
#### `createDeck`
-* Create a new empty deck. Will not overwrite a deck that exists with the same name.
+- 创建一个新的空卡组。不会覆盖同名的已存在卡组。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "createDeck",
- "version": 6,
- "params": {
- "deck": "Japanese::Tokyo"
- }
+ ```json
+ {
+ "action": "createDeck",
+ "version": 6,
+ "params": {
+ "deck": "Japanese::Tokyo"
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": 1519323742721,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": 1519323742721,
+ "error": null
+ }
+ ```
+
+
#### `changeDeck`
-* Moves cards with the given IDs to a different deck, creating the deck if it doesn't exist yet.
+- 将具有给定 ID 的卡片移动到不同的卡组,如果卡组尚不存在则创建它。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "changeDeck",
- "version": 6,
- "params": {
- "cards": [1502098034045, 1502098034048, 1502298033753],
- "deck": "Japanese::JLPT N3"
- }
+ ```json
+ {
+ "action": "changeDeck",
+ "version": 6,
+ "params": {
+ "cards": [1502098034045, 1502098034048, 1502298033753],
+ "deck": "Japanese::JLPT N3"
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
#### `deleteDecks`
-* Deletes decks with the given names.
- The argument `cardsToo` *must* be specified and set to `true`.
+- 删除具有给定名称的卡组。
+ 参数`cardsToo` *必须*被指定并设置为`true`。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "deleteDecks",
- "version": 6,
- "params": {
- "decks": ["Japanese::JLPT N5", "Easy Spanish"],
- "cardsToo": true
- }
+ ```json
+ {
+ "action": "deleteDecks",
+ "version": 6,
+ "params": {
+ "decks": ["Japanese::JLPT N5", "Easy Spanish"],
+ "cardsToo": true
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
#### `getDeckConfig`
-* Gets the configuration group object for the given deck.
+- 获取给定卡组的配置组对象。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "getDeckConfig",
- "version": 6,
- "params": {
- "deck": "Default"
- }
+ ```json
+ {
+ "action": "getDeckConfig",
+ "version": 6,
+ "params": {
+ "deck": "Default"
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": {
- "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
- },
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": {
+ "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
+ },
+ "error": null
+ }
+ ```
+
+
#### `saveDeckConfig`
-* Saves the given configuration group, returning `true` on success or `false` if the ID of the configuration group is
- invalid (such as when it does not exist).
+- 保存给定的配置组,成功时返回`true`,如果配置组的 ID 无效(例如不存在)则返回`false`。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "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
- }
- }
+ ```json
+ {
+ "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
+ }
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
#### `setDeckConfigId`
-* Changes the configuration group for the given decks to the one with the given ID. Returns `true` on success or
- `false` if the given configuration group or any of the given decks do not exist.
+- 将给定卡组的配置组更改为具有给定 ID 的配置组。成功时返回`true`,如果给定的配置组或任何给定的卡组不存在则返回`false`。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "setDeckConfigId",
- "version": 6,
- "params": {
- "decks": ["Default"],
- "configId": 1
- }
+ ```json
+ {
+ "action": "setDeckConfigId",
+ "version": 6,
+ "params": {
+ "decks": ["Default"],
+ "configId": 1
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
#### `cloneDeckConfigId`
-* Creates a new configuration group with the given name, cloning from the group with the given ID, or from the default
- group if this is unspecified. Returns the ID of the new configuration group, or `false` if the specified group to
- clone from does not exist.
+- 使用给定的名称创建一个新的配置组,从具有给定 ID 的组克隆,或者如果未指定,则从默认组克隆。返回新配置组的 ID,或者如果指定的要克隆的组不存在,则返回`false`。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "cloneDeckConfigId",
- "version": 6,
- "params": {
- "name": "Copy of Default",
- "cloneFrom": 1
- }
+ ```json
+ {
+ "action": "cloneDeckConfigId",
+ "version": 6,
+ "params": {
+ "name": "Copy of Default",
+ "cloneFrom": 1
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": 1502972374573,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": 1502972374573,
+ "error": null
+ }
+ ```
+
+
#### `removeDeckConfigId`
-* Removes the configuration group with the given ID, returning `true` if successful, or `false` if attempting to
- remove either the default configuration group (ID = 1) or a configuration group that does not exist.
+- 移除具有给定 ID 的配置组,如果成功则返回`true`,如果尝试移除默认配置组(ID = 1)或不存在的配置组则返回`false`。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "removeDeckConfigId",
- "version": 6,
- "params": {
- "configId": 1502972374573
- }
+ ```json
+ {
+ "action": "removeDeckConfigId",
+ "version": 6,
+ "params": {
+ "configId": 1502972374573
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
#### `getDeckStats`
-* Gets statistics such as total cards and cards due for the given decks.
+- 获取给定卡组的统计信息,如总卡片数和到期卡片数。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "getDeckStats",
- "version": 6,
- "params": {
- "decks": ["Japanese::JLPT N5", "Easy Spanish"]
- }
+ ```json
+ {
+ "action": "getDeckStats",
+ "version": 6,
+ "params": {
+ "decks": ["Japanese::JLPT N5", "Easy Spanish"]
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": {
- "1651445861967": {
- "deck_id": 1651445861967,
- "name": "Japanese::JLPT N5",
- "new_count": 20,
- "learn_count": 0,
- "review_count": 0,
- "total_in_deck": 1506
- },
- "1651445861960": {
- "deck_id": 1651445861960,
- "name": "Easy Spanish",
- "new_count": 26,
- "learn_count": 10,
- "review_count": 5,
- "total_in_deck": 852
- }
- },
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": {
+ "1651445861967": {
+ "deck_id": 1651445861967,
+ "name": "Japanese::JLPT N5",
+ "new_count": 20,
+ "learn_count": 0,
+ "review_count": 0,
+ "total_in_deck": 1506
+ },
+ "1651445861960": {
+ "deck_id": 1651445861960,
+ "name": "Easy Spanish",
+ "new_count": 26,
+ "learn_count": 10,
+ "review_count": 5,
+ "total_in_deck": 852
+ }
+ },
+ "error": null
+ }
+ ```
+
+
---
-### 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](https://docs.ankiweb.net/searching.html).
+- 调用*卡片浏览器*对话框并搜索给定查询。返回找到的卡片标识符数组。查询语法[在此处有文档](https://docs.ankiweb.net/searching.html)。
- Optionally, the `reorderCards` property can be provided to reorder the cards shown in the *Card Browser*.
- This is an array including the `order` and `columnId` objects. `order` can be either `ascending` or `descending` while `columnId` can be one of several column identifiers (as documented in the [Anki source code](https://github.com/ankitects/anki/blob/main/rslib/src/browser_table.rs)).
- The specified column needs to be visible in the *Card Browser*.
+ 可选地,可以提供`reorderCards`属性来重新排序*卡片浏览器*中显示的卡片。
+ 这是一个包含`order`和`columnId`对象的数组。`order`可以是`ascending`或`descending`,而`columnId`可以是几个列标识符之一(如在[Anki 源代码](https://github.com/ankitects/anki/blob/main/rslib/src/browser_table.rs)中记录的)。
+ 指定的列需要在*卡片浏览器*中可见。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "guiBrowse",
- "version": 6,
- "params": {
- "query": "deck:current",
- "reorderCards": {
- "order": "descending",
- "columnId": "noteCrt"
- }
- }
+ ```json
+ {
+ "action": "guiBrowse",
+ "version": 6,
+ "params": {
+ "query": "deck:current",
+ "reorderCards": {
+ "order": "descending",
+ "columnId": "noteCrt"
+ }
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": [1494723142483, 1494703460437, 1494703479525],
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": [1494723142483, 1494703460437, 1494703479525],
+ "error": null
+ }
+ ```
+
+
#### `guiSelectCard`
-* Finds the open instance of the *Card Browser* dialog and selects a card given a card identifier.
- Returns `true` if the *Card Browser* is open, `false` otherwise.
+- 找到*卡片浏览器*对话框的打开实例,并根据卡片标识符选择一张卡片。
+ 如果*卡片浏览器*是打开的,返回`true`,否则返回`false`。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "guiSelectCard",
- "version": 6,
- "params": {
- "card": 1494723142483
- }
+ ```json
+ {
+ "action": "guiSelectCard",
+ "version": 6,
+ "params": {
+ "card": 1494723142483
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
#### `guiSelectedNotes`
-* Finds the open instance of the *Card Browser* dialog and returns an array of identifiers of the notes that are
- selected. Returns an empty list if the browser is not open.
+- 找到*卡片浏览器*对话框的打开实例,并返回选中笔记的标识符数组。如果浏览器未打开,则返回空列表。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "guiSelectedNotes",
- "version": 6
- }
- ```
-
+ ```json
+ {
+ "action": "guiSelectedNotes",
+ "version": 6
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": [1494723142483, 1494703460437, 1494703479525],
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "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.
+- 调用*添加卡片*对话框,使用给定的卡组和模型预设笔记,带有提供的字段值和标签。
+ 多次调用会关闭旧窗口并*重新打开窗口*,使用新提供的值。
- Audio, video, and picture files can be embedded into the fields via the `audio`, `video`, and `picture` keys, respectively.
- Refer to the documentation of `addNote` and `storeMediaFile` for an explanation of these fields.
+ 可以通过`audio`、`video`和`picture`键将音频、视频和图片文件嵌入到字段中。
+ 请参考`addNote`和`storeMediaFile`的文档,了解这些字段的说明。
- The result is the ID of the note which would be added, if the user chose to confirm the *Add Cards* dialogue.
+ 结果是如果用户选择确认*添加卡片*对话框,将添加的笔记的 ID。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "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"
- ],
- "picture": [{
- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/1/13/EU-Romania.svg/285px-EU-Romania.svg.png",
- "filename": "romania.png",
- "fields": [
- "Extra"
- ]
- }]
- }
- }
+ ```json
+ {
+ "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"],
+ "picture": [
+ {
+ "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/1/13/EU-Romania.svg/285px-EU-Romania.svg.png",
+ "filename": "romania.png",
+ "fields": ["Extra"]
+ }
+ ]
+ }
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": 1496198395707,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": 1496198395707,
+ "error": null
+ }
+ ```
+
+
#### `guiEditNote`
-* Opens the *Edit* dialog with a note corresponding to given note ID.
- The dialog is similar to the *Edit Current* dialog, but:
+- 打开*编辑*对话框,显示对应于给定笔记 ID 的笔记。
+ 该对话框类似于*编辑当前*对话框,但:
- * has a Preview button to preview the cards for the note
- * has a Browse button to open the browser with these cards
- * has Previous/Back buttons to navigate the history of the dialog
- * has no bar with the Close button
+ - 有一个预览按钮,用于预览笔记的卡片
+ - 有一个浏览按钮,用于打开浏览器并显示这些卡片
+ - 有上一个/后退按钮,用于导航对话框的历史
+ - 没有带有关闭按钮的栏
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "guiEditNote",
- "version": 6,
- "params": {
- "note": 1649198355435
- }
+ ```json
+ {
+ "action": "guiEditNote",
+ "version": 6,
+ "params": {
+ "note": 1649198355435
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
#### `guiCurrentCard`
-* Returns information about the current card or `null` if not in review mode.
+- 返回有关当前卡片的信息,如果不在复习模式,则返回`null`。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "guiCurrentCard",
- "version": 6
- }
- ```
-
+ ```json
+ {
+ "action": "guiCurrentCard",
+ "version": 6
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "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
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "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`.
+- 启动或重置当前卡片的`timerStarted`值。这对于将开始时间推迟到通过 API 显示卡片时很有用,从而在调用`guiAnswerCard`时使记录的回答卡片所花费的时间更准确。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "guiStartCardTimer",
- "version": 6
- }
- ```
-
+ ```json
+ {
+ "action": "guiStartCardTimer",
+ "version": 6
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
#### `guiShowQuestion`
-* Shows question text for the current card; returns `true` if in review mode or `false` otherwise.
+- 显示当前卡片的问题文本;如果处于复习模式则返回`true`,否则返回`false`。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "guiShowQuestion",
- "version": 6
- }
- ```
-
+ ```json
+ {
+ "action": "guiShowQuestion",
+ "version": 6
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
#### `guiShowAnswer`
-* Shows answer text for the current card; returns `true` if in review mode or `false` otherwise.
+- 显示当前卡片的答案文本;如果处于复习模式则返回`true`,否则返回`false`。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "guiShowAnswer",
- "version": 6
- }
- ```
-
+ ```json
+ {
+ "action": "guiShowAnswer",
+ "version": 6
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "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.
+- 回答当前卡片;如果成功则返回`true`,否则返回`false`。注意,在 Anki 接受任何答案之前,必须先显示当前卡片的答案。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "guiAnswerCard",
- "version": 6,
- "params": {
- "ease": 1
- }
+ ```json
+ {
+ "action": "guiAnswerCard",
+ "version": 6,
+ "params": {
+ "ease": 1
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
#### `guiUndo`
-* Undo the last action / card; returns `true` if succeeded or `false` otherwise.
+- 撤销最后一个动作/卡片;如果成功则返回`true`,否则返回`false`。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "guiUndo",
- "version": 6
- }
- ```
-
+ ```json
+ {
+ "action": "guiUndo",
+ "version": 6
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
#### `guiDeckOverview`
-* Opens the *Deck Overview* dialog for the deck with the given name; returns `true` if succeeded or `false` otherwise.
+- 为具有给定名称的卡组打开*卡组概览*对话框;如果成功则返回`true`,否则返回`false`。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "guiDeckOverview",
- "version": 6,
- "params": {
- "name": "Default"
- }
+ ```json
+ {
+ "action": "guiDeckOverview",
+ "version": 6,
+ "params": {
+ "name": "Default"
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
#### `guiDeckBrowser`
-* Opens the *Deck Browser* dialog.
+- 打开*卡组浏览器*对话框。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "guiDeckBrowser",
- "version": 6
- }
- ```
-
+ ```json
+ {
+ "action": "guiDeckBrowser",
+ "version": 6
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
#### `guiDeckReview`
-* Starts review for the deck with the given name; returns `true` if succeeded or `false` otherwise.
+- 开始复习具有给定名称的卡组;如果成功则返回`true`,否则返回`false`。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "guiDeckReview",
- "version": 6,
- "params": {
- "name": "Default"
- }
+ ```json
+ {
+ "action": "guiDeckReview",
+ "version": 6,
+ "params": {
+ "name": "Default"
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
#### `guiImportFile`
-* Invokes the *Import... (Ctrl+Shift+I)* dialog with an optional file path. Brings up the dialog for user to review the import. Supports all file types that Anki supports. Brings open file dialog if no path is provided. Forward slashes must be used in the path on Windows. Only supported for Anki 2.1.52+.
+- 调用*导入...(Ctrl+Shift+I)*对话框,并可选择提供文件路径。弹出对话框供用户审核导入。支持 Anki 支持的所有文件类型。如果未提供路径,则显示打开文件对话框。在 Windows 上的路径中必须使用正斜杠。仅支持 Anki 2.1.52+。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "guiImportFile",
- "version": 6,
- "params": {
- "path": "C:/Users/Desktop/cards.txt"
- }
+ ```json
+ {
+ "action": "guiImportFile",
+ "version": 6,
+ "params": {
+ "path": "C:/Users/Desktop/cards.txt"
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": null,
+ "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.
+- 安排一个请求来优雅地关闭 Anki。此操作是异步的,因此它会立即返回,而不会等待 Anki 进程实际终止。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "guiExitAnki",
- "version": 6
- }
- ```
-
+ ```json
+ {
+ "action": "guiExitAnki",
+ "version": 6
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
#### `guiCheckDatabase`
-* Requests a database check, but returns immediately without waiting for the check to complete. Therefore, the action will always return `true` even if errors are detected during the database check.
+- 请求进行数据库检查,但立即返回而不等待检查完成。因此,即使在数据库检查过程中检测到错误,此操作也将始终返回`true`。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "guiCheckDatabase",
- "version": 6
- }
- ```
-
+ ```json
+ {
+ "action": "guiCheckDatabase",
+ "version": 6
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
+
---
-### Media Actions
+### 媒体操作
#### `storeMediaFile`
-* Stores a file with the specified base64-encoded contents inside the media folder. Alternatively you can specify a
- absolute file path, or a url from where the file shell be downloaded. If more than one of `data`, `path` and `url` are provided, the `data` field will be used first, then `path`, and finally `url`. To prevent Anki from removing files not used by any cards (e.g. for configuration files), prefix the filename with an underscore. These files are still synchronized to AnkiWeb.
- Any existing file with the same name is deleted by default. Set `deleteExisting` to false to prevent that
- by [letting Anki give the new file a non-conflicting name](https://github.com/ankitects/anki/blob/aeba725d3ea9628c73300648f748140db3fdd5ed/rslib/src/media/files.rs#L194).
+- 将具有指定 base64 编码内容的文件存储在媒体文件夹中。或者,您可以指定绝对文件路径,或者从中下载文件的 URL。如果提供了`data`、`path`和`url`中的多个,将首先使用`data`字段,然后是`path`,最后是`url`。为了防止 Anki 删除不被任何卡片使用的文件(例如配置文件),请在文件名前加下划线。这些文件仍然会同步到 AnkiWeb。
+ 默认情况下,将删除任何同名的现有文件。设置`deleteExisting`为 false 可以通过[让 Anki 为新文件提供非冲突的名称](https://github.com/ankitects/anki/blob/aeba725d3ea9628c73300648f748140db3fdd5ed/rslib/src/media/files.rs#L194)来防止这种情况。
-
- Sample request (relative path):
+
+ 示例请求(相对路径):
- ```json
- {
- "action": "storeMediaFile",
- "version": 6,
- "params": {
- "filename": "_hello.txt",
- "data": "SGVsbG8sIHdvcmxkIQ=="
- }
+ ```json
+ {
+ "action": "storeMediaFile",
+ "version": 6,
+ "params": {
+ "filename": "_hello.txt",
+ "data": "SGVsbG8sIHdvcmxkIQ=="
}
- ```
+ }
+ ```
- *Content of `_hello.txt`*:
+ _`_hello.txt`的内容_:
- ```
- Hello world!
- ```
-
+ ```
+ Hello world!
+ ```
-
- Sample result (relative path):
+
- ```json
- {
- "result": "_hello.txt",
- "error": null
+
+ 示例结果(相对路径):
+
+ ```json
+ {
+ "result": "_hello.txt",
+ "error": null
+ }
+ ```
+
+
+
+
+ 示例请求(绝对路径):
+
+ ```json
+ {
+ "action": "storeMediaFile",
+ "version": 6,
+ "params": {
+ "filename": "_hello.txt",
+ "path": "/path/to/file"
}
- ```
-
+ }
+ ```
-
- Sample request (absolute path):
+
- ```json
- {
- "action": "storeMediaFile",
- "version": 6,
- "params": {
- "filename": "_hello.txt",
- "path": "/path/to/file"
- }
+
+ 示例结果(绝对路径):
+
+ ```json
+ {
+ "result": "_hello.txt",
+ "error": null
+ }
+ ```
+
+
+
+
+ 示例请求(url):
+
+ ```json
+ {
+ "action": "storeMediaFile",
+ "version": 6,
+ "params": {
+ "filename": "_hello.txt",
+ "url": "https://url.to.file"
}
- ```
-
+ }
+ ```
-
- Sample result (absolute path):
+
- ```json
- {
- "result": "_hello.txt",
- "error": null
- }
- ```
-
+
+ 示例结果(url):
-
- Sample request (url):
+ ```json
+ {
+ "result": "_hello.txt",
+ "error": null
+ }
+ ```
- ```json
- {
- "action": "storeMediaFile",
- "version": 6,
- "params": {
- "filename": "_hello.txt",
- "url": "https://url.to.file"
- }
- }
- ```
-
-
-
- Sample result (url):
-
- ```json
- {
- "result": "_hello.txt",
- "error": null
- }
- ```
-
+
#### `retrieveMediaFile`
-* Retrieves the base64-encoded contents of the specified file, returning `false` if the file does not exist.
+- 检索指定文件的 base64 编码内容,如果文件不存在则返回`false`。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "retrieveMediaFile",
- "version": 6,
- "params": {
- "filename": "_hello.txt"
- }
+ ```json
+ {
+ "action": "retrieveMediaFile",
+ "version": 6,
+ "params": {
+ "filename": "_hello.txt"
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": "SGVsbG8sIHdvcmxkIQ==",
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": "SGVsbG8sIHdvcmxkIQ==",
+ "error": null
+ }
+ ```
+
+
#### `getMediaFilesNames`
-* Gets the names of media files matched the pattern. Returning all names by default.
+- 获取与模式匹配的媒体文件名。默认返回所有名称。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "getMediaFilesNames",
- "version": 6,
- "params": {
- "pattern": "_hell*.txt"
- }
+ ```json
+ {
+ "action": "getMediaFilesNames",
+ "version": 6,
+ "params": {
+ "pattern": "_hell*.txt"
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": ["_hello.txt"],
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": ["_hello.txt"],
+ "error": null
+ }
+ ```
+
+
#### `getMediaDirPath`
-* Gets the full path to the `collection.media` folder of the currently opened profile.
+- 获取当前打开的配置文件的`collection.media`文件夹的完整路径。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "getMediaDirPath",
- "version": 6
- }
- ```
-
+ ```json
+ {
+ "action": "getMediaDirPath",
+ "version": 6
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": "/home/user/.local/share/Anki2/Main/collection.media",
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": "/home/user/.local/share/Anki2/Main/collection.media",
+ "error": null
+ }
+ ```
+
+
#### `deleteMediaFile`
-* Deletes the specified file inside the media folder.
+- 删除媒体文件夹中的指定文件。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "deleteMediaFile",
- "version": 6,
- "params": {
- "filename": "_hello.txt"
- }
+ ```json
+ {
+ "action": "deleteMediaFile",
+ "version": 6,
+ "params": {
+ "filename": "_hello.txt"
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
---
-### Miscellaneous Actions
+### 杂项操作
#### `requestPermission`
-* Requests permission to use the API exposed by this plugin. This method does not require the API key, and is the
- only one that accepts requests from any origin; the other methods only accept requests from trusted origins,
- which are listed under `webCorsOriginList` in the add-on config. `localhost` is trusted by default.
+- 请求使用此插件公开的 API 的权限。此方法不需要 API 密钥,是唯一接受来自任何来源的请求的方法;其他方法只接受来自受信任来源的请求,这些来源列在插件配置的`webCorsOriginList`下。默认情况下,`localhost`是受信任的。
- Calling this method from an untrusted origin will display a popup in Anki asking the user whether they want to
- allow your origin to use the API; calls from trusted origins will return the result without displaying the popup.
- When denying permission, the user may also choose to ignore further permission requests from that origin. These
- origins end up in the `ignoreOriginList`, editable via the add-on config.
+ 从不受信任的来源调用此方法将在 Anki 中显示一个弹出窗口,询问用户是否允许您的来源使用 API;来自受信任来源的调用将返回结果而不显示弹出窗口。
+ 在拒绝许可时,用户还可以选择忽略来自该来源的进一步许可请求。这些来源最终会出现在`ignoreOriginList`中,可通过插件配置进行编辑。
- The result always contains the `permission` field, which in turn contains either the string `granted` or `denied`,
- corresponding to whether your origin is trusted. If your origin is trusted, the fields `requireApiKey` (`true` if
- required) and `version` will also be returned.
+ 结果始终包含`permission`字段,该字段反过来包含字符串`granted`或`denied`,对应于您的来源是否受信任。如果您的来源受信任,还将返回字段`requireApiKey`(如果需要则为`true`)和`version`。
- This should be the first call you make to make sure that your application and Anki-Connect are able to communicate
- properly with each other. New versions of Anki-Connect are backwards compatible; as long as you are using actions
- which are available in the reported Anki-Connect version or earlier, everything should work fine.
+ 这应该是您进行的第一个调用,以确保您的应用程序和 Anki-Connect 能够相互正确通信。新版本的 Anki-Connect 向后兼容;只要您使用在报告的 Anki-Connect 版本或更早版本中可用的操作,一切都应该正常工作。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "requestPermission",
- "version": 6
- }
- ```
-
+ ```json
+ {
+ "action": "requestPermission",
+ "version": 6
+ }
+ ```
-
- Sample results:
+
- ```json
- {
- "result": {
- "permission": "granted",
- "requireApiKey": false,
- "version": 6
- },
- "error": null
- }
- ```
+
+ 示例结果:
- ```json
- {
- "result": {
- "permission": "denied"
- },
- "error": null
- }
- ```
-
+ ```json
+ {
+ "result": {
+ "permission": "granted",
+ "requireApiKey": false,
+ "version": 6
+ },
+ "error": null
+ }
+ ```
+
+ ```json
+ {
+ "result": {
+ "permission": "denied"
+ },
+ "error": null
+ }
+ ```
+
+
#### `version`
-* Gets the version of the API exposed by this plugin. Currently versions `1` through `6` are defined.
+- 获取此插件公开的 API 的版本。目前定义了版本`1`到`6`。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "version",
- "version": 6
- }
- ```
-
+ ```json
+ {
+ "action": "version",
+ "version": 6
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": 6,
- "error": null
- }
- ```
-
+
+ 示例结果:
+ ```json
+ {
+ "result": 6,
+ "error": null
+ }
+ ```
+
+
#### `apiReflect`
-* Gets information about the AnkiConnect APIs available. The request supports the following params:
-
- * `scopes` - An array of scopes to get reflection information about.
- The only currently supported value is `"actions"`.
- * `actions` - Either `null` or an array of API method names to check for.
- If the value is `null`, the result will list all of the available API actions.
- If the value is an array of strings, the result will only contain actions which were in this array.
-
- The result will contain a list of which scopes were used and a value for each scope.
- For example, the `"actions"` scope will contain a `"actions"` property which contains a list of supported action names.
-
-
- Sample request:
-
- ```json
- {
- "action": "apiReflect",
- "version": 6,
- "params": {
- "scopes": ["actions", "invalidType"],
- "actions": ["apiReflect", "invalidMethod"]
- }
+- 获取有关 AnkiConnect API 的信息。该请求支持以下参数:
+ - `scopes` - 一个包含要获取反射信息的范围的数组。
+ 当前唯一支持的值是 `"actions"`。
+ - `actions` - 为 `null` 或一个包含 API 方法名称的数组。
+ 如果值为 `null`,结果将列出所有可用的 API 动作。
+ 如果值是一个字符串数组,结果仅包含在该数组中的动作。
+ 结果将包含使用的作用域列表以及每个作用域的值。
+ 例如,`"actions"` 范围将包含一个 `"actions"` 属性,其中包含受支持的动作名称列表。
+
+ 示例请求:
+ ```json
+ {
+ "action": "apiReflect",
+ "version": 6,
+ "params": {
+ "scopes": ["actions", "invalidType"],
+ "actions": ["apiReflect", "invalidMethod"]
}
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": {
- "scopes": ["actions"],
- "actions": ["apiReflect"]
- },
- "error": null
- }
- ```
-
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": {
+ "scopes": ["actions"],
+ "actions": ["apiReflect"]
+ },
+ "error": null
+ }
+ ```
+
#### `sync`
-* Synchronizes the local Anki collections with AnkiWeb.
-
-
- Sample request:
-
- ```json
- {
- "action": "sync",
- "version": 6
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 将本地 Anki 集合与 AnkiWeb 同步。
+
+ 示例请求:
+ ```json
+ {
+ "action": "sync",
+ "version": 6
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
#### `getProfiles`
-* Retrieve the list of profiles.
-
-
- Sample request:
-
- ```json
- {
- "action": "getProfiles",
- "version": 6
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": ["User 1"],
- "error": null
- }
- ```
-
+- 检索配置文件列表。
+
+ 示例请求:
+ ```json
+ {
+ "action": "getProfiles",
+ "version": 6
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": ["User 1"],
+ "error": null
+ }
+ ```
+
#### `getActiveProfile`
-* Retrieve the active profile.
-
-
- Sample request:
-
- ```json
- {
- "action": "getActiveProfile",
- "version": 6
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": "User 1",
- "error": null
- }
- ```
-
-
+- 检索活动的配置文件。
+
+ 示例请求:
+ ```json
+ {
+ "action": "getActiveProfile",
+ "version": 6
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": "User 1",
+ "error": null
+ }
+ ```
+
#### `loadProfile`
-* Selects the profile specified in request.
-
-
- Sample request:
-
- ```json
- {
- "action": "loadProfile",
- "version": 6,
- "params": {
- "name": "user1"
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
+- 选择请求中指定的配置文件。
+
+ 示例请求:
+ ```json
+ {
+ "action": "loadProfile",
+ "version": 6,
+ "params": {
+ "name": "user1"
+ }
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
#### `multi`
-* Performs multiple actions in one request, returning an array with the response of each action (in the given order).
-
-
- Sample request:
-
- ```json
- {
- "action": "multi",
- "version": 6,
- "params": {
- "actions": [
- {
- "action": "deckNames"
- },
- {
- "action": "deckNames",
- "version": 6
- },
- {
- "action": "invalidAction",
- "params": {"useless": "param"}
- },
- {
- "action": "invalidAction",
- "params": {"useless": "param"},
- "version": 6
- }
- ]
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": [
- ["Default"],
- {"result": ["Default"], "error": null},
- {"result": null, "error": "unsupported action"},
- {"result": null, "error": "unsupported action"}
- ],
- "error": null
- }
- ```
-
+- 在一个请求中执行多个操作,返回一个包含每个操作响应的数组(按给定顺序)。
+
+ 示例请求:
+ ```json
+ {
+ "action": "multi",
+ "version": 6,
+ "params": {
+ "actions": [
+ {
+ "action": "deckNames"
+ },
+ {
+ "action": "deckNames",
+ "version": 6
+ },
+ {
+ "action": "invalidAction",
+ "params": {"useless": "param"}
+ },
+ {
+ "action": "invalidAction",
+ "params": {"useless": "param"},
+ "version": 6
+ }
+ ]
+ }
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": [
+ ["Default"],
+ {"result": ["Default"], "error": null},
+ {"result": null, "error": "unsupported action"},
+ {"result": null, "error": "unsupported action"}
+ ],
+ "error": null
+ }
+ ```
+
#### `exportPackage`
-* Exports a given deck in `.apkg` format. Returns `true` if successful or `false` otherwise. The optional property
- `includeSched` (default is `false`) can be specified to include the cards' scheduling data.
-
-
- Sample request:
-
- ```json
- {
- "action": "exportPackage",
- "version": 6,
- "params": {
- "deck": "Default",
- "path": "/data/Deck.apkg",
- "includeSched": true
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
+- 将给定牌组导出为 `.apkg` 格式。如果成功则返回 `true`,否则返回 `false`。可选属性
+ `includeSched`(默认为 `false`)可以指定是否包含卡片的调度数据。
+
+ 示例请求:
+ ```json
+ {
+ "action": "exportPackage",
+ "version": 6,
+ "params": {
+ "deck": "Default",
+ "path": "/data/Deck.apkg",
+ "includeSched": true
+ }
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
#### `importPackage`
-* Imports a file in `.apkg` format into the collection. Returns `true` if successful or `false` otherwise.
- Note that the file path is relative to Anki's collection.media folder, not to the client.
-
-
- Sample request:
-
- ```json
- {
- "action": "importPackage",
- "version": 6,
- "params": {
- "path": "/data/Deck.apkg"
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
+- 将以 `.apkg` 格式的文件导入到集合中。如果成功则返回 `true`,否则返回 `false`。
+ 注意,文件路径相对于 Anki 的 collection.media 文件夹,而不是客户端。
+
+ 示例请求:
+ ```json
+ {
+ "action": "importPackage",
+ "version": 6,
+ "params": {
+ "path": "/data/Deck.apkg"
+ }
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
#### `reloadCollection`
-* Tells anki to reload all data from the database.
-
-
- Sample request:
-
- ```json
- {
- "action": "reloadCollection",
- "version": 6
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 告诉 Anki 从数据库重新加载所有数据。
+
+ 示例请求:
+ ```json
+ {
+ "action": "reloadCollection",
+ "version": 6
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
---
-### Model Actions
+### 模型操作
#### `modelNames`
-* Gets the complete list of model names for the current user.
-
-
- Sample request:
-
- ```json
- {
- "action": "modelNames",
- "version": 6
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": ["Basic", "Basic (and reversed card)"],
- "error": null
- }
- ```
-
+- 获取当前用户的所有模型名称的完整列表。
+
+ 示例请求:
+ ```json
+ {
+ "action": "modelNames",
+ "version": 6
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": ["Basic", "Basic (and reversed card)"],
+ "error": null
+ }
+ ```
+
#### `modelNamesAndIds`
-* Gets the complete list of model names and their corresponding IDs for the current user.
-
-
- Sample request:
-
- ```json
- {
- "action": "modelNamesAndIds",
- "version": 6
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": {
- "Basic": 1483883011648,
- "Basic (and reversed card)": 1483883011644,
- "Basic (optional reversed card)": 1483883011631,
- "Cloze": 1483883011630
- },
- "error": null
- }
- ```
-
+- 获取当前用户的所有模型名称及其对应 ID 的完整列表。
+
+ 示例请求:
+ ```json
+ {
+ "action": "modelNamesAndIds",
+ "version": 6
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": {
+ "Basic": 1483883011648,
+ "Basic (and reversed card)": 1483883011644,
+ "Basic (optional reversed card)": 1483883011631,
+ "Cloze": 1483883011630
+ },
+ "error": null
+ }
+ ```
+
#### `findModelsById`
-* Gets a list of models for the provided model IDs from the current user.
-
-
- Sample request:
-
- ```json
+- 从当前用户提供的模型 ID 中获取模型列表。
+
+示例请求:
+`json
{
"action": "findModelsById",
"version": 6,
@@ -2412,29 +2435,29 @@ Documentation for currently supported actions is split up by category and is ref
"modelIds": [1704387367119, 1704387398570]
}
}
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": [
- {
- "id": 1704387367119,
- "name": "Basic",
- "type": 0,
- "mod": 1704387367,
- "usn": -1,
- "sortf": 0,
- "did": null,
- "tmpls": [
- {
- "name": "Card 1",
- "ord": 0,
- "qfmt": "{{Front}}",
- "afmt": "{{FrontSide}}\n\n
\n\n{{Back}}",
+ `
+
+
+示例结果:
+```json
+{
+"result": [
+{
+"id": 1704387367119,
+"name": "Basic",
+"type": 0,
+"mod": 1704387367,
+"usn": -1,
+"sortf": 0,
+"did": null,
+"tmpls": [
+{
+"name": "Card 1",
+"ord": 0,
+"qfmt": "{{Front}}",
+"afmt": "{{FrontSide}}
+
+{{Back}}",
"bqfmt": "",
"bafmt": "",
"did": null,
@@ -2475,8 +2498,22 @@ Documentation for currently supported actions is split up by category and is ref
"preventDeletion": false
}
],
- "css": ".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n",
- "latexPre": "\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n",
+ "css": ".card {
+ font-family: arial;
+ font-size: 20px;
+ text-align: center;
+ color: black;
+ background-color: white;
+}
+",
+ "latexPre": "\\documentclass[12pt]{article}
+\\special{papersize=3in,5in}
+\\usepackage[utf8]{inputenc}
+\\usepackage{amssymb,amsmath}
+\\pagestyle{empty}
+\\setlength{\\parindent}{0in}
+\\begin{document}
+",
"latexPost": "\\end{document}",
"latexsvg": false,
"req": [
@@ -2503,7 +2540,9 @@ Documentation for currently supported actions is split up by category and is ref
"name": "Card 1",
"ord": 0,
"qfmt": "{{Front}}",
- "afmt": "{{FrontSide}}\n\n
\n\n{{Back}}",
+ "afmt": "{{FrontSide}}
+
+{{Back}}",
"bqfmt": "",
"bafmt": "",
"did": null,
@@ -2515,7 +2554,9 @@ Documentation for currently supported actions is split up by category and is ref
"name": "Card 2",
"ord": 1,
"qfmt": "{{Back}}",
- "afmt": "{{FrontSide}}\n\n
\n\n{{Front}}",
+ "afmt": "{{FrontSide}}
+
+{{Front}}",
"bqfmt": "",
"bafmt": "",
"did": null,
@@ -2556,8 +2597,22 @@ Documentation for currently supported actions is split up by category and is ref
"preventDeletion": false
}
],
- "css": ".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n",
- "latexPre": "\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n",
+ "css": ".card {
+ font-family: arial;
+ font-size: 20px;
+ text-align: center;
+ color: black;
+ background-color: white;
+}
+",
+ "latexPre": "\\documentclass[12pt]{article}
+\\special{papersize=3in,5in}
+\\usepackage[utf8]{inputenc}
+\\usepackage{amssymb,amsmath}
+\\pagestyle{empty}
+\\setlength{\\parindent}{0in}
+\\begin{document}
+",
"latexPost": "\\end{document}",
"latexsvg": false,
"req": [
@@ -2584,15 +2639,12 @@ Documentation for currently supported actions is split up by category and is ref
```
-
#### `findModelsByName`
-* Gets a list of models for the provided model names from the current user.
-
-
- Sample request:
-
- ```json
+- 从当前用户提供的模型名称中获取模型列表。
+
+示例请求:
+`json
{
"action": "findModelsByName",
"version": 6,
@@ -2600,29 +2652,29 @@ Documentation for currently supported actions is split up by category and is ref
"modelNames": ["Basic", "Basic (and reversed card)"]
}
}
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": [
- {
- "id": 1704387367119,
- "name": "Basic",
- "type": 0,
- "mod": 1704387367,
- "usn": -1,
- "sortf": 0,
- "did": null,
- "tmpls": [
- {
- "name": "Card 1",
- "ord": 0,
- "qfmt": "{{Front}}",
- "afmt": "{{FrontSide}}\n\n
\n\n{{Back}}",
+ `
+
+
+示例结果:
+```json
+{
+"result": [
+{
+"id": 1704387367119,
+"name": "Basic",
+"type": 0,
+"mod": 1704387367,
+"usn": -1,
+"sortf": 0,
+"did": null,
+"tmpls": [
+{
+"name": "Card 1",
+"ord": 0,
+"qfmt": "{{Front}}",
+"afmt": "{{FrontSide}}
+
+{{Back}}",
"bqfmt": "",
"bafmt": "",
"did": null,
@@ -2663,8 +2715,22 @@ Documentation for currently supported actions is split up by category and is ref
"preventDeletion": false
}
],
- "css": ".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n",
- "latexPre": "\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n",
+ "css": ".card {
+ font-family: arial;
+ font-size: 20px;
+ text-align: center;
+ color: black;
+ background-color: white;
+}
+",
+ "latexPre": "\\documentclass[12pt]{article}
+\\special{papersize=3in,5in}
+\\usepackage[utf8]{inputenc}
+\\usepackage{amssymb,amsmath}
+\\pagestyle{empty}
+\\setlength{\\parindent}{0in}
+\\begin{document}
+",
"latexPost": "\\end{document}",
"latexsvg": false,
"req": [
@@ -2691,7 +2757,9 @@ Documentation for currently supported actions is split up by category and is ref
"name": "Card 1",
"ord": 0,
"qfmt": "{{Front}}",
- "afmt": "{{FrontSide}}\n\n
\n\n{{Back}}",
+ "afmt": "{{FrontSide}}
+
+{{Back}}",
"bqfmt": "",
"bafmt": "",
"did": null,
@@ -2703,7 +2771,9 @@ Documentation for currently supported actions is split up by category and is ref
"name": "Card 2",
"ord": 1,
"qfmt": "{{Back}}",
- "afmt": "{{FrontSide}}\n\n
\n\n{{Front}}",
+ "afmt": "{{FrontSide}}
+
+{{Front}}",
"bqfmt": "",
"bafmt": "",
"did": null,
@@ -2744,8 +2814,22 @@ Documentation for currently supported actions is split up by category and is ref
"preventDeletion": false
}
],
- "css": ".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n",
- "latexPre": "\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n",
+ "css": ".card {
+ font-family: arial;
+ font-size: 20px;
+ text-align: center;
+ color: black;
+ background-color: white;
+}
+",
+ "latexPre": "\\documentclass[12pt]{article}
+\\special{papersize=3in,5in}
+\\usepackage[utf8]{inputenc}
+\\usepackage{amssymb,amsmath}
+\\pagestyle{empty}
+\\setlength{\\parindent}{0in}
+\\begin{document}
+",
"latexPost": "\\end{document}",
"latexsvg": false,
"req": [
@@ -2774,145 +2858,124 @@ Documentation for currently supported actions is split up by category and is ref
#### `modelFieldNames`
-* Gets the complete list of field names for the provided model name.
-
-
- Sample request:
-
- ```json
- {
- "action": "modelFieldNames",
- "version": 6,
- "params": {
- "modelName": "Basic"
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": ["Front", "Back"],
- "error": null
- }
- ```
-
+- 获取提供模型名称的字段名称的完整列表。
+
+ 示例请求:
+ ```json
+ {
+ "action": "modelFieldNames",
+ "version": 6,
+ "params": {
+ "modelName": "Basic"
+ }
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": ["Front", "Back"],
+ "error": null
+ }
+ ```
+
#### `modelFieldDescriptions`
-* Gets the complete list of field descriptions (the text seen in the gui editor when a field is empty) for the provided model name.
-
-
- Sample request:
-
- ```json
- {
- "action": "modelFieldDescriptions",
- "version": 6,
- "params": {
- "modelName": "Basic"
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": ["", ""],
- "error": null
- }
- ```
-
+- 获取提供模型名称的字段描述(在 GUI 编辑器中字段为空时看到的文本)的完整列表。
+
+ 示例请求:
+ ```json
+ {
+ "action": "modelFieldDescriptions",
+ "version": 6,
+ "params": {
+ "modelName": "Basic"
+ }
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": ["", ""],
+ "error": null
+ }
+ ```
+
#### `modelFieldFonts`
-* Gets the complete list of fonts along with their font sizes.
-
-
- Sample request:
-
- ```json
- {
- "action": "modelFieldFonts",
- "version": 6,
- "params": {
- "modelName": "Basic"
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": {
- "Front": {
- "font": "Arial",
- "size": 20
- },
- "Back": {
- "font": "Arial",
- "size": 20
- }
- },
- "error": null
- }
- ```
-
+- 获取字体及其字体大小的完整列表。
+
+ 示例请求:
+ ```json
+ {
+ "action": "modelFieldFonts",
+ "version": 6,
+ "params": {
+ "modelName": "Basic"
+ }
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": {
+ "Front": {
+ "font": "Arial",
+ "size": 20
+ },
+ "Back": {
+ "font": "Arial",
+ "size": 20
+ }
+ },
+ "error": null
+ }
+ ```
+
#### `modelFieldsOnTemplates`
-* Returns an object indicating the fields on the question and answer side of each card template for the given model
- name. The question side is given first in each array.
-
-
- Sample request:
-
- ```json
- {
- "action": "modelFieldsOnTemplates",
- "version": 6,
- "params": {
- "modelName": "Basic (and reversed card)"
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": {
- "Card 1": [["Front"], ["Back"]],
- "Card 2": [["Back"], ["Front"]]
- },
- "error": null
- }
- ```
-
+- 返回一个对象,指示给定模型名称的每个卡模板的问题和答案侧的字段。问题侧在每个数组中首先给出。
+
+ 示例请求:
+ ```json
+ {
+ "action": "modelFieldsOnTemplates",
+ "version": 6,
+ "params": {
+ "modelName": "Basic (and reversed card)"
+ }
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": {
+ "Card 1": [["Front"], ["Back"]],
+ "Card 2": [["Back"], ["Front"]]
+ },
+ "error": null
+ }
+ ```
+
#### `createModel`
-* Creates a new model to be used in Anki. User must provide the `modelName`, `inOrderFields` and `cardTemplates` to be
- used in the model. There are optional fields `css` and `isCloze`. If not specified, `css` will use the default Anki css and `isCloze` will be equal to `false`. If `isCloze` is `true` then model will be created as Cloze.
-
- Optionally the `Name` field can be provided for each entry of `cardTemplates`. By default the
- card names will be `Card 1`, `Card 2`, and so on.
-
-
- Sample request:
-
- ```json
+- 创建一个用于 Anki 的新模型。用户必须提供 `modelName`, `inOrderFields` 和 `cardTemplates`。
+ 可选字段有 `css` 和 `isCloze`。如果未指定,`css` 将使用默认的 Anki css,`isCloze` 将等于 `false`。如果 `isCloze` 为 `true`,则模型将作为 Cloze 创建。
+ 可以为 `cardTemplates` 中的每个条目提供可选的 `Name` 字段。默认情况下,卡名称将是 `Card 1`、`Card 2` 等等。
+
+ 示例请求:
+ `json
{
"action": "createModel",
"version": 6,
@@ -2930,26 +2993,37 @@ Documentation for currently supported actions is split up by category and is ref
]
}
}
- ```
-
-
-
- Sample result:
-
- ```json
+ `
+
+
+ 示例结果:
+ `json
{
"result":{
"sortf":0,
"did":1,
- "latexPre":"\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n",
+ "latexPre":"\\documentclass[12pt]{article}
+\\special{papersize=3in,5in}
+\\usepackage[utf8]{inputenc}
+\\usepackage{amssymb,amsmath}
+\\pagestyle{empty}
+\\setlength{\\parindent}{0in}
+\\begin{document}
+",
"latexPost":"\\end{document}",
"mod":1551462107,
"usn":-1,
"vers":[
-
],
"type":0,
- "css":".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n",
+ "css":".card {
+ font-family: arial;
+ font-size: 20px;
+ text-align: center;
+ color: black;
+ background-color: white;
+}
+",
"name":"TestApiModel",
"flds":[
{
@@ -2960,7 +3034,6 @@ Documentation for currently supported actions is split up by category and is ref
"font":"Arial",
"size":20,
"media":[
-
]
},
{
@@ -2971,7 +3044,6 @@ Documentation for currently supported actions is split up by category and is ref
"font":"Arial",
"size":20,
"media":[
-
]
}
],
@@ -2987,7 +3059,6 @@ Documentation for currently supported actions is split up by category and is ref
}
],
"tags":[
-
],
"id":1551462107104,
"req":[
@@ -2995,24 +3066,21 @@ Documentation for currently supported actions is split up by category and is ref
0,
"none",
[
-
]
]
]
},
"error":null
}
- ```
-
+ `
+
#### `modelTemplates`
-* Returns an object indicating the template content for each card connected to the provided model by name.
-
-
- Sample request:
-
- ```json
+- 返回一个对象,表示通过提供的模型名称连接的每张卡的模板内容。
+
+示例请求:
+`json
{
"action": "modelTemplates",
"version": 6,
@@ -3020,22 +3088,24 @@ Documentation for currently supported actions is split up by category and is ref
"modelName": "Basic (and reversed card)"
}
}
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": {
- "Card 1": {
- "Front": "{{Front}}",
- "Back": "{{FrontSide}}\n\n
\n\n{{Back}}"
+ `
+
+
+示例结果:
+```json
+{
+"result": {
+"Card 1": {
+"Front": "{{Front}}",
+"Back": "{{FrontSide}}
+
+{{Back}}"
},
"Card 2": {
"Front": "{{Back}}",
- "Back": "{{FrontSide}}\n\n
\n\n{{Front}}"
+ "Back": "{{FrontSide}}
+
+{{Front}}"
}
},
"error": null
@@ -3045,12 +3115,10 @@ Documentation for currently supported actions is split up by category and is ref
#### `modelStyling`
-* Gets the CSS styling for the provided model by name.
-
-
- Sample request:
-
- ```json
+- 获取通过提供的模型名称的模型的 CSS 样式。
+
+ 示例请求:
+ `json
{
"action": "modelStyling",
"version": 6,
@@ -3058,582 +3126,494 @@ Documentation for currently supported actions is split up by category and is ref
"modelName": "Basic (and reversed card)"
}
}
- ```
-
-
-
- Sample result:
-
- ```json
+ `
+
+
+ 示例结果:
+ `json
{
"result": {
- "css": ".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n"
+ "css": ".card {
+ font-family: arial;
+ font-size: 20px;
+ text-align: center;
+ color: black;
+ background-color: white;
+}
+"
},
"error": null
}
- ```
-
+ `
+
#### `updateModelTemplates`
-* Modify the templates of an existing model by name. Only specifies cards and specified sides will be modified.
- If an existing card or side is not included in the request, it will be left unchanged.
-
-
- Sample request:
-
- ```json
- {
- "action": "updateModelTemplates",
- "version": 6,
- "params": {
- "model": {
- "name": "Custom",
- "templates": {
- "Card 1": {
- "Front": "{{Question}}?",
- "Back": "{{Answer}}!"
- }
- }
- }
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 通过名称修改现有模型的模板。仅修改请求中指定的卡和指定的侧面。
+ 如果请求中未包含现有的卡或侧面,则不会进行任何更改。
+
+ 示例请求:
+ ```json
+ {
+ "action": "updateModelTemplates",
+ "version": 6,
+ "params": {
+ "model": {
+ "name": "Custom",
+ "templates": {
+ "Card 1": {
+ "Front": "{{Question}}?",
+ "Back": "{{Answer}}!"
+ }
+ }
+ }
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
#### `updateModelStyling`
-* Modify the CSS styling of an existing model by name.
-
-
- Sample request:
-
- ```json
- {
- "action": "updateModelStyling",
- "version": 6,
- "params": {
- "model": {
- "name": "Custom",
- "css": "p { color: blue; }"
- }
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 修改现有模型的 CSS 样式。
+
+ 示例请求:
+ ```json
+ {
+ "action": "updateModelStyling",
+ "version": 6,
+ "params": {
+ "model": {
+ "name": "Custom",
+ "css": "p { color: blue; }"
+ }
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
#### `findAndReplaceInModels`
-* Find and replace string in existing model by model name. Customise to replace in front, back or css by setting to true/false.
-
-
- Sample request:
-
- ```json
- {
- "action": "findAndReplaceInModels",
- "version": 6,
- "params": {
- "model": {
- "modelName": "",
- "findText": "text_to_replace",
- "replaceText": "replace_with_text",
- "front": true,
- "back": true,
- "css": true
- }
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": 1,
- "error": null
- }
- ```
-
+- 在现有模型中查找并替换字符串。可以通过设置为 true/false 来自定义在 front、back 或 css 中替换。
+
+ 示例请求:
+ ```json
+ {
+ "action": "findAndReplaceInModels",
+ "version": 6,
+ "params": {
+ "model": {
+ "modelName": "",
+ "findText": "text_to_replace",
+ "replaceText": "replace_with_text",
+ "front": true,
+ "back": true,
+ "css": true
+ }
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": 1,
+ "error": null
+ }
+ ```
+
#### `modelTemplateRename`
-* Renames a template in an existing model.
-
-
- Sample request:
-
- ```json
- {
- "action": "modelTemplateRename",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "oldTemplateName": "Card 1",
- "newTemplateName": "Card 1 renamed"
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 重命名现有模型中的模板。
+
+ 示例请求:
+ ```json
+ {
+ "action": "modelTemplateRename",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "oldTemplateName": "Card 1",
+ "newTemplateName": "Card 1 renamed"
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
#### `modelTemplateReposition`
-* Repositions a template in an existing model.
-
- The value of `index` starts at 0. For example, an index of `0` puts the template in the first position, and an index of `2` puts the template in the third position.
-
-
- Sample request:
-
- ```json
- {
- "action": "modelTemplateReposition",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "templateName": "Card 1",
- "index": 1
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 重新定位现有模型中的模板。
+ `index` 的值从 0 开始。例如,索引为 `0` 时将模板放在第一个位置,索引为 `2` 时将模板放在第三个位置。
+
+ 示例请求:
+ ```json
+ {
+ "action": "modelTemplateReposition",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "templateName": "Card 1",
+ "index": 1
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
#### `modelTemplateAdd`
-* Adds a template to an existing model by name. If you want to update an existing template, use `updateModelTemplates`.
-
-
- Sample request:
-
- ```json
- {
- "action": "modelTemplateAdd",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "template": {
- "Name": "Card 3",
- "Front": "Front html {{Field1}}",
- "Back": "Back html {{Field2}}"
- }
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 通过名称向现有模型添加模板。如果您想更新现有模板,请使用 `updateModelTemplates`。
+
+ 示例请求:
+ ```json
+ {
+ "action": "modelTemplateAdd",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "template": {
+ "Name": "Card 3",
+ "Front": "Front html {{Field1}}",
+ "Back": "Back html {{Field2}}"
+ }
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
#### `modelTemplateRemove`
-* Removes a template from an existing model.
-
-
- Sample request:
-
- ```json
- {
- "action": "modelTemplateRemove",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "templateName": "Card 1"
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 从现有模型中删除模板。
+
+ 示例请求:
+ ```json
+ {
+ "action": "modelTemplateRemove",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "templateName": "Card 1"
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
#### `modelFieldRename`
-* Rename the field name of a given model.
-
-
- Sample request:
-
- ```json
- {
- "action": "modelFieldRename",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "oldFieldName": "Front",
- "newFieldName": "FrontRenamed"
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 重命名给定模型的字段名称。
+
+ 示例请求:
+ ```json
+ {
+ "action": "modelFieldRename",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "oldFieldName": "Front",
+ "newFieldName": "FrontRenamed"
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
#### `modelFieldReposition`
-* Reposition the field within the field list of a given model.
-
- The value of `index` starts at 0. For example, an index of `0` puts the field in the first position, and an index of `2` puts the field in the third position.
-
-
- Sample request:
-
- ```json
- {
- "action": "modelFieldReposition",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "fieldName": "Back",
- "index": 0
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 在给定模型的字段列表中重新定位字段。
+ `index` 的值从 0 开始。例如,索引为 `0` 时将字段放在第一个位置,索引为 `2` 时将字段放在第三个位置。
+
+ 示例请求:
+ ```json
+ {
+ "action": "modelFieldReposition",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "fieldName": "Back",
+ "index": 0
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
#### `modelFieldAdd`
-* Creates a new field within a given model.
-
- Optionally, the `index` value can be provided, which works exactly the same as the index in `modelFieldReposition`. By default, the field is added to the end of the field list.
-
-
- Sample request:
-
- ```json
- {
- "action": "modelFieldAdd",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "fieldName": "NewField",
- "index": 0
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 在给定模型中创建一个新字段。
+ 可以选择性地提供 `index` 值,其工作方式与 `modelFieldReposition` 中的索引完全相同。默认情况下,字段会被添加到字段列表的末尾。
+
+ 示例请求:
+ ```json
+ {
+ "action": "modelFieldAdd",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "fieldName": "NewField",
+ "index": 0
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
#### `modelFieldRemove`
-* Deletes a field within a given model.
-
-
- Sample request:
-
- ```json
- {
- "action": "modelFieldRemove",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "fieldName": "Front"
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 删除给定模型内的字段。
+
+ 示例请求:
+ ```json
+ {
+ "action": "modelFieldRemove",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "fieldName": "Front"
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
#### `modelFieldSetFont`
-* Sets the font for a field within a given model.
-
-
- Sample request:
-
- ```json
- {
- "action": "modelFieldSetFont",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "fieldName": "Front",
- "font": "Courier"
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 设置给定模型内字段的字体。
+
+ 示例请求:
+ ```json
+ {
+ "action": "modelFieldSetFont",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "fieldName": "Front",
+ "font": "Courier"
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
#### `modelFieldSetFontSize`
-* Sets the font size for a field within a given model.
-
-
- Sample request:
-
- ```json
- {
- "action": "modelFieldSetFontSize",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "fieldName": "Front",
- "fontSize": 10
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 设置给定模型内字段的字体大小。
+
+ 示例请求:
+ ```json
+ {
+ "action": "modelFieldSetFontSize",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "fieldName": "Front",
+ "fontSize": 10
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
#### `modelFieldSetDescription`
-* Sets the description (the text seen in the gui editor when a field is empty) for a field within a given model.
-
- Older versions of Anki (2.1.49 and below) do not have field descriptions. In that case, this will return with `false`.
-
-
- Sample request:
-
- ```json
- {
- "action": "modelFieldSetDescription",
- "version": 6,
- "params": {
- "modelName": "Basic",
- "fieldName": "Front",
- "description": "example field description"
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": true,
- "error": null
- }
- ```
-
+- 设置给定模型内字段的描述(在字段为空时在 GUI 编辑器中看到的文本)。
+ 较旧版本的 Anki(2.1.49 及以下)没有字段描述。在这种情况下,这将返回 `false`。
+
+ 示例请求:
+ ```json
+ {
+ "action": "modelFieldSetDescription",
+ "version": 6,
+ "params": {
+ "modelName": "Basic",
+ "fieldName": "Front",
+ "description": "example field description"
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": true,
+ "error": null
+ }
+ ```
+
---
-### Note Actions
+### 笔记操作
#### `addNote`
-* Creates a note using the given deck and model, with the provided field values and tags. Returns the identifier of
- the created note created on success, and `null` on failure.
-
- Anki-Connect can download audio, video, and picture files and embed them in newly created notes. The corresponding `audio`, `video`, and `picture` note members are
- optional and can be omitted. If you choose to include any of them, they should contain a single object or an array of objects
- with the mandatory `filename` field and one of `data`, `path` or `url`. Refer to the documentation of `storeMediaFile` for an explanation of these fields.
- The `skipHash` field can be optionally provided to skip the inclusion of files with an MD5 hash that matches the provided value.
- This is useful for avoiding the saving of error pages and stub files.
- The `fields` member is a list of fields that should play audio or video, or show a picture when the card is displayed in
- Anki. The `allowDuplicate` member inside `options` group can be set to true to enable adding duplicate cards.
- Normally duplicate cards can not be added and trigger exception.
-
- The `duplicateScope` member inside `options` can be used to specify the scope for which duplicates are checked.
- A value of `"deck"` will only check for duplicates in the target deck; any other value will check the entire collection.
-
- The `duplicateScopeOptions` object can be used to specify some additional settings:
-
- * `duplicateScopeOptions.deckName` will specify which deck to use for checking duplicates in. If undefined or `null`, the target deck will be used.
- * `duplicateScopeOptions.checkChildren` will change whether or not duplicate cards are checked in child decks. The default value is `false`.
- * `duplicateScopeOptions.checkAllModels` specifies whether duplicate checks are performed across all note types. The default value is `false`.
-
-
- Sample request:
-
- ```json
- {
- "action": "addNote",
- "version": 6,
- "params": {
- "note": {
- "deckName": "Default",
- "modelName": "Basic",
- "fields": {
- "Front": "front content",
- "Back": "back content"
- },
- "options": {
- "allowDuplicate": false,
- "duplicateScope": "deck",
- "duplicateScopeOptions": {
- "deckName": "Default",
- "checkChildren": false,
- "checkAllModels": false
- }
- },
- "tags": [
- "yomichan"
- ],
- "audio": [{
- "url": "https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kanji=猫&kana=ねこ",
- "filename": "yomichan_ねこ_猫.mp3",
- "skipHash": "7e2c2f954ef6051373ba916f000168dc",
- "fields": [
- "Front"
- ]
- }],
- "video": [{
- "url": "https://cdn.videvo.net/videvo_files/video/free/2015-06/small_watermarked/Contador_Glam_preview.mp4",
- "filename": "countdown.mp4",
- "skipHash": "4117e8aab0d37534d9c8eac362388bbe",
- "fields": [
- "Back"
- ]
- }],
- "picture": [{
- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c7/A_black_cat_named_Tilly.jpg/220px-A_black_cat_named_Tilly.jpg",
- "filename": "black_cat.jpg",
- "skipHash": "8d6e4646dfae812bf39651b59d7429ce",
- "fields": [
- "Back"
- ]
- }]
- }
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": 1496198395707,
- "error": null
- }
- ```
-
+- 使用给定的牌组和模型,以及提供的字段值和标签创建笔记。在成功创建时返回创建的笔记标识符,在失败时返回 `null`。
+ Anki-Connect 可以下载音频、视频和图片文件并将它们嵌入到新创建的笔记中。相应的 `audio`、`video` 和 `picture` 笔记成员是可选的,可以省略。如果您选择包含其中任何一个,它们应该包含一个单个对象或一组具有必填 `filename` 字段和 `data`、`path` 或 `url` 其中之一的对象。请参阅 `storeMediaFile` 文档以了解这些字段的解释。
+ 可以选择性地提供 `skipHash` 字段以跳过包含与提供的 MD5 哈希匹配的文件。这对于避免保存错误页面和存根文件很有用。
+ `fields` 成员是一个应播放音频或视频或在 Anki 中显示卡片时显示图片的字段列表。`options` 组内的 `allowDuplicate` 成员可以设置为 true 以启用添加重复卡片。通常重复卡片不能被添加,并会触发异常。
+ `duplicateScope` 成员可以在 `options` 内用于指定检查重复项的范围。值为 `"deck"` 将只在目标牌组中检查重复项;其他任何值将在整个集合中检查。
+ `duplicateScopeOptions` 对象可用于指定一些额外的设置:
+ - `duplicateScopeOptions.deckName` 将指定在检查重复项时使用的牌组。如果未定义或为 `null`,将使用目标牌组。
+ - `duplicateScopeOptions.checkChildren` 将改变是否在子牌组中检查重复卡片。默认值为 `false`。
+ - `duplicateScopeOptions.checkAllModels` 指定是否在所有笔记类型之间执行重复检查。默认值为 `false`。
+
+ 示例请求:
+ ```json
+ {
+ "action": "addNote",
+ "version": 6,
+ "params": {
+ "note": {
+ "deckName": "Default",
+ "modelName": "Basic",
+ "fields": {
+ "Front": "front content",
+ "Back": "back content"
+ },
+ "options": {
+ "allowDuplicate": false,
+ "duplicateScope": "deck",
+ "duplicateScopeOptions": {
+ "deckName": "Default",
+ "checkChildren": false,
+ "checkAllModels": false
+ }
+ },
+ "tags": [
+ "yomichan"
+ ],
+ "audio": [{
+ "url": "https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kanji=猫&kana=ねこ",
+ "filename": "yomichan_ねこ_猫.mp3",
+ "skipHash": "7e2c2f954ef6051373ba916f000168dc",
+ "fields": [
+ "Front"
+ ]
+ }],
+ "video": [{
+ "url": "https://cdn.videvo.net/videvo_files/video/free/2015-06/small_watermarked/Contador_Glam_preview.mp4",
+ "filename": "countdown.mp4",
+ "skipHash": "4117e8aab0d37534d9c8eac362388bbe",
+ "fields": [
+ "Back"
+ ]
+ }],
+ "picture": [{
+ "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c7/A_black_cat_named_Tilly.jpg/220px-A_black_cat_named_Tilly.jpg",
+ "filename": "black_cat.jpg",
+ "skipHash": "8d6e4646dfae812bf39651b59d7429ce",
+ "fields": [
+ "Back"
+ ]
+ }]
+ }
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": 1496198395707,
+ "error": null
+ }
+ ```
+
#### `addNotes`
-* Creates multiple notes using the given deck and model, with the provided field values and tags. Returns an array of
- identifiers of the created notes. In the event of any errors, all errors are gathered and returned.
-* Please see the documentation for `addNote` for an explanation of objects in the `notes` array.
-
+- 使用给定的牌组和模型,以及提供的字段值和标签创建多个笔记。返回创建的笔记标识符的数组。在发生任何错误的情况下,将收集所有错误并返回。
+- 请参阅 `addNote` 的文档以了解 `notes` 数组中的对象的解释。
- Sample request:
-
+ 示例请求:
```json
{
"action":"addNotes",
@@ -3658,13 +3638,10 @@ Documentation for currently supported actions is split up by category and is ref
}
]
}
- }
```
-
- Sample result:
-
+ 示例结果:
```json
{
"result":null,
@@ -3675,218 +3652,183 @@ Documentation for currently supported actions is split up by category and is ref
#### `canAddNotes`
-* Accepts an array of objects which define parameters for candidate notes (see `addNote`) and returns an array of
- booleans indicating whether or not the parameters at the corresponding index could be used to create a new note.
-
-
- Sample request:
-
- ```json
- {
- "action": "canAddNotes",
- "version": 6,
- "params": {
- "notes": [
- {
- "deckName": "Default",
- "modelName": "Basic",
- "fields": {
- "Front": "front content",
- "Back": "back content"
- },
- "tags": [
- "yomichan"
- ]
- }
- ]
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": [true],
- "error": null
- }
- ```
-
+- 接收一个定义候选笔记参数的对象数组(参见 `addNote`),并返回一个布尔数组,指示相应索引处的参数是否可以用于创建新笔记。
+
+ 示例请求:
+ ```json
+ {
+ "action": "canAddNotes",
+ "version": 6,
+ "params": {
+ "notes": [
+ {
+ "deckName": "Default",
+ "modelName": "Basic",
+ "fields": {
+ "Front": "front content",
+ "Back": "back content"
+ },
+ "tags": [
+ "yomichan"
+ ]
+ }
+ ]
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": [true],
+ "error": null
+ }
+ ```
+
#### `canAddNotesWithErrorDetail`
-* Accepts an array of objects which define parameters for candidate notes (see `addNote`) and returns an array of
- objects with fields `canAdd` and `error`.
-
- * `canAdd` indicates whether or not the parameters at the corresponding index could be used to create a new note.
- * `error` contains an explanation of why a note cannot be added.
-
-
- Sample request:
-
- ```json
- {
- "action": "canAddNotesWithErrorDetail",
- "version": 6,
- "params": {
- "notes": [
- {
- "deckName": "Default",
- "modelName": "Basic",
- "fields": {
- "Front": "front content",
- "Back": "back content"
- },
- "tags": [
- "yomichan"
- ]
- },
- {
- "deckName": "Default",
- "modelName": "Basic",
- "fields": {
- "Front": "front content 2",
- "Back": "back content 2"
- },
- "tags": [
- "yomichan"
- ]
- }
- ]
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": [
- {
- "canAdd": false,
- "error": "cannot create note because it is a duplicate"
- },
- {
- "canAdd": true
- }
- ],
- "error": null
- }
- ```
-
+- 接收一个定义候选笔记参数的对象数组(参见 `addNote`),并返回一个包含 `canAdd` 和 `error` 字段的对象数组。
+ - `canAdd` 表示相应索引处的参数是否可以用于创建新笔记。
+ - `error` 包含无法添加笔记的原因说明。
+
+ 示例请求:
+ ```json
+ {
+ "action": "canAddNotesWithErrorDetail",
+ "version": 6,
+ "params": {
+ "notes": [
+ {
+ "deckName": "Default",
+ "modelName": "Basic",
+ "fields": {
+ "Front": "front content",
+ "Back": "back content"
+ },
+ "tags": [
+ "yomichan"
+ ]
+ },
+ {
+ "deckName": "Default",
+ "modelName": "Basic",
+ "fields": {
+ "Front": "front content 2",
+ "Back": "back content 2"
+ },
+ "tags": [
+ "yomichan"
+ ]
+ }
+ ]
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": [
+ {
+ "canAdd": false,
+ "error": "cannot create note because it is a duplicate"
+ },
+ {
+ "canAdd": true
+ }
+ ],
+ "error": null
+ }
+ ```
+
#### `updateNoteFields`
-* Modify the fields of an existing note. You can also include audio, video, or picture files which will be added to the note with an
- optional `audio`, `video`, or `picture` property. Please see the documentation for `addNote` for an explanation of objects in the `audio`, `video`, or `picture` array.
-
- > **Warning**:
- > You must not be viewing the note that you are updating on your Anki browser, otherwise
- > the fields will not update. See [this issue](https://github.com/FooSoft/anki-connect/issues/82)
- > for further details.
-
-
- Sample request:
-
- ```json
- {
- "action": "updateNoteFields",
- "version": 6,
- "params": {
- "note": {
- "id": 1514547547030,
- "fields": {
- "Front": "new front content",
- "Back": "new back content"
- },
- "audio": [{
- "url": "https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kanji=猫&kana=ねこ",
- "filename": "yomichan_ねこ_猫.mp3",
- "skipHash": "7e2c2f954ef6051373ba916f000168dc",
- "fields": [
- "Front"
- ]
- }]
- }
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 修改现有笔记的字段。您还可以包括音频、视频或图片文件,这些文件将使用可选的 `audio`、`video` 或 `picture` 属性添加到笔记中。请参阅 `addNote` 的文档以了解 `audio`、`video` 或 `picture` 数组中的对象的解释。
+ > **警告**:
+ > 您不能在 Anki 浏览器中查看正在更新的笔记,否则字段不会更新。详情请参见 [此问题](https://github.com/FooSoft/anki-connect/issues/82)。
+
+ 示例请求:
+ ```json
+ {
+ "action": "updateNoteFields",
+ "version": 6,
+ "params": {
+ "note": {
+ "id": 1514547547030,
+ "fields": {
+ "Front": "new front content",
+ "Back": "new back content"
+ },
+ "audio": [{
+ "url": "https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kanji=猫&kana=ねこ",
+ "filename": "yomichan_ねこ_猫.mp3",
+ "skipHash": "7e2c2f954ef6051373ba916f000168dc",
+ "fields": [
+ "Front"
+ ]
+ }]
+ }
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
#### `updateNote`
-* Modify the fields and/or tags of an existing note.
- In other words, combines `updateNoteFields` and `updateNoteTags`.
- Please see their documentation for an explanation of all properties.
-
- Either `fields` or `tags` property can be omitted without affecting the other.
- Thus valid requests to `updateNoteFields` also work with `updateNote`.
- The note must have the `fields` property in order to update the optional audio, video, or picture objects.
-
- If neither `fields` nor `tags` are provided, the method will fail.
- Fields are updated first and are not rolled back if updating tags fails.
- Tags are not updated if updating fields fails.
-
- > **Warning**
- > You must not be viewing the note that you are updating on your Anki browser, otherwise
- > the fields will not update. See [this issue](https://github.com/FooSoft/anki-connect/issues/82)
- > for further details.
-
-
- Sample request:
-
- ```json
- {
- "action": "updateNote",
- "version": 6,
- "params": {
- "note": {
- "id": 1514547547030,
- "fields": {
- "Front": "new front content",
- "Back": "new back content"
- },
- "tags": ["new", "tags"]
- }
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 修改现有笔记的字段和/或标签。
+ 换句话说,结合了 `updateNoteFields` 和 `updateNoteTags`。
+ 请参阅它们的文档以了解所有属性的解释。
+ 可以省略 `fields` 或 `tags` 属性而不影响另一个。
+ 因此,对 `updateNoteFields` 的有效请求也适用于 `updateNote`。
+ 如果既不提供 `fields` 也不提供 `tags`,该方法将失败。
+ 首先更新字段,如果更新标签失败,字段不会回滚。
+ 如果更新字段失败,则不会更新标签。
+ > **警告**
+ > 您不能在 Anki 浏览器中查看正在更新的笔记,否则字段不会更新。详情请参见 [此问题](https://github.com/FooSoft/anki-connect/issues/82)。
+
+ 示例请求:
+ ```json
+ {
+ "action": "updateNote",
+ "version": 6,
+ "params": {
+ "note": {
+ "id": 1514547547030,
+ "fields": {
+ "Front": "new front content",
+ "Back": "new back content"
+ },
+ "tags": ["new", "tags"]
+ }
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
#### `updateNoteModel`
-* Update the model, fields, and tags of an existing note.
- This allows you to change the note's model, update its fields with new content, and set new tags.
-
+- 更新现有笔记的模型、字段和标签。
+ 这允许您更改笔记的模型,使用新内容更新其字段,并设置新的标签。
- Sample request:
-
+ 示例请求:
```json
{
"action": "updateNoteModel",
@@ -3903,680 +3845,639 @@ Documentation for currently supported actions is split up by category and is ref
"tags": ["new", "updated", "tags"]
}
}
- }
```
-
-
- Sample result:
-
+ 示例结果:
```json
{
"result": null,
"error": null
}
```
-
#### `updateNoteTags`
-* Set a note's tags by note ID. Old tags will be removed.
-
-
- Sample request:
-
- ```json
- {
- "action": "updateNoteTags",
- "version": 6,
- "params": {
- "note": 1483959289817,
- "tags": ["european-languages"]
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 通过笔记 ID 设置笔记的标签。旧标签将被移除。
+
+ 示例请求:
+ ```json
+ {
+ "action": "updateNoteTags",
+ "version": 6,
+ "params": {
+ "note": 1483959289817,
+ "tags": ["european-languages"]
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
#### `getNoteTags`
-* Get a note's tags by note ID.
-
-
- Sample request:
-
- ```json
- {
- "action": "getNoteTags",
- "version": 6,
- "params": {
- "note": 1483959289817
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": ["european-languages"],
- "error": null
- }
- ```
-
+- 通过笔记 ID 获取笔记的标签。
+
+ 示例请求:
+ ```json
+ {
+ "action": "getNoteTags",
+ "version": 6,
+ "params": {
+ "note": 1483959289817
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": ["european-languages"],
+ "error": null
+ }
+ ```
+
#### `addTags`
-* Adds tags to notes by note ID.
-
-
- Sample request:
-
- ```json
- {
- "action": "addTags",
- "version": 6,
- "params": {
- "notes": [1483959289817, 1483959291695],
- "tags": "european-languages"
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 通过笔记 ID 向笔记添加标签。
+
+ 示例请求:
+ ```json
+ {
+ "action": "addTags",
+ "version": 6,
+ "params": {
+ "notes": [1483959289817, 1483959291695],
+ "tags": "european-languages"
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
#### `removeTags`
-* Remove tags from notes by note ID.
-
-
- Sample request:
-
- ```json
- {
- "action": "removeTags",
- "version": 6,
- "params": {
- "notes": [1483959289817, 1483959291695],
- "tags": "european-languages"
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 通过笔记 ID 从笔记中移除标签。
+
+ 示例请求:
+ ```json
+ {
+ "action": "removeTags",
+ "version": 6,
+ "params": {
+ "notes": [1483959289817, 1483959291695],
+ "tags": "european-languages"
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
#### `getTags`
-* Gets the complete list of tags for the current user.
-
-
- Sample request:
-
- ```json
- {
- "action": "getTags",
- "version": 6
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": ["european-languages", "idioms"],
- "error": null
- }
- ```
-
+- 获取当前用户的完整标签列表。
+
+ 示例请求:
+ ```json
+ {
+ "action": "getTags",
+ "version": 6
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": ["european-languages", "idioms"],
+ "error": null
+ }
+ ```
+
#### `clearUnusedTags`
-* Clears all the unused tags in the notes for the current user.
-
-
- Sample request:
-
- ```json
- {
- "action": "clearUnusedTags",
- "version": 6
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 清除当前用户笔记中所有未使用的标签。
+
+ 示例请求:
+ ```json
+ {
+ "action": "clearUnusedTags",
+ "version": 6
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
#### `replaceTags`
-* Replace tags in notes by note ID.
-
-
- Sample request:
-
- ```json
- {
- "action": "replaceTags",
- "version": 6,
- "params": {
- "notes": [1483959289817, 1483959291695],
- "tag_to_replace": "european-languages",
- "replace_with_tag": "french-languages"
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 替换笔记中的标签。
+
+ 示例请求:
+ ```json
+ {
+ "action": "replaceTags",
+ "version": 6,
+ "params": {
+ "notes": [1483959289817, 1483959291695],
+ "tag_to_replace": "european-languages",
+ "replace_with_tag": "french-languages"
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
#### `replaceTagsInAllNotes`
-* Replace tags in all the notes for the current user.
-
-
- Sample request:
-
- ```json
- {
- "action": "replaceTagsInAllNotes",
- "version": 6,
- "params": {
- "tag_to_replace": "european-languages",
- "replace_with_tag": "french-languages"
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+- 替换当前用户所有笔记中的标签。
+
+ 示例请求:
+ ```json
+ {
+ "action": "replaceTagsInAllNotes",
+ "version": 6,
+ "params": {
+ "tag_to_replace": "european-languages",
+ "replace_with_tag": "french-languages"
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
#### `findNotes`
-* Returns an array of note IDs for a given query. Query syntax is [documented here](https://docs.ankiweb.net/searching.html).
-
-
- Sample request:
-
- ```json
- {
- "action": "findNotes",
- "version": 6,
- "params": {
- "query": "deck:current"
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": [1483959289817, 1483959291695],
- "error": null
- }
- ```
-
+- 返回给定查询的笔记 ID 数组。查询语法记录在 [此处](https://docs.ankiweb.net/searching.html)。
+
+ 示例请求:
+ ```json
+ {
+ "action": "findNotes",
+ "version": 6,
+ "params": {
+ "query": "deck:current"
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": [1483959289817, 1483959291695],
+ "error": null
+ }
+ ```
+
#### `notesInfo`
-* Returns a list of objects containing for each note ID the note fields, tags, note type, modification time,the cards belonging to
- the note and the profile where the note was created.
+- 返回一个对象列表,包含每个笔记 ID 的笔记字段、标签、笔记类型、修改时间、属于该笔记的卡片以及创建该笔记的配置文件。
+
+ 示例请求(笔记ID):
+ ```json
+ {
+ "action": "notesInfo",
+ "version": 6,
+ "params": {
+ "notes": [1502298033753]
+ }
+ ```
+
+
+ 示例请求(查询):
+ ```json
+ {
+ "action": "notesInfo",
+ "version": 6,
+ "params": {
+ "query": "deck:current"
+ }
+ ```
+
+
+ 示例结果:
+ ```json
+ {
+ "result": [
+ {
+ "noteId":1502298033753,
+ "profile": "User_1",
+ "modelName": "Basic",
+ "tags":["tag","another_tag"],
+ "fields": {
+ "Front": {"value": "front content", "order": 0},
+ "Back": {"value": "back content", "order": 1}
+ },
+ "mod": 1718377864,
+ "cards": [1498938915662]
+ }
+ ],
+ "error": null
+ }
+ ```
+
-
- Sample request (note ids):
+ #### `notesModTime`
- ```json
- {
- "action": "notesInfo",
- "version": 6,
- "params": {
- "notes": [1502298033753]
- }
+- 返回一个对象列表,每个对象包含对应笔记 ID 的修改时间。
+
+
+ 示例请求:
+
+ ```json
+ {
+ "action": "notesModTime",
+ "version": 6,
+ "params": {
+ "notes": [1502298033753]
}
- ```
-
+ }
+ ```
-
- Sample request (query):
+
- ```json
- {
- "action": "notesInfo",
- "version": 6,
- "params": {
- "query": "deck:current"
- }
- }
- ```
-
+
+ 示例结果:
-
- Sample result:
-
- ```json
- {
- "result": [
- {
- "noteId":1502298033753,
- "profile": "User_1",
- "modelName": "Basic",
- "tags":["tag","another_tag"],
- "fields": {
- "Front": {"value": "front content", "order": 0},
- "Back": {"value": "back content", "order": 1}
- },
- "mod": 1718377864,
- "cards": [1498938915662]
- }
- ],
- "error": null
- }
- ```
-
-s
-#### `notesModTime`
-
-* Returns a list of objects containings for each note ID the modification time.
-
-
- Sample request:
-
- ```json
- {
- "action": "notesModTime",
- "version": 6,
- "params": {
- "notes": [1502298033753]
- }
- }
- ```
-
-
-
- Sample result:
-
- ```json
- {
- "result": [
- {
- "noteId": 1498938915662,
- "mod": 1629454092
- }
- ],
- "error": null
- }
- ```
-
+ ```json
+ {
+ "result": [
+ {
+ "noteId": 1498938915662,
+ "mod": 1629454092
+ }
+ ],
+ "error": null
+ }
+ ```
+
#### `deleteNotes`
-* Deletes notes with the given ids. If a note has several cards associated with it, all associated cards will be deleted.
+- 删除指定 ID 的笔记。如果某个笔记关联了多张卡片,则所有关联的卡片也会被删除。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "deleteNotes",
- "version": 6,
- "params": {
- "notes": [1502298033753]
- }
+ ```json
+ {
+ "action": "deleteNotes",
+ "version": 6,
+ "params": {
+ "notes": [1502298033753]
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
#### `removeEmptyNotes`
-* Removes all the empty notes for the current user.
+- 移除当前用户所有空的笔记。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "removeEmptyNotes",
- "version": 6
- }
- ```
-
+ ```json
+ {
+ "action": "removeEmptyNotes",
+ "version": 6
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+
---
-### Statistic Actions
+### 统计操作
#### `getNumCardsReviewedToday`
-* Gets the count of cards that have been reviewed in the current day (with day start time as configured by user in anki)
+- 获取当天已复习卡片的数量(以 Anki 用户配置的起始时间为准)。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "getNumCardsReviewedToday",
- "version": 6
- }
- ```
-
+ ```json
+ {
+ "action": "getNumCardsReviewedToday",
+ "version": 6
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": 0,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": 0,
+ "error": null
+ }
+ ```
+
+
#### `getNumCardsReviewedByDay`
-* Gets the number of cards reviewed as a list of pairs of `(dateString, number)`
+- 获取每天复习卡片的数量,返回一个包含 `(日期字符串, 数量)` 对的列表。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "getNumCardsReviewedByDay",
- "version": 6
- }
- ```
-
+ ```json
+ {
+ "action": "getNumCardsReviewedByDay",
+ "version": 6
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": [
- ["2021-02-28", 124],
- ["2021-02-27", 261]
- ],
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": [
+ ["2021-02-28", 124],
+ ["2021-02-27", 261]
+ ],
+ "error": null
+ }
+ ```
+
+
#### `getCollectionStatsHTML`
-* Gets the collection statistics report
+- 获取整套卡组的统计报告(HTML 格式)。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "getCollectionStatsHTML",
- "version": 6,
- "params": {
- "wholeCollection": true
- }
+ ```json
+ {
+ "action": "getCollectionStatsHTML",
+ "version": 6,
+ "params": {
+ "wholeCollection": true
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": " lots of HTML here ",
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": " lots of HTML here ",
+ "error": null
+ }
+ ```
+
+
#### `cardReviews`
-* Requests all card reviews for a specified deck after a certain time.
- `startID` is the latest unix time not included in the result.
- Returns a list of 9-tuples `(reviewTime, cardID, usn, buttonPressed, newInterval, previousInterval, newFactor, reviewDuration, reviewType)`
+- 请求指定牌组在某一时间之后的所有卡片复习记录。
+ `startID` 是不会包含在结果中的最新 unix 时间。
+ 返回值为一个包含 9 个元素的元组列表,格式为 `(复习时间, 卡片ID, usn, 按下的按钮, 新间隔, 上次间隔, 新因子, 复习时长, 复习类型)`
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "cardReviews",
- "version": 6,
- "params": {
- "deck": "default",
- "startID": 1594194095740
- }
+ ```json
+ {
+ "action": "cardReviews",
+ "version": 6,
+ "params": {
+ "deck": "default",
+ "startID": 1594194095740
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": [
- [1594194095746, 1485369733217, -1, 3, 4, -60, 2500, 6157, 0],
- [1594201393292, 1485369902086, -1, 1, -60, -60, 0, 4846, 0]
- ],
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": [
+ [1594194095746, 1485369733217, -1, 3, 4, -60, 2500, 6157, 0],
+ [1594201393292, 1485369902086, -1, 1, -60, -60, 0, 4846, 0]
+ ],
+ "error": null
+ }
+ ```
+
+
#### `getReviewsOfCards`
-* Requests all card reviews for each card ID.
- Returns a dictionary mapping each card ID to a list of dictionaries of the format:
- ```
- {
- "id": reviewTime,
- "usn": usn,
- "ease": buttonPressed,
- "ivl": newInterval,
- "lastIvl": previousInterval,
- "factor": newFactor,
- "time": reviewDuration,
- "type": reviewType,
+- 请求每个卡片 ID 的所有复习记录。
+ 返回一个字典,将每个卡片 ID 映射到一个由下述格式字典组成的列表:
+
+ ```
+ {
+ "id": reviewTime,
+ "usn": usn,
+ "ease": buttonPressed,
+ "ivl": newInterval,
+ "lastIvl": previousInterval,
+ "factor": newFactor,
+ "time": reviewDuration,
+ "type": reviewType,
+ }
+ ```
+
+ 之所以使用这些键名而不是更具描述性的名称,是因为这些是 Anki 数据库中使用的实际键名。
+
+
+ 示例请求:
+
+ ```json
+ {
+ "action": "getReviewsOfCards",
+ "version": 6,
+ "params": {
+ "cards": ["1653613948202"]
}
- ```
- The reason why these key values are used instead of the more descriptive counterparts
- is because these are the exact key values used in Anki's database.
+ }
+ ```
-
- Sample request:
+
- ```json
- {
- "action": "getReviewsOfCards",
- "version": 6,
- "params": {
- "cards": [
- "1653613948202"
- ]
- }
- }
- ```
-
+
+ 示例结果:
-
- Sample result:
-
- ```json
- {
- "result": {
- "1653613948202": [
- {
- "id": 1653772912146,
- "usn": 1750,
- "ease": 1,
- "ivl": -20,
- "lastIvl": -20,
- "factor": 0,
- "time": 38192,
- "type": 0
- },
- {
- "id": 1653772965429,
- "usn": 1750,
- "ease": 3,
- "ivl": -45,
- "lastIvl": -20,
- "factor": 0,
- "time": 15337,
- "type": 0
- }
- ]
+ ```json
+ {
+ "result": {
+ "1653613948202": [
+ {
+ "id": 1653772912146,
+ "usn": 1750,
+ "ease": 1,
+ "ivl": -20,
+ "lastIvl": -20,
+ "factor": 0,
+ "time": 38192,
+ "type": 0
},
- "error": null
- }
- ```
-
+ {
+ "id": 1653772965429,
+ "usn": 1750,
+ "ease": 3,
+ "ivl": -45,
+ "lastIvl": -20,
+ "factor": 0,
+ "time": 15337,
+ "type": 0
+ }
+ ]
+ },
+ "error": null
+ }
+ ```
+
+
#### `getLatestReviewID`
-* Returns the unix time of the latest review for the given deck. 0 if no review has ever been made for the deck.
+- 返回指定牌组最近一次复习的 unix 时间。如果该牌组从未被复习过,则返回 0。
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "getLatestReviewID",
- "version": 6,
- "params": {
- "deck": "default"
- }
+ ```json
+ {
+ "action": "getLatestReviewID",
+ "version": 6,
+ "params": {
+ "deck": "default"
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": 1594194095746,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": 1594194095746,
+ "error": null
+ }
+ ```
+
+
#### `insertReviews`
-* Inserts the given reviews into the database. Required format: list of 9-tuples `(reviewTime, cardID, usn, buttonPressed, newInterval, previousInterval, newFactor, reviewDuration, reviewType)`
+- 将给定的复习记录插入数据库。所需格式为 9 元素元组列表:`(复习时间, 卡片ID, usn, 按下的按钮, 新间隔, 上次间隔, 新因子, 复习时长, 复习类型)`
-
- Sample request:
+
+ 示例请求:
- ```json
- {
- "action": "insertReviews",
- "version": 6,
- "params": {
- "reviews": [
- [1594194095746, 1485369733217, -1, 3, 4, -60, 2500, 6157, 0],
- [1594201393292, 1485369902086, -1, 1, -60, -60, 0, 4846, 0]
- ]
- }
+ ```json
+ {
+ "action": "insertReviews",
+ "version": 6,
+ "params": {
+ "reviews": [
+ [1594194095746, 1485369733217, -1, 3, 4, -60, 2500, 6157, 0],
+ [1594201393292, 1485369902086, -1, 1, -60, -60, 0, 4846, 0]
+ ]
}
- ```
-
+ }
+ ```
-
- Sample result:
+
- ```json
- {
- "result": null,
- "error": null
- }
- ```
-
+
+ 示例结果:
+
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+