wanikanify icon indicating copy to clipboard operation
wanikanify copied to clipboard

Migrate to WaniKani API v2

Open padarom opened this issue 4 years ago • 7 comments

API v1 will cease to exist on September 1. Therefore Wanikanify needs to migrate to v2 in order to keep functioning from that date on.

The endpoints in v2 are more atomic in nature, so unfortunately it's not quite as easy to use as v1 but I tried to make the code as readable as possible.

  1. We fetch the user's vocabulary assignments. This gives us the user's progress (i.e. SRS level) for each item, but doesn't provide the vocab itself.
  2. We fetch the study material. These are all the custom notes and synonyms the user has added to their vocabs.
  3. Of the data we have requested this far, we are only interested in the user defined synonyms, the SRS level and the assignment's subject IDs. Therefore we create a simple hash that only includes those values.
  4. Request the subject for each of the user's assignments. This gives us the actual list of characters and meanings.

padarom avatar May 16 '20 00:05 padarom

@padarom Thanks for the PR! I'll have a look and merge in the next few days. I don't use wanikani these days, and I haven't looked at this code in years, except for incoming PRs. It's likely due for an overhaul and/or a new maintainer.

josefalcon avatar May 19 '20 14:05 josefalcon

Any update on this? I'd love to continue being able to use this awesome extension.

Koolstr avatar Dec 15 '20 09:12 Koolstr

FYI, Pulled this and ran locally, can confirm change seems to be working (Admittedly Brave Browser) but I can't see why it wouldn't for Chrome.

AdamMelbye avatar Jan 13 '21 22:01 AdamMelbye

Yeah, sadly does not appear to be working on chrome. Installed @padarom fork.

wiilover22 avatar Feb 07 '21 17:02 wiilover22

I just tested my fork on Chrome again. It is still working for me, even on a different machine than where I developed it. Like AdamMelbye, I don't see any reason why it wouldn't work on Chrome if it worked in Brave. They're all Chromium so if one works, the others most likely also will.

image

padarom avatar Feb 08 '21 09:02 padarom

I'm not sure what I'm missing then. Tried a fresh install of Brave Browser as well, and didn't work there either for me. Does the API token need more permissions other than the default "GET"? I downloaded your fork, installed using the developer mode toggle in the extensions tab, put in my API key, and have tried every setting - from the Automatic, to clicking the extension button.

Any ideas, or any form of debugging/logs I can help with?

Edit: Figured out the how to get the console to log stuff. Looks like I'm getting an incomplete promise due to the GET URL being wrong for some reason. Log attached

err1.log

wiilover22 avatar Feb 08 '21 14:02 wiilover22

The difference seems to be our Wanikani progress. The request attaches all subject IDs that you have at your minimum SRS level as GET parameters. For me and wiilover22 this seems fine because we don't have as many subjects, but for you it seems like the parameters make the URL exceed the maximum URL length supported by WaniKani.

Unfortunately I don't have the time right now to look into this, but I assume we'd need to split the request in getVocabListFromWaniKani into multiple batches so that each request stays under the URL length limit. The issue is that at some point we might run into rate limiting issues, so we'd probably also need to add some smart retry logic and try fetching missing resources over time, which I think is a major change.

padarom avatar Mar 09 '21 09:03 padarom