An unofficial Python API for Tinycards by Duolingo.
- Make sure Python (with pip) is installed.
- Install dependencies from the requirements.txt (hint: requests is the only requirement right now):
$ pip install -r requirements.txt
>>> # A new client with the given identification (e.g., mail address) and password.
>>> client = tinycards.Tinycards('identification', 'password')
'Logged in as 'username' (user@email.com)'
>>> # If no identification or password are specified, they are taken from ENV.
>>> client = tinycards.Tinycards()
'Logged in as 'username' (user@email.com)'
>>> user = client.get_user_info()
{
username: 'bachman',
email: 'bachman@aviato.com',
fullname: 'Erlich Bachman',
...
}
>>> all_decks = client.get_decks()
>>> [deck.title for deck in all_decks]
['Deck 1', 'Deck 2', 'Deck 3']
>>> deck_1 = client.find_deck_by_title('Deck 1')
>>> deck_1.title = 'Deck 1.1'
>>> client.update_deck(deck_1)
{
'title': 'Deck 1.1',
...
}
>>> deck = client.find_deck_by_title('Some Deck')
{
'title': 'Some Deck',
'id': '8176b324-addc-495d-aadc-fad005e5b439'
...
}
>>> client.delete_deck(deck.id)
{
'title': 'Some Deck',
'id': '8176b324-addc-495d-aadc-fad005e5b439'
...
}
>>> deck = client.find_deck_by_title('Some Deck')
None