API [How to get lessons info]

I’m writting a small React app to self study some materials. Usually study materials dissapear after doing them, so I’ve ended up thinking about having a very simple page with study materials (/subjects in the api) so I can re-study stuff from older levels up to my current level. Here’s a few questions:

1-If I want to request all the items (radical, kanji and vocab) I can currently review from a specific level I need to request the assignments and then take each subject id?

-Assignments : api.wanikani.com/v2/assignments?levels=12&in_review=true
-Subjects: api.wanikani.com/v2/subjects?ids=(all the ids I’ve got from the previous call)

2-Can I get study materials by date that they were “previously” studied, for example, to get all the materials from last week or this month?. Should I follow the same logic to get the assignments but using a date filter (started_at)?

Felipe F

I would recommend just fetching all of the /subjects and caching them, then each time you start your app (or maybe once a day), do a /subjects query with the ‘after’ parameter set to the timestamp of the last update. That will keep your cache up to to date. And it will be much faster to just look through your cache to filter on a specific level.

When you say “by date that they were previously studied”, do you mean the last review timestamp? Or do you mean when an item’s lesson was done

1 Like

@rfindley thank you for your answer. I will look into caching I’ve read the api docs and they suggest doing it. Regarding the questions you’ve made, I mean any item that’s been already done as a lesson, so if I’m in level 13 already but I haven’t studied any items yet , I should not see any item. But if i’ve done 20 lesson items I should see those 20

Are you using something like indexeddb (or a library like Dexie?) to cache the requests?. It seems quite tricky to store the huge nested objects from each request that the api returns

Yes, Open Framework uses indexeddb. It keeps track of the date of the last query, and queries the API for any changes since that date. The response is then merged into the cached data, and the cache is updated.


Can you get Open framework as a dependency on NPM?. I’m building a small React app

1 Like

I’m not familiar enough with writing NPM modules to be of much help there. You are welcome to write a wrapper, clone the Open Framework, or whatever seems fitting or desirable, though.

1 Like