An unofficial Python API for Tinycards by Duolingo.
The easiest way to get started is to simple install the library like so:
$ pip install tinycards
If you want to modify the library's source code and try out your changes locally, you might want to consider building from source which works like follows:
- Make sure Python with Setuptools is installed.
- From the project's root folder, install using pip:
$ pip install .
- In order to run the tests, you need to set the enviroment variables TINYCARDS_IDENTIFIER and TINYCARDS_PASSWORD.
- Then, from the project's root directory, simply start the pytest test runner:
$ pytest tinycards
- When all tests were successful, pytest will exit with 0.
Below is a list of some of the most common functions. For a more practical example, see the csv_to_deck.py script.
>>> # A new client with the given identification (e.g., mail address) and password.
>>> client = tinycards.Tinycards('identification', 'password')
'Logged in as 'username' ([email protected])'
>>> # If no identification or password are specified, they are taken from ENV.
>>> client = tinycards.Tinycards()
'Logged in as 'username' ([email protected])'>>> user = client.get_user_info()
{
username: 'bachman',
email: '[email protected]',
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- Bump the version in
setup.py. - Push a new tag to GitHub:
git tag 0.01git push origin 0.01
- The Travis build will deploy the release to PyPI.
