PC端添加卡片的插件
之前的通用模板2,手机端不能配合蓝牙自拍器,这里改成单张卡片的形式。
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.Card Actions
名称 | 说明 | 提交json | 返回json |
---|---|---|---|
getEaseFactors | Returns an array with the ease factor for each of the given cards (in the same order). |
{ “version”: 6, “action”: “getEaseFactors”, “params”: { “cards”: [ 1483959291685, 1483959293217 ] } } |
{ “result”: [ 4100, 3900 ], “error”: null } |
Deck Actions
名称 | 说明 | 提交json | 返回json |
---|---|---|---|
deckNames | Gets the complete list of deck names for the current user. |
{ “action”: “deckNames”, “version”: 6 } | { “result”: [“Default”], “error”: null } |
Graphical Actions
名称 | 说明 | 提交json | 返回json |
---|---|---|---|
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. |
{ “action”: “guiBrowse”, “version”: 6, “params”: { “query”: “deck:current” } } | { “result”: [1494723142483, 1494703460437, 1494703479525], “error”: null } |
Media Actions
名称 | 说明 | 提交json | 返回json |
---|---|---|---|
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. |
{ “action”: “storeMediaFile”, “version”: 6, “params”: { “filename”: “_hello.txt”, “data”: “SGVsbG8sIHdvcmxkIQ==” } } | { “result”: “_hello.txt”, “error”: null } |
Miscellaneous Actions
名称 | 说明 | 提交json | 返回json |
---|---|---|---|
requestPermission | Request permission to use the API exposed by this plugin. Only request coming from origin listed in the webCorsOriginList option are allowed to use the Api. Calling this method will display a popup asking the user if he want to allow your origin to use the Api. This is the only method that can be called even if the origin of the request isn’t in the webCorsOriginList list. It also doesn’t require the api key. Calling this method will not display the popup if the origin is already trusted. This should be the first call you make to make sure that your application and AnkiConnect are able to communicate properly with each other. New versions of AnkiConnect are backwards compatible; as long as you are using actions which are available in the reported AnkiConnect version or earlier, everything should work fine. |
{ “version”: 6, “action”: “requestPermission” } |
{ “result”: { “permission”: “granted”, “requireApiKey”: false, “version”: 6 }, “error”: null } { “result”: { “permission”: “denied” }, “error”: null } |
# |
Model Actions
名称 | 说明 | 提交json | 返回json |
---|---|---|---|
modelNames | Gets the complete list of model names for the current user. |
{ “version”: 6, “action”: “modelNames” } |
{ “result”: [ “Basic”, “Basic (and reversed card)” ], “error”: null } |
Note Actions
名称 | 说明 | 提交json | 返回json |
---|---|---|---|
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. AnkiConnect 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 fieldsmember 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. |
{ “version”: 6, “action”: “addNote”, “params”: { “note”: { “deckName”: “Default”, “picture”: [ { “skipHash”: “8d6e4646dfae812bf39651b59d7429ce”, “url”: “https://upload.wikimedia.org/wikipedia/commons/thumb/c/c7/A_black_cat_named_Tilly.jpg/220px-A_black_cat_named_Tilly.jpg”, “filename”: “blackcat.jpg”, “fields”: [ “Back” ] } ], “audio”: [ { “skipHash”: “7e2c2f954ef6051373ba916f000168dc”, “url”: “https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kanji=猫&kana=ねこ”, “filename”: “yomichanねこ_猫.mp3”, “fields”: [ “Front” ] } ], “modelName”: “Basic”, “video”: [ { “skipHash”: “4117e8aab0d37534d9c8eac362388bbe”, “url”: “https://cdn.videvo.net/videvo_files/video/free/2015-06/small_watermarked/Contador_Glam_preview.mp4”, “filename”: “countdown.mp4”, “fields”: [ “Back” ] } ], “fields”: { “Front”: “front content”, “Back”: “back content” }, “options”: { “allowDuplicate”: false, “duplicateScope”: “deck”, “duplicateScopeOptions”: { “deckName”: “Default”, “checkChildren”: false, “checkAllModels”: false } }, “tags”: [ “yomichan” ] } } } |
{ “result”: 1496198395707, “error”: null }{ “result”: [1496198395707, null], “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 (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. |
{ “version”: 6, “action”: “addNotes”, “params”: { “notes”: [ { “deckName”: “Default”, “picture”: [ { “skipHash”: “8d6e4646dfae812bf39651b59d7429ce”, “url”: “https://upload.wikimedia.org/wikipedia/commons/thumb/c/c7/A_black_cat_named_Tilly.jpg/220px-A_black_cat_named_Tilly.jpg”, “filename”: “blackcat.jpg”, “fields”: [ “Back” ] } ], “audio”: [ { “skipHash”: “7e2c2f954ef6051373ba916f000168dc”, “url”: “https://assets.languagepod101.com/dictionary/japanese/audiomp3.php?kanji=猫&kana=ねこ”, “filename”: “yomichanねこ_猫.mp3”, “fields”: [ “Front” ] } ], “modelName”: “Basic”, “video”: [ { “skipHash”: “4117e8aab0d37534d9c8eac362388bbe”, “url”: “https://cdn.videvo.net/videvo_files/video/free/2015-06/small_watermarked/Contador_Glam_preview.mp4”, “filename”: “countdown.mp4”, “fields”: [ “Back” ] } ], “fields”: { “Front”: “front content”, “Back”: “back content” }, “tags”: [ “yomichan” ] } ] } } |
|
Statistic Actions
名称 | 说明 | 提交json | 返回json |
---|---|---|---|
getNumCardsReviewedToday | Gets the count of cards that have been reviewed in the current day (with day start time as configured by user in anki) | { “version”: 6, “action”: “getNumCardsReviewedToday” } |
{ “result”: 0, “error”: null } |