ankiconnect

Types

pub type ActionError {
  AnkiActionFailed(String)
  FailedToDecodeResponse(json.DecodeError)
}

Constructors

pub type FieldData {
  FieldData(value: String, order: Int)
}

Constructors

  • FieldData(value: String, order: Int)

The source for a media file that can be added to an Anki deck.

pub type MediaFileSource {
  Base64Data(String)
  Path(String)
  Url(String)
}

Constructors

  • Base64Data(String)
  • Path(String)
  • Url(String)
pub type Note {
  NewNote(
    deck_name: String,
    model_name: String,
    fields: dict.Dict(String, String),
    tags: List(String),
    audio: List(NoteMediaFile),
    video: List(NoteMediaFile),
    picture: List(NoteMediaFile),
  )
}

Constructors

pub type NoteInfo {
  NoteInfo(
    note_id: Int,
    model_name: String,
    tags: List(String),
    fields: dict.Dict(String, FieldData),
  )
}

Constructors

  • NoteInfo(
      note_id: Int,
      model_name: String,
      tags: List(String),
      fields: dict.Dict(String, FieldData),
    )
pub type NoteMediaFile {
  NewNoteMediaFile(
    filename: String,
    source: MediaFileSource,
    fields: List(String),
  )
}

Constructors

  • NewNoteMediaFile(
      filename: String,
      source: MediaFileSource,
      fields: List(String),
    )

Values

pub fn add_note_request(note: Note) -> request.Request(String)

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.

pub fn add_note_response(
  response: response.Response(String),
) -> Result(Int, ActionError)

Parses the response for an addNote request.

pub fn deck_names_and_ids_request() -> request.Request(String)

Gets the complete list of deck names and their respective IDs for the current user.

pub fn deck_names_and_ids_response(
  response: response.Response(String),
) -> Result(dict.Dict(String, Int), ActionError)

Parses the response for a deckNamesAndIds request.

pub fn deck_names_request() -> request.Request(String)

Gets the complete list of deck names for the current user.

pub fn deck_names_response(
  response: response.Response(String),
) -> Result(List(String), ActionError)

Parse the response for the deck names request.

pub fn find_cards_request(
  query: String,
) -> request.Request(String)

Returns the matching card IDs for a query.

pub fn find_cards_response(
  response: response.Response(String),
) -> Result(List(Int), ActionError)

Parses the response for a findCards request.

pub fn find_notes_request(
  query: String,
) -> request.Request(String)

Returns an array of note IDs for a given query.

pub fn find_notes_response(
  response: response.Response(String),
) -> Result(List(Int), ActionError)

Parses the response for a findNotes request.

pub fn notes_info_query_request(
  query: String,
) -> request.Request(String)

Gets the note info for a query.

Use with notes_info_response.

pub fn notes_info_request(
  ids: List(Int),
) -> request.Request(String)

Gets the note info for a list of note IDs.

pub fn notes_info_response(
  response: response.Response(String),
) -> Result(List(NoteInfo), ActionError)

Parses the response for a notesInfo request.

pub fn store_media_file_request(
  filename: String,
  source: MediaFileSource,
  delete_existing: Bool,
) -> request.Request(String)

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.

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.

pub fn store_media_file_response(
  response: response.Response(String),
) -> Result(String, ActionError)

Parses the response for a storeMediaFile request.

Search Document