-
Notifications
You must be signed in to change notification settings - Fork 94
RESTful API Documentation
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!
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.
Returns a list of all models in a collection
No parameters.
array of objects, each representing a model
Returns a model that matches the given name
-
model
(string)
object, representing a model. If no model is found with the given name, an empty response will be sent.
Notes - Information (in fields per the model) that can generate a card (based on a template from the model).
Finds a set of notes
-
query
(string) (omitting this will return an empty array) -
preload
(boolean)
array of objects, each representing a note.
TODO Description
-
updated_since
(date) -
limit
(integer) -
preload
(boolean)
TODO
TODO Description
-
model
(string)
-
fields
(object) -
tags
(string)
None
Returns a list of all models in a collection
No parameters.
array of objects, each representing a model
Returns a list of all decks in the collection.
No parameters.
array of objects, each representing a deck
Switches to a deck specified by the given ID number or name.
-
deck
(string or number)
None
This will create a dynamic deck based on the given query. If a deck exists with the same name, the old deck will be cleared.
-
name
(string) - defaults to "Custom Study Session" -
query
(string) - defaults to '' (TODO document query) -
count
(int) - default to 100 -
mode
(string) - "random", "added", or "due". defaults to "random".
Returns an object representing the newly created dynamic deck.
If a dynamic deck exists with the given name, clears that deck.
-
name
(string) - defaults to "Custom Study Session"
None
Cards - A specific card in a deck with a history of review (generated from a note based on the template).
Returns a set of cards that match the given query.
-
query
(string) - defaults to '' (TODO document query) -
order
(boolean) - defaults toFalse
-
limit
(int) - defaults to 0 -
offset
(int) - defaults to 0 -
preload
(boolean) - defaults toFalse
List of objects representing cards that were retrieved by the query
Returns a list of cards ordered by last update date, with the most recently updated cards returned first.
-
updated_since
(date string) -
limit
(int) - defaults to 10 -
preload
(boolean) - defaults toFalse
List of objects representing cards that were retrieved by the query
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO