2016-09-07 04:15:55 +00:00
|
|
|
# AnkiConnect #
|
2016-05-30 02:59:21 +00:00
|
|
|
|
2017-04-01 20:21:04 +00:00
|
|
|
The AnkiConnect plugin enables external applications such as [Yomichan](https://foosoft.net/projects/yomichan/) to communicate with
|
|
|
|
[Anki](https://apps.ankiweb.net/) over a network interface. This software makes it possible to execute queries against
|
|
|
|
the user's card deck, automatically create new vocabulary and Kanji flash cards, and more. AnkiConnect is compatible
|
|
|
|
with the latest stable (2.0.x) and alpha (2.1.x) releases of Anki and works on Linux, Windows, and Mac OS X.
|
2016-05-30 02:59:21 +00:00
|
|
|
|
2017-10-02 16:31:31 +00:00
|
|
|
## Table of Contents ##
|
|
|
|
|
|
|
|
* [Installation](https://foosoft.net/projects/anki-connect/#installation)
|
|
|
|
* [Notes for Windows Users](https://foosoft.net/projects/anki-connect/#notes-for-windows-users)
|
|
|
|
* [Notes for Mac OS X Users](https://foosoft.net/projects/anki-connect/#notes-for-mac-os-x-users)
|
|
|
|
* [Application Interface for Developers](https://foosoft.net/projects/anki-connect/#application-interface-for-developers)
|
|
|
|
* [Sample Invocation](https://foosoft.net/projects/anki-connect/#sample-invocation)
|
|
|
|
* [Supported Actions](https://foosoft.net/projects/anki-connect/#supported-actions)
|
|
|
|
* [Miscellaneous](https://foosoft.net/projects/anki-connect/#miscellaneous)
|
|
|
|
* [Decks](https://foosoft.net/projects/anki-connect/#decks)
|
|
|
|
* [Models](https://foosoft.net/projects/anki-connect/#models)
|
2018-01-26 23:18:44 +00:00
|
|
|
* [Notes](https://foosoft.net/projects/anki-connect/#notes)
|
|
|
|
* [Cards](https://foosoft.net/projects/anki-connect/#cards)
|
|
|
|
* [Media](https://foosoft.net/projects/anki-connect/#media)
|
2017-10-02 16:31:31 +00:00
|
|
|
* [Graphical](https://foosoft.net/projects/anki-connect/#graphical)
|
|
|
|
|
2017-04-01 20:21:04 +00:00
|
|
|
## Installation ##
|
2016-05-30 02:59:21 +00:00
|
|
|
|
2017-03-15 04:10:45 +00:00
|
|
|
The installation process is similar to that of other Anki plugins and can be accomplished in three steps:
|
|
|
|
|
2019-04-28 23:02:02 +00:00
|
|
|
1. Open the `Install Add-on` dialog by selecting `Tools` | `Add-ons` | `Browse & Install` in Anki.
|
|
|
|
2. Input [2055492159](https://ankiweb.net/shared/info/2055492159) into the text box labeled `Code` and press the `OK` button to proceed.
|
2017-03-15 04:10:45 +00:00
|
|
|
3. Restart Anki when prompted to do so in order to complete the installation of AnkiConnect.
|
|
|
|
|
2017-04-01 20:21:04 +00:00
|
|
|
Anki must be kept running in the background in order for other applications to be able to use AnkiConnect. You can
|
|
|
|
verify that AnkiConnect is running at any time by accessing [localhost:8765](http://localhost:8765) in your browser. If
|
2019-04-28 23:02:02 +00:00
|
|
|
the server is running, you should see the message `AnkiConnect v.6` displayed in your browser window.
|
2016-07-03 02:46:01 +00:00
|
|
|
|
2017-04-22 06:36:47 +00:00
|
|
|
### Notes for Windows Users ###
|
2017-01-28 20:20:38 +00:00
|
|
|
|
2017-04-01 20:21:04 +00:00
|
|
|
Windows users may see a firewall nag dialog box appear on Anki startup. This occurs because AnkiConnect hosts a local
|
|
|
|
server in order to enable other applications to connect to it. The host application, Anki, must be unblocked for this
|
|
|
|
plugin to function correctly.
|
2017-01-28 20:20:38 +00:00
|
|
|
|
2017-04-22 06:36:47 +00:00
|
|
|
### Notes for Mac OS X Users ###
|
2017-01-28 20:20:38 +00:00
|
|
|
|
2017-02-12 00:41:02 +00:00
|
|
|
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
|
2017-02-12 03:26:22 +00:00
|
|
|
placed in a suspended state. As this behavior causes AnkiConnect to stop working while you have another window in the
|
2017-02-12 00:41:02 +00:00
|
|
|
foreground, App Nap should be disabled for Anki:
|
|
|
|
|
|
|
|
1. Start the Terminal application.
|
2018-09-16 03:21:03 +00:00
|
|
|
2. Execute the following commands in the terminal window:
|
2017-02-12 00:41:02 +00:00
|
|
|
```
|
2019-02-02 03:56:51 +00:00
|
|
|
defaults write net.ankiweb.dtop NSAppSleepDisabled -bool true
|
2017-02-12 00:41:02 +00:00
|
|
|
defaults write net.ichi2.anki NSAppSleepDisabled -bool true
|
2018-09-16 03:21:03 +00:00
|
|
|
defaults write org.qt-project.Qt.QtWebEngineCore NSAppSleepDisabled -bool true
|
2017-02-12 00:41:02 +00:00
|
|
|
```
|
|
|
|
3. Restart Anki.
|
|
|
|
|
2017-04-22 06:36:47 +00:00
|
|
|
## Application Interface for Developers ##
|
2017-02-01 17:23:09 +00:00
|
|
|
|
2017-02-03 04:14:24 +00:00
|
|
|
AnkiConnect exposes Anki features to external applications via an easy to use
|
|
|
|
[RESTful](https://en.wikipedia.org/wiki/Representational_state_transfer) API. After it is installed, this plugin will
|
|
|
|
initialize a minimal HTTP sever running on port 8765 every time Anki executes. Other applications (including browser
|
|
|
|
extensions) can then communicate with it via HTTP POST requests.
|
2017-02-01 17:23:09 +00:00
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
By default, AnkiConnect 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 set the
|
|
|
|
environment variable `ANKICONNECT_BIND_ADDRESS` to change the binding address. For example, you can set it to `0.0.0.0`
|
|
|
|
in order to bind it to all network interfaces on your host.
|
2017-08-28 20:15:42 +00:00
|
|
|
|
2017-02-03 04:14:24 +00:00
|
|
|
### Sample Invocation ###
|
2017-02-01 17:23:09 +00:00
|
|
|
|
2019-02-03 16:48:57 +00:00
|
|
|
Every request consists of a JSON-encoded object containing an `action`, a `version`, and a set of contextual `params`.
|
|
|
|
AnkiConnect 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 AnkiConnect, 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 AnkiConnect, but a couple of simple examples are
|
|
|
|
included below as reference.
|
|
|
|
|
|
|
|
#### Curl ####
|
|
|
|
|
|
|
|
```bash
|
|
|
|
curl localhost:8765 -X POST -d "{\"action\": \"deckNames\", \"version\": 6}"
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Python ####
|
|
|
|
|
|
|
|
```python
|
|
|
|
import json
|
|
|
|
import urllib2
|
|
|
|
|
|
|
|
def request(action, **params):
|
|
|
|
return {'action': action, 'params': params, 'version': 6}
|
|
|
|
|
|
|
|
def invoke(action, **params):
|
|
|
|
requestJson = json.dumps(request(action, **params))
|
|
|
|
response = json.load(urllib2.urlopen(urllib2.Request('http://localhost: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 ####
|
2017-02-01 17:23:09 +00:00
|
|
|
|
2017-09-30 00:03:48 +00:00
|
|
|
```javascript
|
2019-02-03 16:48:57 +00:00
|
|
|
function invoke(action, version, params={}) {
|
2017-02-03 04:14:24 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
const xhr = new XMLHttpRequest();
|
2019-02-03 16:48:57 +00:00
|
|
|
xhr.addEventListener('error', () => reject('failed to issue request'));
|
2017-09-10 05:28:09 +00:00
|
|
|
xhr.addEventListener('load', () => {
|
|
|
|
try {
|
|
|
|
const response = JSON.parse(xhr.responseText);
|
2019-02-03 16:48:57 +00:00
|
|
|
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';
|
|
|
|
}
|
2017-09-10 05:28:09 +00:00
|
|
|
if (response.error) {
|
|
|
|
throw response.error;
|
|
|
|
}
|
2019-02-03 16:48:57 +00:00
|
|
|
resolve(response.result);
|
2017-09-10 05:28:09 +00:00
|
|
|
} catch (e) {
|
|
|
|
reject(e);
|
2017-02-03 04:14:24 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
xhr.open('POST', 'http://127.0.0.1:8765');
|
2017-08-31 04:26:28 +00:00
|
|
|
xhr.send(JSON.stringify({action, version, params}));
|
2017-02-03 04:14:24 +00:00
|
|
|
});
|
|
|
|
}
|
2017-02-01 17:23:09 +00:00
|
|
|
|
2019-02-03 16:48:57 +00:00
|
|
|
await invoke('createDeck', {deck: 'test1'});
|
|
|
|
const result = await invoke('deckNames', 6);
|
|
|
|
console.log(`got list of decks: ${result}`);
|
2017-05-06 12:39:38 +00:00
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
### Supported Actions ###
|
2017-08-22 08:43:37 +00:00
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
Below is a comprehensive list of currently supported actions. 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.
|
2017-08-22 08:43:37 +00:00
|
|
|
|
2018-05-25 12:31:32 +00:00
|
|
|
This page currently documents **version 6** of the API. Make sure to include this version number in your requests to
|
2017-08-31 04:43:15 +00:00
|
|
|
guarantee that your application continues to function properly in the future.
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
#### Miscellaneous ####
|
2017-08-22 08:43:37 +00:00
|
|
|
|
2017-04-22 06:36:47 +00:00
|
|
|
* **version**
|
2017-02-01 17:23:09 +00:00
|
|
|
|
2018-05-25 12:31:32 +00:00
|
|
|
Gets the version of the API exposed by this plugin. Currently versions `1` through `6` are defined.
|
2017-02-03 04:14:24 +00:00
|
|
|
|
|
|
|
This should be the first call you make to make sure that your application and AnkiConnect are able to communicate
|
2017-08-14 20:02:56 +00:00
|
|
|
properly with each other. New versions of AnkiConnect are backwards compatible; as long as you are using actions
|
2017-02-03 04:14:24 +00:00
|
|
|
which are available in the reported AnkiConnect version or earlier, everything should work fine.
|
|
|
|
|
2017-04-22 06:36:47 +00:00
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-02-03 04:14:24 +00:00
|
|
|
{
|
2017-10-02 01:17:39 +00:00
|
|
|
"action": "version",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6
|
2017-02-01 17:23:09 +00:00
|
|
|
}
|
2017-02-03 04:14:24 +00:00
|
|
|
```
|
2017-02-01 17:23:09 +00:00
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
2018-05-25 12:31:32 +00:00
|
|
|
"result": 6,
|
2017-10-02 01:17:39 +00:00
|
|
|
"error": null
|
|
|
|
}
|
2017-02-03 04:14:24 +00:00
|
|
|
```
|
2017-08-17 12:25:06 +00:00
|
|
|
|
2017-08-22 08:43:37 +00:00
|
|
|
* **upgrade**
|
|
|
|
|
|
|
|
Displays a confirmation dialog box in Anki asking the user if they wish to upgrade AnkiConnect to the latest version
|
|
|
|
from the project's [master branch](https://raw.githubusercontent.com/FooSoft/anki-connect/master/AnkiConnect.py) on
|
|
|
|
GitHub. Returns a boolean value indicating if the plugin was upgraded or not.
|
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-22 08:43:37 +00:00
|
|
|
{
|
2017-10-02 01:17:39 +00:00
|
|
|
"action": "upgrade",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6
|
2017-08-22 08:43:37 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": true,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-22 08:43:37 +00:00
|
|
|
```
|
|
|
|
|
2018-02-21 17:01:37 +00:00
|
|
|
* **sync**
|
|
|
|
|
|
|
|
Synchronizes the local anki collections with ankiweb.
|
2018-02-22 03:14:50 +00:00
|
|
|
|
2018-02-21 17:01:37 +00:00
|
|
|
*Sample request*:
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"action": "sync",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6
|
2018-02-21 17:01:37 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
*Sample result*:
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"result": null,
|
|
|
|
"error": null
|
|
|
|
}
|
2018-02-22 03:14:50 +00:00
|
|
|
```
|
2018-02-21 17:01:37 +00:00
|
|
|
|
2019-01-06 03:51:38 +00:00
|
|
|
* **loadProfile**
|
|
|
|
|
|
|
|
Selects the profile specified in request.
|
|
|
|
|
|
|
|
*Sample request*:
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"action": "loadProfile",
|
|
|
|
"params": {
|
|
|
|
"name": "user1"
|
|
|
|
},
|
|
|
|
"version": 6
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
*Sample result*:
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"result": true,
|
|
|
|
"error": null
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-17 12:25:06 +00:00
|
|
|
* **multi**
|
|
|
|
|
|
|
|
Performs multiple actions in one request, returning an array with the response of each action (in the given order).
|
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-17 12:25:06 +00:00
|
|
|
{
|
|
|
|
"action": "multi",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-08-17 12:25:06 +00:00
|
|
|
"params": {
|
|
|
|
"actions": [
|
|
|
|
{"action": "deckNames"},
|
|
|
|
{
|
|
|
|
"action": "browse",
|
|
|
|
"params": {"query": "deck:current"}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": [
|
2018-05-20 04:23:24 +00:00
|
|
|
{"result": "Default", "error": null},
|
|
|
|
{"result": [1494723142483, 1494703460437, 1494703479525], "error": null}
|
2017-10-02 01:17:39 +00:00
|
|
|
],
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-17 12:25:06 +00:00
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
#### Decks ####
|
2017-08-22 08:12:49 +00:00
|
|
|
|
2017-08-22 08:43:37 +00:00
|
|
|
* **deckNames**
|
2017-08-22 08:12:49 +00:00
|
|
|
|
2017-08-22 08:43:37 +00:00
|
|
|
Gets the complete list of deck names for the current user.
|
2017-08-22 08:12:49 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-22 08:12:49 +00:00
|
|
|
{
|
2017-10-02 01:17:39 +00:00
|
|
|
"action": "deckNames",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6
|
2017-08-22 08:12:49 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": ["Default"],
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-22 08:12:49 +00:00
|
|
|
```
|
|
|
|
|
2017-08-22 08:43:37 +00:00
|
|
|
* **deckNamesAndIds**
|
2017-08-22 08:12:49 +00:00
|
|
|
|
2017-08-22 08:43:37 +00:00
|
|
|
Gets the complete list of deck names and their respective IDs for the current user.
|
2017-08-22 08:12:49 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-22 08:12:49 +00:00
|
|
|
{
|
2017-10-02 01:17:39 +00:00
|
|
|
"action": "deckNamesAndIds",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6
|
2017-08-22 08:12:49 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-02-03 04:14:24 +00:00
|
|
|
{
|
2017-10-02 01:17:39 +00:00
|
|
|
"result": {"Default": 1},
|
|
|
|
"error": null
|
2017-02-03 04:14:24 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-22 08:43:37 +00:00
|
|
|
* **getDecks**
|
2017-08-16 21:26:53 +00:00
|
|
|
|
2017-08-22 08:43:37 +00:00
|
|
|
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.
|
2017-08-16 21:26:53 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-16 21:26:53 +00:00
|
|
|
{
|
2017-08-22 08:43:37 +00:00
|
|
|
"action": "getDecks",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-08-22 08:43:37 +00:00
|
|
|
"params": {
|
|
|
|
"cards": [1502298036657, 1502298033753, 1502032366472]
|
|
|
|
}
|
2017-08-16 21:26:53 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-16 21:26:53 +00:00
|
|
|
{
|
2017-10-02 01:17:39 +00:00
|
|
|
"result": {
|
|
|
|
"Default": [1502032366472],
|
|
|
|
"Japanese::JLPT N3": [1502298036657, 1502298033753]
|
|
|
|
},
|
|
|
|
"error": null
|
2017-08-16 21:26:53 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2018-02-22 18:34:12 +00:00
|
|
|
* **createDeck**
|
|
|
|
|
|
|
|
Create a new empty deck. Will not overwrite a deck that exists with the same name.
|
|
|
|
|
|
|
|
*Sample request*:
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"action": "createDeck",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2018-02-22 18:34:12 +00:00
|
|
|
"params": {
|
|
|
|
"deck": "Japanese::Tokyo"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
*Sample result*:
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"result": 1519323742721,
|
|
|
|
"error": null
|
|
|
|
}
|
|
|
|
```
|
2017-08-22 08:43:37 +00:00
|
|
|
* **changeDeck**
|
2017-02-03 04:14:24 +00:00
|
|
|
|
2017-08-22 08:43:37 +00:00
|
|
|
Moves cards with the given IDs to a different deck, creating the deck if it doesn't exist yet.
|
2017-02-03 04:14:24 +00:00
|
|
|
|
2017-04-22 06:36:47 +00:00
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-02-03 04:14:24 +00:00
|
|
|
{
|
2017-08-22 08:43:37 +00:00
|
|
|
"action": "changeDeck",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-08-22 08:43:37 +00:00
|
|
|
"params": {
|
|
|
|
"cards": [1502098034045, 1502098034048, 1502298033753],
|
|
|
|
"deck": "Japanese::JLPT N3"
|
|
|
|
}
|
2017-02-03 04:14:24 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": null,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-02-03 04:14:24 +00:00
|
|
|
```
|
|
|
|
|
2017-08-22 08:43:37 +00:00
|
|
|
* **deleteDecks**
|
2017-02-03 04:14:24 +00:00
|
|
|
|
2017-08-22 08:43:37 +00:00
|
|
|
Deletes decks with the given names. If `cardsToo` is `true` (defaults to `false` if unspecified), the cards within
|
|
|
|
the deleted decks will also be deleted; otherwise they will be moved to the default deck.
|
2017-02-03 04:14:24 +00:00
|
|
|
|
2017-04-22 06:36:47 +00:00
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-02-03 04:14:24 +00:00
|
|
|
{
|
2017-08-22 08:43:37 +00:00
|
|
|
"action": "deleteDecks",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-07-02 00:12:11 +00:00
|
|
|
"params": {
|
2017-08-22 08:43:37 +00:00
|
|
|
"decks": ["Japanese::JLPT N5", "Easy Spanish"],
|
|
|
|
"cardsToo": true
|
2017-02-01 17:23:09 +00:00
|
|
|
}
|
|
|
|
}
|
2017-02-03 04:14:24 +00:00
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": null,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-02-03 04:14:24 +00:00
|
|
|
```
|
|
|
|
|
2017-08-18 19:57:19 +00:00
|
|
|
* **getDeckConfig**
|
2017-07-27 17:54:02 +00:00
|
|
|
|
2017-10-02 01:17:39 +00:00
|
|
|
Gets the configuration group object for the given deck.
|
2017-07-27 17:54:02 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-07-27 17:54:02 +00:00
|
|
|
{
|
2017-08-18 19:57:19 +00:00
|
|
|
"action": "getDeckConfig",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-07-27 17:54:02 +00:00
|
|
|
"params": {
|
2017-08-17 12:25:06 +00:00
|
|
|
"deck": "Default"
|
2017-07-27 17:54:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-17 12:25:06 +00:00
|
|
|
{
|
2017-10-02 01:17:39 +00:00
|
|
|
"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
|
2017-08-17 12:25:06 +00:00
|
|
|
},
|
2017-10-02 01:17:39 +00:00
|
|
|
"error": null
|
2017-08-17 12:25:06 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-18 19:57:19 +00:00
|
|
|
* **saveDeckConfig**
|
2017-08-17 12:25:06 +00:00
|
|
|
|
2017-10-02 01:17:39 +00:00
|
|
|
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).
|
2017-08-17 12:25:06 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-17 12:25:06 +00:00
|
|
|
{
|
2017-08-18 19:57:19 +00:00
|
|
|
"action": "saveDeckConfig",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-08-17 12:25:06 +00:00
|
|
|
"params": {
|
2017-10-02 01:17:39 +00:00
|
|
|
"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
|
|
|
|
}
|
2017-08-17 12:25:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": true,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-17 12:25:06 +00:00
|
|
|
```
|
|
|
|
|
2017-08-18 19:57:19 +00:00
|
|
|
* **setDeckConfigId**
|
2017-08-17 12:25:06 +00:00
|
|
|
|
|
|
|
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*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-17 12:25:06 +00:00
|
|
|
{
|
2017-08-18 19:57:19 +00:00
|
|
|
"action": "setDeckConfigId",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-08-17 12:25:06 +00:00
|
|
|
"params": {
|
|
|
|
"decks": ["Default"],
|
2017-08-18 20:10:51 +00:00
|
|
|
"configId": 1
|
2017-08-17 12:25:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": true,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-17 12:25:06 +00:00
|
|
|
```
|
|
|
|
|
2017-08-18 19:57:19 +00:00
|
|
|
* **cloneDeckConfigId**
|
2017-08-17 12:25:06 +00:00
|
|
|
|
2017-10-02 01:17:39 +00:00
|
|
|
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.
|
2017-08-17 12:25:06 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-17 12:25:06 +00:00
|
|
|
{
|
2017-08-18 19:57:19 +00:00
|
|
|
"action": "cloneDeckConfigId",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-08-17 12:25:06 +00:00
|
|
|
"params": {
|
|
|
|
"name": "Copy of Default",
|
|
|
|
"cloneFrom": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": 1502972374573,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-17 12:25:06 +00:00
|
|
|
```
|
|
|
|
|
2017-08-18 19:57:19 +00:00
|
|
|
* **removeDeckConfigId**
|
2017-08-17 12:25:06 +00:00
|
|
|
|
2017-10-02 01:17:39 +00:00
|
|
|
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.
|
2017-08-17 12:25:06 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-17 12:25:06 +00:00
|
|
|
{
|
2017-08-18 19:57:19 +00:00
|
|
|
"action": "removeDeckConfigId",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-08-17 12:25:06 +00:00
|
|
|
"params": {
|
2017-08-18 20:10:51 +00:00
|
|
|
"configId": 1502972374573
|
2017-08-17 12:25:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": true,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-07-27 17:54:02 +00:00
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
#### Models ####
|
2017-08-22 08:43:37 +00:00
|
|
|
|
|
|
|
* **modelNames**
|
|
|
|
|
|
|
|
Gets the complete list of model names for the current user.
|
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-22 08:43:37 +00:00
|
|
|
{
|
2017-10-02 01:17:39 +00:00
|
|
|
"action": "modelNames",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6
|
2017-08-22 08:43:37 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": ["Basic", "Basic (and reversed card)"],
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-22 08:43:37 +00:00
|
|
|
```
|
|
|
|
|
2017-08-22 08:51:01 +00:00
|
|
|
* **modelNamesAndIds**
|
|
|
|
|
|
|
|
Gets the complete list of model names and their corresponding IDs for the current user.
|
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-22 08:51:01 +00:00
|
|
|
{
|
2017-10-02 01:17:39 +00:00
|
|
|
"action": "modelNamesAndIds",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6
|
2017-08-22 08:51:01 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-22 08:51:01 +00:00
|
|
|
{
|
2017-10-02 01:17:39 +00:00
|
|
|
"result": {
|
|
|
|
"Basic": 1483883011648,
|
|
|
|
"Basic (and reversed card)": 1483883011644,
|
|
|
|
"Basic (optional reversed card)": 1483883011631,
|
|
|
|
"Cloze": 1483883011630
|
|
|
|
},
|
|
|
|
"error": null
|
2017-08-22 08:51:01 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-22 08:43:37 +00:00
|
|
|
* **modelFieldNames**
|
|
|
|
|
|
|
|
Gets the complete list of field names for the provided model name.
|
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-22 08:43:37 +00:00
|
|
|
{
|
|
|
|
"action": "modelFieldNames",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-08-22 08:43:37 +00:00
|
|
|
"params": {
|
|
|
|
"modelName": "Basic"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": ["Front", "Back"],
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-22 08:43:37 +00:00
|
|
|
```
|
|
|
|
|
2017-08-22 08:51:01 +00:00
|
|
|
* **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*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-22 08:51:01 +00:00
|
|
|
{
|
|
|
|
"action": "modelFieldsOnTemplates",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-08-22 08:51:01 +00:00
|
|
|
"params": {
|
|
|
|
"modelName": "Basic (and reversed card)"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-22 08:51:01 +00:00
|
|
|
{
|
2017-10-02 01:17:39 +00:00
|
|
|
"result": {
|
|
|
|
"Card 1": [["Front"], ["Back"]],
|
|
|
|
"Card 2": [["Back"], ["Front"]]
|
|
|
|
},
|
|
|
|
"error": null
|
2017-08-22 08:51:01 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-03-01 17:38:30 +00:00
|
|
|
|
2019-05-05 13:33:48 +00:00
|
|
|
* **createModel**
|
2019-03-01 17:38:30 +00:00
|
|
|
|
2019-03-07 18:19:35 +00:00
|
|
|
Creates a new model to be used in Anki. User must provide the `modelName`, `inOrderFields` and `cardTemplates` to be
|
|
|
|
used in the model.
|
2019-03-01 17:38:30 +00:00
|
|
|
|
|
|
|
*Sample request*
|
|
|
|
```json
|
|
|
|
{
|
2019-05-05 13:33:48 +00:00
|
|
|
"action": "createModel",
|
2019-03-01 17:38:30 +00:00
|
|
|
"version": 6,
|
|
|
|
"params": {
|
|
|
|
"modelName": "newModelName",
|
2019-03-07 19:18:51 +00:00
|
|
|
"inOrderFields": ["Field1", "Field2", "Field3"],
|
2019-03-01 17:38:30 +00:00
|
|
|
"css": "Optional CSS with default to builtin css",
|
|
|
|
"cardTemplates": [
|
|
|
|
{
|
|
|
|
"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":"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
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2018-01-26 23:18:44 +00:00
|
|
|
#### Notes ####
|
2017-08-22 08:43:37 +00:00
|
|
|
|
2017-04-22 06:36:47 +00:00
|
|
|
* **addNote**
|
2017-02-03 04:14:24 +00:00
|
|
|
|
2017-02-05 20:08:52 +00:00
|
|
|
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.
|
2017-02-03 04:14:24 +00:00
|
|
|
|
2017-10-02 01:17:39 +00:00
|
|
|
AnkiConnect can download audio files and embed them in newly created notes. The corresponding `audio` note member is
|
|
|
|
optional and can be omitted. If you choose to include it, the `url` and `filename` fields must be also defined. The
|
|
|
|
`skipHash` field can be optionally provided to skip the inclusion of downloaded 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
|
2018-11-07 20:52:30 +00:00
|
|
|
list of fields that should play audio 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.
|
2017-02-03 04:14:24 +00:00
|
|
|
|
2017-04-22 06:36:47 +00:00
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-02-03 04:14:24 +00:00
|
|
|
{
|
2017-07-02 00:12:11 +00:00
|
|
|
"action": "addNote",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-07-02 00:12:11 +00:00
|
|
|
"params": {
|
|
|
|
"note": {
|
|
|
|
"deckName": "Default",
|
|
|
|
"modelName": "Basic",
|
|
|
|
"fields": {
|
|
|
|
"Front": "front content",
|
2017-09-10 05:28:09 +00:00
|
|
|
"Back": "back content"
|
2017-05-31 02:48:24 +00:00
|
|
|
},
|
2018-11-07 20:05:02 +00:00
|
|
|
"options": {
|
2019-01-06 03:43:44 +00:00
|
|
|
"allowDuplicate": false
|
2018-11-07 20:05:02 +00:00
|
|
|
},
|
2017-07-02 00:12:11 +00:00
|
|
|
"tags": [
|
2017-09-10 05:28:09 +00:00
|
|
|
"yomichan"
|
2017-05-31 02:48:24 +00:00
|
|
|
],
|
2017-07-02 00:12:11 +00:00
|
|
|
"audio": {
|
|
|
|
"url": "https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kanji=猫&kana=ねこ",
|
|
|
|
"filename": "yomichan_ねこ_猫.mp3",
|
2017-09-10 05:28:09 +00:00
|
|
|
"skipHash": "7e2c2f954ef6051373ba916f000168dc",
|
2018-07-03 13:50:50 +00:00
|
|
|
"fields": [
|
|
|
|
"Front"
|
|
|
|
]
|
2017-05-31 02:48:24 +00:00
|
|
|
}
|
2017-02-03 04:14:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": 1496198395707,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-02-03 04:14:24 +00:00
|
|
|
```
|
2017-02-05 20:08:52 +00:00
|
|
|
|
2017-04-22 06:36:47 +00:00
|
|
|
* **addNotes**
|
2017-02-05 20:08:52 +00:00
|
|
|
|
|
|
|
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 (notes that could not be created will have a `null` identifier). Please see the
|
|
|
|
documentation for `addNote` for an explanation of objects in the `notes` array.
|
|
|
|
|
2017-04-22 06:36:47 +00:00
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-02-05 20:08:52 +00:00
|
|
|
{
|
2017-07-02 00:12:11 +00:00
|
|
|
"action": "addNotes",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-07-02 00:12:11 +00:00
|
|
|
"params": {
|
|
|
|
"notes": [
|
2017-02-05 20:08:52 +00:00
|
|
|
{
|
2017-07-02 00:12:11 +00:00
|
|
|
"deckName": "Default",
|
|
|
|
"modelName": "Basic",
|
|
|
|
"fields": {
|
|
|
|
"Front": "front content",
|
|
|
|
"Back": "back content"
|
2017-02-05 20:08:52 +00:00
|
|
|
},
|
2017-07-02 00:12:11 +00:00
|
|
|
"tags": [
|
|
|
|
"yomichan"
|
2017-02-05 20:08:52 +00:00
|
|
|
],
|
2017-07-02 00:12:11 +00:00
|
|
|
"audio": {
|
|
|
|
"url": "https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kanji=猫&kana=ねこ",
|
|
|
|
"filename": "yomichan_ねこ_猫.mp3",
|
2017-09-10 05:28:09 +00:00
|
|
|
"skipHash": "7e2c2f954ef6051373ba916f000168dc",
|
2018-07-03 13:50:50 +00:00
|
|
|
"fields": [
|
|
|
|
"Front"
|
|
|
|
]
|
2017-02-05 20:08:52 +00:00
|
|
|
}
|
2017-07-02 00:12:11 +00:00
|
|
|
}
|
2017-02-05 20:08:52 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": [1496198395707, null],
|
|
|
|
"error": null
|
|
|
|
}
|
2017-02-05 20:08:52 +00:00
|
|
|
```
|
|
|
|
|
2017-04-22 06:36:47 +00:00
|
|
|
* **canAddNotes**
|
2017-02-03 04:14:24 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2017-04-22 06:36:47 +00:00
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-02-03 04:14:24 +00:00
|
|
|
{
|
2017-07-02 00:12:11 +00:00
|
|
|
"action": "canAddNotes",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-07-02 00:12:11 +00:00
|
|
|
"params": {
|
|
|
|
"notes": [
|
2017-02-05 20:08:52 +00:00
|
|
|
{
|
2017-07-02 00:12:11 +00:00
|
|
|
"deckName": "Default",
|
|
|
|
"modelName": "Basic",
|
|
|
|
"fields": {
|
|
|
|
"Front": "front content",
|
|
|
|
"Back": "back content"
|
2017-02-03 04:14:24 +00:00
|
|
|
},
|
2017-07-02 00:12:11 +00:00
|
|
|
"tags": [
|
|
|
|
"yomichan"
|
2017-02-03 04:14:24 +00:00
|
|
|
]
|
2017-07-02 00:12:11 +00:00
|
|
|
}
|
2017-02-03 04:14:24 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": [true],
|
|
|
|
"error": null
|
|
|
|
}
|
2017-02-03 04:14:24 +00:00
|
|
|
```
|
2017-02-01 17:23:09 +00:00
|
|
|
|
2018-01-01 02:34:38 +00:00
|
|
|
* **updateNoteFields**
|
|
|
|
|
|
|
|
Modify the fields of an exist note.
|
|
|
|
|
|
|
|
*Sample request*:
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"action": "updateNoteFields",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2018-01-01 02:34:38 +00:00
|
|
|
"params": {
|
|
|
|
"note": {
|
|
|
|
"id": 1514547547030,
|
|
|
|
"fields": {
|
|
|
|
"Front": "new front content",
|
|
|
|
"Back": "new back content"
|
2018-01-26 23:18:44 +00:00
|
|
|
}
|
2018-01-01 02:34:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
*Sample result*:
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"result": null,
|
|
|
|
"error": null
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-03 20:07:22 +00:00
|
|
|
* **addTags**
|
|
|
|
|
2017-08-03 21:21:59 +00:00
|
|
|
Adds tags to notes by note ID.
|
2017-08-03 20:07:22 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-03 20:07:22 +00:00
|
|
|
{
|
|
|
|
"action": "addTags",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-08-03 20:07:22 +00:00
|
|
|
"params": {
|
2017-08-03 21:21:59 +00:00
|
|
|
"notes": [1483959289817, 1483959291695],
|
2017-08-03 20:07:22 +00:00
|
|
|
"tags": "european-languages"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": null,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-03 20:07:22 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
* **removeTags**
|
|
|
|
|
2017-08-03 21:21:59 +00:00
|
|
|
Remove tags from notes by note ID.
|
2017-08-03 20:07:22 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-03 20:07:22 +00:00
|
|
|
{
|
|
|
|
"action": "removeTags",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-08-03 20:07:22 +00:00
|
|
|
"params": {
|
2017-08-03 21:21:59 +00:00
|
|
|
"notes": [1483959289817, 1483959291695],
|
2017-08-03 20:07:22 +00:00
|
|
|
"tags": "european-languages"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": null,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-03 20:07:22 +00:00
|
|
|
```
|
|
|
|
|
2018-01-14 11:26:37 +00:00
|
|
|
* **getTags**
|
|
|
|
|
|
|
|
Gets the complete list of tags for the current user.
|
|
|
|
|
|
|
|
*Sample request*:
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"action": "getTags",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6
|
2018-01-14 11:26:37 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
*Sample result*:
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"result": ["european-languages", "idioms"],
|
|
|
|
"error": null
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2018-01-26 23:18:44 +00:00
|
|
|
* **findNotes**
|
|
|
|
|
|
|
|
Returns an array of note IDs for a given query. Same query syntax as `guiBrowse`.
|
|
|
|
|
|
|
|
*Sample request*:
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"action": "findNotes",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2018-01-26 23:18:44 +00:00
|
|
|
"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 and the cards belonging to
|
|
|
|
the note.
|
|
|
|
|
|
|
|
*Sample request*:
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"action": "notesInfo",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2018-01-26 23:18:44 +00:00
|
|
|
"params": {
|
|
|
|
"notes": [1502298033753]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
*Sample result*:
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"result": [
|
|
|
|
{
|
|
|
|
"noteId":1502298033753,
|
|
|
|
"modelName": "Basic",
|
|
|
|
"tags":["tag","another_tag"],
|
|
|
|
"fields": {
|
|
|
|
"Front": {"value": "front content", "order": 0},
|
|
|
|
"Back": {"value": "back content", "order": 1}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"error": null
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
2019-02-26 17:28:36 +00:00
|
|
|
* **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
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
2018-01-26 23:18:44 +00:00
|
|
|
#### Cards ####
|
2017-08-22 08:43:37 +00:00
|
|
|
|
2017-08-03 20:07:22 +00:00
|
|
|
* **suspend**
|
|
|
|
|
2017-08-06 01:29:59 +00:00
|
|
|
Suspend cards by card ID; returns `true` if successful (at least one card wasn't already suspended) or `false`
|
|
|
|
otherwise.
|
2017-08-03 20:07:22 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-03 20:07:22 +00:00
|
|
|
{
|
|
|
|
"action": "suspend",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-08-03 20:07:22 +00:00
|
|
|
"params": {
|
2017-08-03 21:21:59 +00:00
|
|
|
"cards": [1483959291685, 1483959293217]
|
2017-08-03 20:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": true,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-03 20:07:22 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
* **unsuspend**
|
|
|
|
|
2017-08-06 01:29:59 +00:00
|
|
|
Unsuspend cards by card ID; returns `true` if successful (at least one card was previously suspended) or `false`
|
|
|
|
otherwise.
|
2017-08-03 20:07:22 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-03 20:07:22 +00:00
|
|
|
{
|
|
|
|
"action": "unsuspend",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-08-03 20:07:22 +00:00
|
|
|
"params": {
|
2017-08-03 21:21:59 +00:00
|
|
|
"cards": [1483959291685, 1483959293217]
|
2017-08-03 20:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": true,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-06 01:29:59 +00:00
|
|
|
```
|
|
|
|
|
2017-08-12 14:57:28 +00:00
|
|
|
* **areSuspended**
|
2017-08-06 01:29:59 +00:00
|
|
|
|
2017-08-12 15:28:38 +00:00
|
|
|
Returns an array indicating whether each of the given cards is suspended (in the same order).
|
2017-08-06 01:29:59 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-06 01:29:59 +00:00
|
|
|
{
|
2017-08-12 14:57:28 +00:00
|
|
|
"action": "areSuspended",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-08-06 01:29:59 +00:00
|
|
|
"params": {
|
2017-08-12 14:57:28 +00:00
|
|
|
"cards": [1483959291685, 1483959293217]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": [false, true],
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-12 14:57:28 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
* **areDue**
|
|
|
|
|
2017-10-02 01:17:39 +00:00
|
|
|
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.
|
2017-08-12 14:57:28 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-12 14:57:28 +00:00
|
|
|
{
|
|
|
|
"action": "areDue",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-08-12 14:57:28 +00:00
|
|
|
"params": {
|
|
|
|
"cards": [1483959291685, 1483959293217]
|
2017-08-06 01:29:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": [false, true],
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-03 20:07:22 +00:00
|
|
|
```
|
|
|
|
|
2017-08-09 17:40:09 +00:00
|
|
|
* **getIntervals**
|
|
|
|
|
|
|
|
Returns an array of the most recent intervals for each given card ID, or a 2-dimensional array of all the intervals
|
2017-10-02 01:17:39 +00:00
|
|
|
for each given card ID when `complete` is `true`. Negative intervals are in seconds and positive intervals in days.
|
2017-08-09 17:40:09 +00:00
|
|
|
|
|
|
|
*Sample request 1*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-09 17:40:09 +00:00
|
|
|
{
|
|
|
|
"action": "getIntervals",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-08-09 17:40:09 +00:00
|
|
|
"params": {
|
|
|
|
"cards": [1502298033753, 1502298036657]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result 1*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": [-14400, 3],
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-09 17:40:09 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
*Sample request 2*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-09 17:40:09 +00:00
|
|
|
{
|
|
|
|
"action": "getIntervals",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-08-09 17:40:09 +00:00
|
|
|
"params": {
|
|
|
|
"cards": [1502298033753, 1502298036657],
|
|
|
|
"complete": true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result 2*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": [
|
|
|
|
[-120, -180, -240, -300, -360, -14400],
|
|
|
|
[-120, -180, -240, -300, -360, -14400, 1, 3]
|
|
|
|
],
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-09 17:40:09 +00:00
|
|
|
```
|
|
|
|
|
2017-08-03 21:31:47 +00:00
|
|
|
* **findCards**
|
|
|
|
|
2017-10-02 01:17:39 +00:00
|
|
|
Returns an array of card IDs for a given query. Functionally identical to `guiBrowse` but doesn't use the GUI for
|
|
|
|
better performance.
|
2017-08-03 21:31:47 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-03 21:31:47 +00:00
|
|
|
{
|
|
|
|
"action": "findCards",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-07-02 00:12:11 +00:00
|
|
|
"params": {
|
|
|
|
"query": "deck:current"
|
2017-05-28 20:22:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": [1494723142483, 1494703460437, 1494703479525],
|
|
|
|
"error": null
|
|
|
|
}
|
2017-05-28 20:22:21 +00:00
|
|
|
```
|
|
|
|
|
2017-08-22 08:43:37 +00:00
|
|
|
* **cardsToNotes**
|
2017-08-13 08:02:59 +00:00
|
|
|
|
2017-10-02 01:17:39 +00:00
|
|
|
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.
|
2017-08-13 08:02:59 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-13 08:02:59 +00:00
|
|
|
{
|
2017-08-22 08:43:37 +00:00
|
|
|
"action": "cardsToNotes",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-08-13 08:02:59 +00:00
|
|
|
"params": {
|
2017-08-22 08:43:37 +00:00
|
|
|
"cards": [1502098034045, 1502098034048, 1502298033753]
|
2017-08-13 08:02:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": [1502098029797, 1502298025183],
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-13 08:02:59 +00:00
|
|
|
```
|
2017-08-14 20:02:56 +00:00
|
|
|
|
2018-01-09 17:40:07 +00:00
|
|
|
* **cardsInfo**
|
|
|
|
|
2018-01-26 23:18:44 +00:00
|
|
|
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, as well as ease and interval.
|
2018-01-09 17:40:07 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"action": "cardsInfo",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2018-01-09 17:40:07 +00:00
|
|
|
"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,
|
2018-01-09 17:44:50 +00:00
|
|
|
"interval": 16,
|
2018-01-09 17:40:07 +00:00
|
|
|
"note":1502298033753
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"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,
|
2018-01-09 17:44:50 +00:00
|
|
|
"interval": 23,
|
2018-01-09 17:40:07 +00:00
|
|
|
"note":1502298033753
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"error": null
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2018-01-26 23:18:44 +00:00
|
|
|
#### Media ####
|
2017-08-13 08:02:59 +00:00
|
|
|
|
2017-08-22 19:05:12 +00:00
|
|
|
* **storeMediaFile**
|
2017-08-10 17:34:43 +00:00
|
|
|
|
2018-01-26 23:18:44 +00:00
|
|
|
Stores a file with the specified base64-encoded contents inside the media folder. 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.
|
2017-08-10 17:34:43 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-10 17:34:43 +00:00
|
|
|
{
|
2017-08-22 19:05:12 +00:00
|
|
|
"action": "storeMediaFile",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-08-10 17:34:43 +00:00
|
|
|
"params": {
|
2017-08-22 08:43:37 +00:00
|
|
|
"filename": "_hello.txt",
|
|
|
|
"data": "SGVsbG8sIHdvcmxkIQ=="
|
2017-08-10 17:34:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": null,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-10 17:34:43 +00:00
|
|
|
```
|
2017-08-14 20:02:56 +00:00
|
|
|
|
2017-08-22 08:43:37 +00:00
|
|
|
*Content of `_hello.txt`*:
|
|
|
|
```
|
|
|
|
Hello world!
|
|
|
|
```
|
2017-08-13 09:05:56 +00:00
|
|
|
|
2017-08-22 19:05:12 +00:00
|
|
|
* **retrieveMediaFile**
|
2017-08-22 08:43:37 +00:00
|
|
|
|
2017-08-22 19:05:12 +00:00
|
|
|
Retrieves the base64-encoded contents of the specified file, returning `false` if the file does not exist.
|
2017-08-13 09:05:56 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-13 09:05:56 +00:00
|
|
|
{
|
2017-08-22 19:05:12 +00:00
|
|
|
"action": "retrieveMediaFile",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-08-13 09:05:56 +00:00
|
|
|
"params": {
|
2017-08-22 08:43:37 +00:00
|
|
|
"filename": "_hello.txt"
|
2017-08-13 09:05:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": "SGVsbG8sIHdvcmxkIQ==",
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-13 09:05:56 +00:00
|
|
|
```
|
2017-08-10 17:34:43 +00:00
|
|
|
|
2017-08-22 19:05:12 +00:00
|
|
|
* **deleteMediaFile**
|
2017-08-09 18:05:00 +00:00
|
|
|
|
2017-08-22 19:05:12 +00:00
|
|
|
Deletes the specified file inside the media folder.
|
2017-08-09 18:05:00 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-09 18:05:00 +00:00
|
|
|
{
|
2017-08-22 19:05:12 +00:00
|
|
|
"action": "deleteMediaFile",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-08-09 18:05:00 +00:00
|
|
|
"params": {
|
2017-08-22 08:43:37 +00:00
|
|
|
"filename": "_hello.txt"
|
2017-08-09 18:05:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": null,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-09 18:05:00 +00:00
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
#### Graphical ####
|
2017-08-22 08:43:37 +00:00
|
|
|
|
2017-08-03 21:31:47 +00:00
|
|
|
* **guiBrowse**
|
2017-07-21 11:45:31 +00:00
|
|
|
|
2017-10-02 01:17:39 +00:00
|
|
|
Invokes the *Card Browser* dialog and searches for a given query. Returns an array of identifiers of the cards that
|
|
|
|
were found.
|
2017-07-21 11:45:31 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-07-21 11:45:31 +00:00
|
|
|
{
|
2017-08-03 21:31:47 +00:00
|
|
|
"action": "guiBrowse",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-07-21 11:45:31 +00:00
|
|
|
"params": {
|
|
|
|
"query": "deck:current"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": [1494723142483, 1494703460437, 1494703479525],
|
|
|
|
"error": null
|
|
|
|
}
|
2017-07-21 11:45:31 +00:00
|
|
|
```
|
|
|
|
|
2017-05-28 20:22:21 +00:00
|
|
|
* **guiAddCards**
|
|
|
|
|
2019-01-24 07:44:28 +00:00
|
|
|
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.
|
2019-01-17 22:08:52 +00:00
|
|
|
|
2019-01-18 02:56:02 +00:00
|
|
|
The `closeAfterAdding` member inside `options` group can be set to true to create a dialog that closes upon adding the note.
|
2019-01-24 07:44:28 +00:00
|
|
|
Invoking the action mutliple times with this option will create _multiple windows_.
|
2017-05-28 20:22:21 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-05-28 20:22:21 +00:00
|
|
|
{
|
2017-10-02 01:17:39 +00:00
|
|
|
"action": "guiAddCards",
|
2019-01-17 22:08:52 +00:00
|
|
|
"version": 6,
|
|
|
|
"params": {
|
|
|
|
"note": {
|
|
|
|
"deckName": "Default",
|
|
|
|
"modelName": "Cloze",
|
|
|
|
"fields": {
|
|
|
|
"Text": "The capital of Romania is {{c1::Bucharest}}",
|
|
|
|
"Extra": "Romania is a country in Europe"
|
|
|
|
},
|
|
|
|
"options": {
|
2019-01-18 02:56:02 +00:00
|
|
|
"closeAfterAdding": true
|
2019-01-17 22:08:52 +00:00
|
|
|
},
|
|
|
|
"tags": [
|
2019-01-24 07:44:28 +00:00
|
|
|
"countries"
|
2019-01-17 22:08:52 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
2017-05-28 20:22:21 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": null,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-05-28 20:22:21 +00:00
|
|
|
```
|
|
|
|
|
2017-07-01 20:16:51 +00:00
|
|
|
* **guiCurrentCard**
|
2017-06-08 14:03:02 +00:00
|
|
|
|
2017-07-01 20:16:51 +00:00
|
|
|
Returns information about the current card or `null` if not in review mode.
|
2017-06-08 14:03:02 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-06-08 14:03:02 +00:00
|
|
|
{
|
2017-10-02 01:17:39 +00:00
|
|
|
"action": "guiCurrentCard",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6
|
2017-06-08 14:03:02 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-06-08 14:03:02 +00:00
|
|
|
{
|
2017-10-02 01:17:39 +00:00
|
|
|
"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}
|
2017-07-05 20:01:13 +00:00
|
|
|
},
|
2018-05-25 12:31:32 +00:00
|
|
|
"template": "Forward",
|
2017-10-02 01:17:39 +00:00
|
|
|
"cardId": 1498938915662,
|
2019-05-25 19:16:32 +00:00
|
|
|
"buttons": [1, 2, 3],
|
|
|
|
"nextReviews": ["<1m", "<10m", "4d"]
|
2017-07-03 00:52:57 +00:00
|
|
|
},
|
2017-10-02 01:17:39 +00:00
|
|
|
"error": null
|
2017-06-08 14:03:02 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-16 12:04:05 +00:00
|
|
|
* **guiStartCardTimer**
|
|
|
|
|
2017-10-02 01:17:39 +00:00
|
|
|
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`.
|
2017-08-16 12:04:05 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-16 12:04:05 +00:00
|
|
|
{
|
2017-10-02 01:17:39 +00:00
|
|
|
"action": "guiStartCardTimer",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6
|
2017-08-16 12:04:05 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": true,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-16 12:04:05 +00:00
|
|
|
```
|
|
|
|
|
2017-06-16 16:17:53 +00:00
|
|
|
* **guiShowQuestion**
|
2017-06-08 14:03:02 +00:00
|
|
|
|
2017-07-01 20:16:51 +00:00
|
|
|
Shows question text for the current card; returns `true` if in review mode or `false` otherwise.
|
2017-06-08 14:03:02 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-06-08 14:03:02 +00:00
|
|
|
{
|
2017-10-02 01:17:39 +00:00
|
|
|
"action": "guiShowQuestion",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6
|
2017-06-08 14:03:02 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": true,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-06-08 14:03:02 +00:00
|
|
|
```
|
|
|
|
|
2017-06-16 16:17:53 +00:00
|
|
|
* **guiShowAnswer**
|
2017-06-08 14:03:02 +00:00
|
|
|
|
2017-07-01 20:16:51 +00:00
|
|
|
Shows answer text for the current card; returns `true` if in review mode or `false` otherwise.
|
2017-06-08 14:03:02 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-06-08 14:03:02 +00:00
|
|
|
{
|
2017-10-02 01:17:39 +00:00
|
|
|
"action": "guiShowAnswer",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6
|
2017-06-08 14:03:02 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": true,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-06-08 14:03:02 +00:00
|
|
|
```
|
|
|
|
|
2017-06-16 16:17:53 +00:00
|
|
|
* **guiAnswerCard**
|
2017-06-08 14:03:02 +00:00
|
|
|
|
2017-07-01 20:16:51 +00:00
|
|
|
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.
|
2017-06-08 14:03:02 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-06-08 14:03:02 +00:00
|
|
|
{
|
2017-07-02 00:12:11 +00:00
|
|
|
"action": "guiAnswerCard",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2017-07-02 00:12:11 +00:00
|
|
|
"params": {
|
|
|
|
"ease": 1
|
2017-06-08 14:03:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": true,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-07-02 17:50:30 +00:00
|
|
|
```
|
2017-07-03 00:33:59 +00:00
|
|
|
|
2017-07-02 17:50:30 +00:00
|
|
|
* **guiDeckOverview**
|
|
|
|
|
2017-10-02 01:17:39 +00:00
|
|
|
Opens the *Deck Overview* dialog for the deck with the given name; returns `true` if succeeded or `false` otherwise.
|
2017-07-02 17:50:30 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-07-02 17:50:30 +00:00
|
|
|
{
|
|
|
|
"action": "guiDeckOverview",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2019-02-02 19:13:36 +00:00
|
|
|
"params": {
|
|
|
|
"name": "Default"
|
|
|
|
}
|
2017-07-02 17:50:30 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": true,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-07-02 17:50:30 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
* **guiDeckBrowser**
|
|
|
|
|
2017-10-02 01:17:39 +00:00
|
|
|
Opens the *Deck Browser* dialog.
|
2017-07-02 17:50:30 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-07-02 17:50:30 +00:00
|
|
|
{
|
2017-10-02 01:17:39 +00:00
|
|
|
"action": "guiDeckBrowser",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6
|
2017-07-02 17:50:30 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": null,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-06-08 14:03:02 +00:00
|
|
|
```
|
|
|
|
|
2017-07-03 00:33:59 +00:00
|
|
|
* **guiDeckReview**
|
|
|
|
|
|
|
|
Starts review for the deck with the given name; returns `true` if succeeded or `false` otherwise.
|
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-07-03 00:33:59 +00:00
|
|
|
{
|
|
|
|
"action": "guiDeckReview",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6,
|
2019-02-02 19:13:36 +00:00
|
|
|
"params": {
|
|
|
|
"name": "Default"
|
|
|
|
}
|
2017-07-03 00:33:59 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": true,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-07-03 00:33:59 +00:00
|
|
|
```
|
2017-08-31 04:26:28 +00:00
|
|
|
|
2017-08-29 02:24:08 +00:00
|
|
|
* **guiExitAnki**
|
|
|
|
|
2017-10-02 01:17:39 +00:00
|
|
|
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.
|
2017-08-29 02:24:08 +00:00
|
|
|
|
|
|
|
*Sample request*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-08-29 02:24:08 +00:00
|
|
|
{
|
2017-10-02 01:17:39 +00:00
|
|
|
"action": "guiExitAnki",
|
2018-05-25 12:31:32 +00:00
|
|
|
"version": 6
|
2017-08-29 02:24:08 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-08-31 04:26:28 +00:00
|
|
|
*Sample result*:
|
2017-09-30 00:03:48 +00:00
|
|
|
```json
|
2017-10-02 01:17:39 +00:00
|
|
|
{
|
|
|
|
"result": null,
|
|
|
|
"error": null
|
|
|
|
}
|
2017-08-29 02:24:08 +00:00
|
|
|
```
|