API for reviewing?

I was planning to make or at least experiment with a WaniKani VR application for the HTC Vive.
After having implemented the API I noticed there was no endpoints for reviewing?
All of the API endpoints seems to be only for statistics.

Is there a separate API the mobile application uses for reviews?
Anyone knows how it does it?

Without it the VR application will only be a statistics app -.-

The mobile programs use an embedded iframe, thatā€™s how you can login to it since WK has no authentication linking to it. There is no such API.

Wouldnā€™t want to experience any level above 20 in VR anywayā€¦

Awā€¦ I was hoping to do my reviews in a fun way in VR.

Iā€™ll see if I can still do the reviews by using the site in the background but provide a VR GUI to do the reviewing in.
Would have been easier with an API.

Why no kanji above level 20 in VR?
Iā€™ve done RTK 1 twice and canā€™t see where the issue is?
Of course the writing in VR has to be big for it to be viewable with nice AA/Supersampling.

The potential of what you can do in VR is infinite, I canā€™t wait to figure out a really fun way to do WaniKani in VR.

Edit: Just checked the review ajax requests and it seems like thatā€™s the API I want to use :slight_smile:
Just need to have a session going and it should work.

mattias said... Aw... I was hoping to do my reviews in a fun way in VR.

I'll see if I can still do the reviews by using the site in the background but provide a VR GUI to do the reviewing in.
Would have been easier with an API.

Why no kanji above level 20 in VR?
I've done RTK 1 twice and can't see where the issue is?
Of course the writing in VR has to be big for it to be viewable with nice AA/Supersampling.

The potential of what you can do in VR is infinite, I can't wait to figure out a really fun way to do WaniKani in VR.
 'cuz level twenties are death and thirties are hell... *Badum tsss*

Haha, WaniKani reviews in VR? Iā€™d like to see what that looks like :smiley:

Hi there! Iā€™m new here, so please pardon me if I break some sort of rule in this post. :smiley:

Thereā€™s no public API for that as far as I know, but you could just as well make a GET request to:
https://www.wanikani.com/review/queue?
^ Edit2: this is correct now

You need to pass the userā€™sĀ _wanikani_session cookie in the request header (ie, Cookie: _wanikani_session=12341243SUPERSECRETNUMBER5325234). Getting the cookie is probably going to be the tricky part, but you could certainly analyze how WaniKani does it and make your own login transaction; not that thatā€™s necessarily very good practice, lol. :stuck_out_tongue: For the purpose of testing though, you could just pull it out of the Network tools tab in the Chrome developer tools.

Itā€™ll throw you back some JSON which should be fairly intuitive to read out into your own data structure. I canā€™t give it a proper look yet, because I have only 1 review in my queue, but Iā€™m sure you can figure it out! Good luck BTW, I canā€™t wait to see WaniKani in VR!!

Edit 3:
It seems that you can make the SRS aware of progress updates via this service:
https://www.wanikani.com/json/progress
You can supply the ID of the item you want to update in the query string; ie:
https://www.wanikani.com/json/progress?r128=0
To assert that the ā€˜clamā€™ radical took 0 attempts to answer correctly (I think thatā€™s the point of the 0 there).

Very funny to see this here. Iā€™ve already sent an E-Mail about it, since I wanted to build my own client without the need to disguise as a webbrowser.

Method of logging in:

visit https://www.wanikani.com/login
To get the ā€œauthenticity_tokenā€ that is inside the login form. (not actually sure if you need that x.x)
And then just send a post with the login informations and the authenticity_token.

Doing so in Firefox gives back a 302 response and  ā€œ_wanikani_sessionā€ is found in the answer header
Doing it outside of firefox gives me back a 200 response and the ā€œ_wanikani_sessionā€ cookie.
 
Calling ā€œhttps://www.wanikani.com/vocabulary/力ā€ to retrieve the item ID required for https://www.wanikani.com/json/progress?v18=0 sadly gives me a 500 response.
https://www.wanikani.com/json/progress?v18=0 can be called to answer ā€œåŠ›ā€ correctly (only works if the item is ready for reviewing)
I havenā€™t found a different way to get the item ID except for the item pageā€™s javascript

Items that are on your reviewlist can be gathered from the api tho


Here is hopping that Viet at least responses to my E-Mail, but I guess he is a busy man. :slight_smile:
Hope I could help someone with my attempt


EDIT: Did I write 301?.. I meanā€™t 302ā€¦
EDIT2: Donā€™t just copy urls I guessā€¦ whoopsā€¦

Ah nice, thatā€™s brilliant.Ā 

Hm, odd; I get a 200 OK regardless of the item ID. Does it still give you a 500 if you replace that ā€˜rā€™ with a ā€˜vā€™? I think thatā€™s supposed to denote the type; ie, for the 力 vocab word, does this work?
https://www.wanikani.com/json/progress?v18=0

Oh that is what you get if you take the shortcut and copy it. xD
I have ā€œ/json/progress?v18=0&v18=0ā€ in my code. (as this is what your browser sends after getting it right)

I get the 500 when gathering the Item ID found on the item page:

Line 430 -> https://www.wanikani.com/vocabulary/力: Notes.add(ā€˜vocabularyā€™, ā€˜meaningā€™, 18, progression.requested_information.meaning_note, $(ā€˜#note-meaningā€™));
Havenā€™t tried calling progress yet, as it failed on a step before it. I Guess Iā€™ll try it out real quickā€¦ and edit the above oneā€¦ againā€¦

