API V2 Beta Documentation

I know the docs don’t show it yet, but does /reviews have any filters for starting_srs_stage or ending_srs_stage?

A week or so ago, someone was asking about a way to track lessons (as opposed to reviews). I’m assuming starting_srs_stage==0 represents lessons, right?

There are no filters yet. Can’t imagine a use for it under the endpoint, but maybe someone can make the case for it.

There are no starting_srs_stage == 0 since as you have pointed out is Lessons. A completed lessons doesn’t get logged under /review. To track lessons you would look at /assignment under started_at. started_at gets timestamped when the user completes the lesson for the subject. unlocked_at is when the subject is made available to lessons.

Ahh, okay. I saw a reference to srs==0 as “Initiate” somewhere… maybe on the docs-in-progress on github under /assignments? I don’t remember.

Ahh yeah. For an assignment resource, you’ll see srs_stage: 0. But it isn’t active for lessons until the unlocked_at gets timestamped.

If the 0 is listed under /review as a possible option, I’ll need to update the doc. starting_srs_stage and ending_srs_stage can be anything between 1 through 9

1 Like

Looks like the /subjects endpoint still expects an array for ids and returns 422 for a comma-delimited string. Is this an oversight perhaps?

Not sure if there are other endpoints/parameters like this. I haven’t tested yet.

EDIT: It also looks like it only returns a single item given an array of ids.

Is there a reason for the inconsistency with character in radical and kanji subjects and characters in vocabulary subjects?

Can you post the url and headers? I am not seeing the issue. Our tests cover this as well, so it would have failed…

Here is what I did,

curl "https://www.wanikani.com/api/v2/subjects?ids=1,2,3" \
  -H "Authorization: Bearer viets_api_key_here"

which yielded a 200 and…

{"object":"collection","url":"https://www.wanikani.com/api/v2/subjects?ids=1%2C2%2C3","pages":{"per_page":1000,"next_url":null,"previous_url":null},"total_count":3,"data_updated_at":"2017-06-12T23:21:17.334581Z","data":[{"id":1,"object":"radical","url":"https://www.wanikani.com/api/v2/subjects/1","data_updated_at":"2017-06-12T23:21:17.248393Z","data":{"level":1,"created_at":"2012-02-27T18:08:16.000000Z","slug":"ground","document_url":"https://www.wanikani.com/radicals/ground","character":"一","character_images":[],"meanings":[{"meaning":"Ground","primary":true}]}},{"id":2,"object":"radical","url":"https://www.wanikani.com/api/v2/subjects/2","data_updated_at":"2017-06-12T23:21:17.292652Z","data":{"level":1,"created_at":"2012-02-27T18:11:07.000000Z","slug":"fins","document_url":"https://www.wanikani.com/radicals/fins","character":"ハ","character_images":[],"meanings":[{"meaning":"Fins","primary":true}]}},{"id":3,"object":"radical","url":"https://www.wanikani.com/api/v2/subjects/3","data_updated_at":"2017-06-12T23:21:17.334581Z","data":{"level":1,"created_at":"2012-02-27T18:12:15.000000Z","slug":"drop","document_url":"https://www.wanikani.com/radicals/drop","character":"丶","character_images":[],"meanings":[{"meaning":"Drop","primary":true}]}}]}

The rationale is radical and kanji only consist of one single character and vocabulary can consist of multiple characters. Semantics, I suppose. I will bring this one up with @oldbonsai.

Alright. I just ran a request with 5 ids and it worked. Something like this, however, fails with 422:

https://www.wanikani.com/api/v2/subjects?ids=2896,2895,8697,2890,2889,641,625,2865,2864,2863,2862,2861,2860,2859,2857,2846,2918,2917,7733,7674,2916,2884,2856,2855,2854,7527,642,634,618,2913,2912,2911,2914,7618,2888,2887,2886,2885,2883,2882,2881,629,7451,2901,644,616,619,632,617,7732,7566,2850,2849,2848,2847,643,7482,2853,2852,2851,851,630,623,3522,2899,2898,2897,645,2867,2866,611,633,2841,2840,2777,2776,2775,2774,2773,2772,3648,3647,2799,2798,2797,142,144,143,141,139,137,138,136,135,134,133,132,130,129,127,128,131,156,212,609,626,615,620,628,627,621,637,624,610,631,638,607,622,612,635,608,613,3439,7524,7456,3444,3441,3446,3415,3411,2661,3442,2717,3440,7477,3445,3443,636,614,639,640,3418,3419,56,8696,2793,2792,2791,2790,2789,2788,2787,2813,2812,2811,2810,2809,2805,7523,2834,2764,2756,2748,2747,7672,2842,2778,2802,2767,2751,8661,7670,7730,596,568,589,571,581,2721,123,7617,570,2679,2659,503

I see. Thought it could be that. But well, erm…

var character: String? = null
var characters: String? = null

and usage in code would be like

if (vocabulary) {
    text = item.characters
} else {
    text = item.character
}

…or something. Sure, I could write an extension function/field, but well, is it really worth this? Don’t think so.

Yeah, I understand that. Will bring it up. Internally we just use characters for everything. So I am scratching my head on this one now. Although, you’d probably want to check for type anyway if you plan on using the unique fields for the subject anyhow (like character_images on radical).

1 Like

Yeah, I’ll be handling the character_images thing. But that’s just if (character_images.isNotEmpty()) useImage() else useCharacter().

This one has to do with a size limit validated on filters which can take in delimited values. It is set to 128 at the moment. On the 422, did you receive a JSON response with the error message?

Think we’ll need to revisit the decision on this one as well. Will update once we do.

1 Like

Oh, right, you do! I somehow totally missed this in my log…

{
  "error": "The ids parameter can only have 128 members"
}

Sorry about that.

1 Like

Upcoming changes

  • Subject resources of type radical and kanji will have the field character renamed to characters for consistency with other types. Note this is a breaking change, so be prepared for this
  • We are lifting the delimited string size limit on filters. You’ll receive a HTTP 414 if the URL length is too long (server limitation). If this becomes a performance issue, we may reemploy a limit.
  • Page size defaults are being reduced from 1,000 to 500. However /subjects and /reviews will stay at 1,000
  • Character images for subject radical resources are coming. They’ll be the primary visual representation of the radical and characters is secondary if the unicode exists. We’ll share the SVG, and PNG of various sizes. Thanks to @rfindley for taking on the project of creating the SVGs. Very professional to deal with and does great work.
4 Likes

Would it be possible to have a filter for /assignments like started with a boolean value?

Yep. We’ll add unlocked and started to complete the timestamp filters. Will squeeze it in with the other updates.

1 Like

Changes which are now live:

  • assignment_ids filter on /reviews
  • character on subject resource types radical and kanji has been renamed to characters
  • On filters which accepts a delimited string list, there is no longer a size limit. There is however a URL length limit (this is a server limitation; a HTTP 414 will return).
  • Page size limit defaults changed from 1000 to 500. Exceptions are /reviews and /subjects which are still set to 1000.
  • started and unlocked boolean filters added to /assignments

I reallz hope that you do not kill of v1 as there are so many third party websites as well scripts no longer getting updated relzing on it

1 Like

They said there will be a grace period (maybe four months) but it will be deleted eventually.