Skip to content

gnicod/tinycards-python-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tinycards Python API

An unofficial Python API for Tinycards by Duolingo.

Installation

  1. Make sure Python (with pip) is installed.
  2. Install dependencies from the requirements.txt (hint: requests is the only requirement right now):
$ pip install -r requirements.txt

Usage

Initialise a new client

>>> # 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)'

Get info about the currently logged in user.

>>> user = client.get_user_info()
{
  username: 'bachman',
  email: 'bachman@aviato.com',
  fullname: 'Erlich Bachman',
  ...
}

Get all decks of a user

>>> all_decks = client.get_decks()
>>> [deck.title for deck in all_decks]
['Deck 1', 'Deck 2', 'Deck 3']

Update an existing deck

>>> deck_1 = client.find_deck_by_title('Deck 1')
>>> deck_1.title = 'Deck 1.1'
>>> client.update_deck(deck_1)
{
  'title': 'Deck 1.1',
  ...
}

Delete an existing deck

>>> 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

About

An unofficial Python API for Tinycards by Duolingo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%