Skip to content

RESTful API Documentation

Austin Almond edited this page May 6, 2017 · 29 revisions

Unfortunately, there still isn't complete documentation on using the RESTful API. However, here is a super quick overview with information about how to gleen more information.

Please edit this page and help improve it!

Overview

All the code for the API and be found in this file:

https://github.com/dsnopek/anki-sync-server/blob/master/AnkiServer/apps/rest_app.py

All of the endpoints take HTTP POST requests and accept/return JSON (except for the top-level URL, which is a GET request and returns text with version information). So, the API is actually not quite RESTful, it's more like a super simple HTTP RPC.

There is one magic URL, /list_collections which returns the names of all available collections. Every other URL will contain the collection name and is directly connected to a Handler class:

  • /collection/[NAME]/[METHOD] -> CollectionHandler
  • /collection/[NAME]/model/[MODEL_ID]/[METHOD] -> ModelHandler
  • /collection/[NAME]/note/[NOTE_ID]/[METHOD] -> NoteHandler
  • /collection/[NAME]/deck/[DECK_ID]/[METHOD] -> DeckHandler
  • /collection/[NAME]/card/[CARD_ID]/[METHOD] -> CardHandler

Replace [NAME] with the collection name and [METHOD] with a paricular method on the Handler class that you want to call. So, for example, POSTing to this URL:

/collection/mine/latest_notes

... will call the CollectionHandler.latest_notes() method in the rest_app.py file I linked above.

Collections

TODO: document all the methods on the CollectionHandler

list_models

find_model_by_name

find_notes

latest_notes

add_note

list_tags

list_decks

select_deck

create_dynamic_deck

empty_dynamic_deck

find_cards

latest_cards

reset_scheduler

extend_scheduler_limits

next_card

answer_card

suspend_cards

unsuspend_cards

cards_recent_ease

latest_revlog

stats_report

set_language

Models

TODO: document all the methods on the ModelHandler

field_names

Notes

TODO: document all the methods on the NoteHandler

index

update

delete

add_tags

remove_tags

Decks

TODO: document all the methods on the DeckHandler

index

next_card

get_conf

set_update_conf

Cards

TODO: document all the methods on the CardHandler

index

add_tags

remove_tags

stats_report

latest_revlog

Clone this wiki locally