Yeah, Iā€™m just going to create a desktop window which you can login with to get the session.
Then inside VR Iā€™ll make use of this undocumented API.

Kind of how Wevr transport does it.

I guess Iā€™ll start writing on a library to use this undocumented API.
It should be fine since you still need to actually login to use it.

Going to have to write a library for both the public API and the undocumented one before I start on creating VR content.

Haha, you sometime just need to take a little break to see something so obviousā€¦
No 401 response with session cookie anywhere

I donā€™t really want to tell you but okā€¦
The reason for the 500 was me sending ā€œåŠ›ā€. (facepalm)
200 with the wanted Item ID after doing some UTF-8 magicā€¦

submitting an answer is:

A get to :
/json/progress?v<ITEM_ID>=0&v<ITEM_ID>=0
With this being in the header. (you get 406 otherwise)
X-Requested-With", ā€œXMLHttpRequestā€
And the ā€œ_wanikani_sessionā€ cookie ofc
and you log in with:
A get to :
https://www.wanikani.com/login
And retriving ā€œauthenticity_tokenā€ from the Loginform
and a post with the logindata and the authenticity_token.
The Item ID can be found on its page inside the javascript near the end of the file

I guess I slept when I tried it firstā€¦
Would be nice to so something in the API regardless as less experienced people (like me q.q) get a better chance of doing things

Darky1 said...submitting an answer is:
A get to :
/json/progress?v<ITEM_ID>[]=0&v<ITEM_ID>[]=0
 And, of course, replace the zeros with ones if you got meaning or reading wrong.  I can't remember which one is meaning and which is reading.  It's been a long time since I did anything with those.  But I think it's the same order as how it appears on the item progress screen (where it shows percent correct and longest streak).
rfindley said...
Darky1 said...submitting an answer is:
A get to :
/json/progress?v<ITEM_ID>[]=0&v<ITEM_ID>[]=0
 And, of course, replace the zeros with ones if you got meaning or reading wrong.  I can't remember which one is meaning and which is reading.  It's been a long time since I did anything with those.  But I think it's the same order as how it appears on the item progress screen (where it shows percent correct and longest streak).
 Totally forgot that.

Something to note would be that the "v" stands for vocab, and is replaced with "k" for Kanji and "r" for Radicals.
My guess would be that the first of the two 0s is the amount of meaning answers you got wrong, and the second one the amount of wrong reading answers.
Radicals have the first 0 changed. (the other one remains 0)

You donā€™t need to lookup the kanji etc to find the id. All data is available in the queue response:
https://www.wanikani.com/review/queue?

Watching some of the headers I also see X-CSRF-Token, might need that as well?
I havenā€™t written any code yet. But all you need is to have the network tab open in your browser and do some reviews to find the right api calls and which headers/data they use.

^^^
Iā€™ve done an automated WK login for some scripts that monitor WK updates. Ā I just used wget in a bash shell, with the flag to save cookies to a file. Ā Worked great, and I didnā€™t have to look at what cookies were being saved. Ā Doing it in an app instead of shell-script should be fine if your http library has decent cookie support.

How do you do login script in Python? What info do I need?

payload = {'user[login]': 'xxxxxx', 'user[password]': 'xxxxxx', 'user[remember_me]' : True, 'authenticity_token' : 'zQE9GfubYgUZdGMlXsnNXzoMbAYBVAKhyIJnhw1TUtB4LAtC/+qExa1/53nhOC9oGTEjz3nU7CkIOPUkoVMaGw==', 'utf8' : '&#x2713;' }

For the ā€˜utf8ā€™ parameter, I used:

utf8=%E2%9C%93

My overall POST data looked like this (without the new-lines):

utf8=%E2%9C%93
&authenticity_token=ZwqNBZMlyTtJzX3Yw%2BbbxGGX87ScrvxwGCVJd2%2B62bqgNssN6oXlOcpoChWh8nQQMWp9tl5fNMMCjroRg%2Bz9jg%3D%3D
&user%5Blogin%5D=xxxxxx
&user%5Bpassword%5D=xxxxxx
&user%5Bremember_me%5D=0
&user%5Bremember_me%5D=1

And, of course, you have to keep the cookies between calls.

I used a bash script for the fetching, and a node.js script to extract the info from the login page:

bash script
#!/bin/bash

COOKIES="html/cookies.txt"

# Clear cookies
rm -f ${COOKIES}

# Get login page, and extract auth token
wget -Ohtml/login.html --save-cookies ${COOKIES} --keep-session-cookies "https://www.wanikani.com/login" -o/dev/null
post_data=`./extract_login_auth`

# Login, and save Dashboard
wget -Ohtml/dashboard.html --load-cookies ${COOKIES} --keep-session-cookies --save-cookies ${COOKIES} --post-data "${post_data}" "https://www.wanikani.com/login" -o/dev/null
node.js script
#!/usr/bin/js

var username = 'your_username';
var password = 'your_password';
var utf8='utf8=%E2%9C%93';

var fs = require('fs');
var cheerio = require('cheerio');

var page = fs.readFileSync('html/login.html');
var $ = cheerio.load(page);
console.log(
        utf8+
        '&authenticity_token='+encodeURIComponent($('input[name="authenticity_token"]').val())+
        '&'+encodeURIComponent('user[login]')+'='+encodeURIComponent(username)+
        '&'+encodeURIComponent('user[password]')+'='+encodeURIComponent(password)+
        '&'+encodeURIComponent('user[remember_me]')+'=0'+
        '&'+encodeURIComponent('user[remember_me]')+'=1'
);
1 Like