How to filter subjects by if its been learned in api v2?

Trying to fix some of my scripts after v1 deprecation. Looking at the api, I don’t see anyway to filter out subjects that have not been learned yet. How can I achieve this?

1 Like

I hope you don’t mind, but I’ve moved this to the API section, since that’s more appropriate.

As for your question, I’m afraid I’m not an API expert, but looking through the documentation you might find this helpful: https://docs.api.wanikani.com/20170710/#assignment-data-structure

Depending on what you’re trying to do, you could call the API for the values started_at (which will return a non-null timestamp value if you’ve done the lesson for a subject) or passed_at (which will do likewise if you’ve Guru’d the item)

An item that is still locked can be queried with unlocked_at and will give a null value if it’s locked and you can use passed_at and filter items with a null value to find items that you’ve done the lesson for, but haven’t Guru’d (if I’m reading right)

If you are writing a regular userscript I recommend that you make use of the Wanikani Open Framework (WKOF)

With WKOF your script will be faster (no fetching through the API since WKOF caches items), easier to develop (WKOF is very handy), and have a lower load on WK.

Fetching all items that a user has not yet learned is as easy as this. Just fetch items with a filter for locked items (SRS level -1 in WKOF) and initiate items (SRS level 0)

wkof.include('ItemData');
wkof.ready('ItemData')
    .then(fetch_items)
    .then(do_stuff);

function fetch_items() {
     return wkof.ItemData.get_items({
        wk_items: {
            options: {assignments: true,}, 
            filters: {srs: [-1, 0],},
        },
    });
}

function do_stuff(items) {
    // Do stff
}
3 Likes

Annnnnd this is why I move this to API, for that kind of useful feedback and a noob like me can’t offer :smiley:

1 Like