Help Using the API?

I’m using Swift to access the WaniKani API, and I have been reading the documentation for a while but I’m not quite understanding how I would actually get the reviews that are available, or how I would tell Wanikani that I completed the reviews.

I have no problem accessing simple data like the number of lessons or reviews available, but beyond that I’m stuck.

This is with v1.4 api. Also tried v2 but didn’t have any luck.

I apologize if this is stated elsewhere, I searched a bit but didn’t find much.

You cannot modify data with v1.4. Only with v2 can you modify data, and only then if your API token has write access enabled. I can’t really help beyond that.

Hmm okay, there are some apps on the app store that basically just show the web page inside the app, and that’s fine, but there is another app that is a completely custom app.

I tried to use API v2 but I didn’t really see a way to do it there either. It might be that I didn’t understand all the terminology.

I think that app was created before APIv2 added write support, so it might have (at least originally) used private/unsupported endpoints.

I’m going to move this topic to #wanikani:api-and-third-party-apps. There’s also a dedicated thread there for the APIv2 beta, so if you don’t get any useful responses in this thread maybe you can ask there.

Hey, godspeed getting your iOS project up and running.

First, definitely use the v2 API so that you can POST user answers to the WaniKani backend.

Second, it is possible. Something that isn’t entirely explained in the documentation is that there is not a one-to-one relationship with a view that you see on the web and a corresponding backing data model. Multiple data types are combined in advance to create the lesson or review screen that you’re familiar with. Confusingly, a Review for the backend just means a data type that tracks user-submitted answers not a “review” that contains meanings, readings, ect. This could have been better named in my opinion. Eventually you will become one with the data model spec and you’ll know what I mean. If you are interested in reactive programming like RxSwift, this is project is a good candidate to transform data types.

You can take a look at my last post to see how this turned out for my Android version.

Good luck!

1 Like

https://docs.api.wanikani.com/20170710/

To get the reviews available, you would use the assignments endpoint with the available_before filter set to the current time (WaniKani API Reference). Alternatively, you could use the summary endpoint, focusing on reviews available currently (WaniKani API Reference - there should be enough information included to work this out).

Extract the subject_id out of each entry, and use that with the ids filter on the subjects endpoint (you can separate each ID with a comma) to get the subjects to be reviewed, and the answers to compare to (WaniKani API Reference). You’ll need to do the checks locally, since the POST review endpoint only takes the end results.

Finally, one a subject is completed, send a POST request to the reviews endpoint with the relevant information (WaniKani API Reference)

3 Likes

This was extremely helpful, so thank you for explaining. Sorry I did not reply right away, but I messed around with it a little more each day. Summary endpoint worked for me, since I’ll probably use the other information that comes with that. I’m currently working on getting all the json data for each review into a class and then I’ll finally actually be able to do something with all the information.

Still a ways to go to get the functionality of this app working, but I have a cool idea and I’m excited to make it so I can show others who might use a WaniKani iOS app.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.