Help with Wanikani API calls from Anki


#1

I’ve just been setting up some Anki vocab lists. I want words to only show kanji if I know it on Wanikani. So I quickly wrote some javascript which can do this but it’s got a couple of problems I’m hoping you all can all work out.

Right now I’m not doing any API calls. Meaning I don’t know my level or the kanji I know. I’ve gotten around this by making a big multidimension array with all the kanji ordered by wanikani level, also using a variable to store my wanikani level which I have to manually input. Obvious issues with this is that I have to manually change my level each time I level up, plus I can only use kanji from previous lessons.

The reason I’m not doing any API calls is because as far as I know, every card would do a new API. That would quickly eat up the 100 API calls allowed per hour (plus it is pretty rude to do). I had a quick look at doing it in Python for getting the information but it’s not a language I’m familiar with, so that quickly went nowhere.

Does anybody have any ideas on how to solve my problems?

I’ll probably release this as an app when I’m finished. Depending on if I can make it idiot proof or not.


#2

Are you working with plain Javascript, or something like jquery?
What part about API calls is giving you trouble?  e.g. not knowing which URLs to request?  Not knowing how to do an ajax request?  Not knowing when or how often to fetch data?


#3

Just use plain old javascript at this point.

The problem is that I’m doing it in Anki so I would need to do a new API call every card as I don’t think the information can be stored. At least I couldn’t find anything in the manual (I might have missed it). This would mean while studying in Anki I would have to do a new API call every few seconds, which is both inefficient and not possible due to the 100 call limit an hour.

If it were a normal browser I would just throw all that information in a cookie and be done with it. In my quick test in anki, this didn’t work. Pretty sure I can’t do things like using local storage or query parameters or a database (maybe database is possible, haven’t tried).

The one idea I’ve had since my initial post is to create a junk card that can store all that information. Not sure if it’s possible to access this information from another card using javascript, haven’t had time to try. Not an elegant solution but it’s certainly better than manually changing variables (Might be quick and easy but no way would I remember to do it).


#4

Writing a Python addon would certainly be possible, that way you could access other cards or the database.
With Javascript it’s not that easy like you said since it’s just for styling the cards (html) and so gets called per card. You could maybe try out what happens if you use localStorage (if the cards speak HTML5 dunno). Another way could be -tedious though- that you load your kanjis into a file via the API and then have the cards read that file (with Jquery or something).


#5

So realistically I have to use Python, which I kind of figured.

I’m sure I can figure most of it out. At least I think I will be able to figure out how to do an API call and store the data. As for how to access said data from a card, would really save me a lot of headaches if someone could point me in the right direction. Possibly also how to run a function on anki startup (where I would do the API call) would be nice as well. The ANKI documentation really isn’t very good.


#6

If you can get it working, I would absolutely love to use it. I love the idea of Anki to supplement WK but like you said (kinda), if I tell it I’m level 5, it will throw in all the level 5 cards, even the ones I haven’t learned yet. Maybe I’m doing it completely wrong and just don’t understand how to use the WK deck… That’s very possible as I’m brand new to Anki… I dunno… Now I’m just rambling… I’ll see myself out…