Skip to main content

Working with WaniKani API, login, and Community.

Project description

# How to use WaniKaniTools

The following operations are supported by WaniKaniTools

* API v1 wrapper
* API v2 wrapper, and support for pagination
* Web login using `PhantomJS` and able to both `execute_script()` and `click()` buttons accordingly

Sample working scripts are

* `burnManager.py`
* `WaniKaniTools/database/create.py`
* `example/multiple_readings.py`

## Installation

1. For Mac OSX, `brew install phantomjs`. I am not sure about Windows, or other OS's, but you'll need PhantomJS for the web login, burnManager and Community.
2. `pip install WaniKaniTools`

## Using API v1

```python
from WaniKaniTools.api import api

resource = (
'user-information',
'study-queue',
'level-progression',
'srs-distribution',
'recent-unlocks', # Argument is output limit in range 1-100. Default=10
'critical-items', # Argument is percentage in range 0-100. Default=75
'radicals', # Argument is level, comma-delimited. Default=all levels
'kanji',
'vocabulary'
)
api_v1 = api.v1(put_your_api_v1_key_here)
result = api_v1.GET(resource[2])['requested_information'] # Output is Python dictionary
```

## Using API v2

### Basic operations

```python
from WaniKaniTools.api import api

resource_v2 = (
'user',
'subjects', # Argument is id. Params are ids, types, slugs, levels, updated_after
'assignments', # Argument is id. Params are ...
'review_statistics',
'study_materials',
'summary',
'reviews',
'level_progressions',
'resets'
)
api_v2 = api.v2(put_your_api_v2_key_here)
result = api_v2.GET(resource_v2[1]) # Output is Python dictionary
```

### Pagination

```python
from WaniKaniTools.api import api

api_v2 = api.v2(put_your_api_v2_key_here)
result = api_v2.GET('subjects')

while True:
for data in result['data']:
meaning_array = []
for meaning in data["data"]["meanings"]:
if meaning['primary']:
meaning_array += [ meaning['meaning'] ]

to_print = (
data["id"],
data["object"],
data["data"]["characters"] if "characters" in data["data"] else data["data"]["character"],
', '.join(meaning_array),
data["data"]["document_url"]
)
print(*to_print)

next_url = result['pages']['next_url']

if next_url is None:
break

result = api_v2.GETurl(next_url)
```

## Simulating web login

### Web login and execute script

The operations supported here are the same as `selenium-webdriver`

```python
from WaniKaniTools.website import login

with login.Webdriver(your_username, your_password) as w:
w.driver.execute_script(put_your_javascript_here)
```


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

WaniKaniTools-0.2.1.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

WaniKaniTools-0.2.1-py2.py3-none-any.whl (4.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file WaniKaniTools-0.2.1.tar.gz.

File metadata

File hashes

Hashes for WaniKaniTools-0.2.1.tar.gz
Algorithm Hash digest
SHA256 6504dd48ea20fc82e9d18f815d5bd3555a9e4f89f2f0b1df2d96bb9674d17b8f
MD5 3028fa5ddeb9a85a8f1420bfd5df6fcc
BLAKE2b-256 48b999c5df1907e9dc861a6ba43a9191285566265793d143a337d1a1e6cd1ac5

See more details on using hashes here.

File details

Details for the file WaniKaniTools-0.2.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for WaniKaniTools-0.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b4569ad080f53fa06b936a68f79eb5dd6ffaddc49a4b139a1208b3ca260ccf60
MD5 de4c1818d23716c708b863c1b4f1ea6f
BLAKE2b-256 5a2e20c9b0c6bfa8538465df65ac91a73470833f402fa6239f52b5dadb1ba73b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page