Question on retrieving kanji through API

So I’m trying to pull a list of kanji through the API by this uri https://api.wanikani.com/v2/assignments?subject_types=kanji and I wrote the results to a JSON file.

So in the file is there a way for me to get in text the kanji itself that each entry represents??
Like ID: 123456== 寒 or whatever?

You should retrieve and cache the kanji through the Subjects endpoint and then cross reference the subject_id from the assignments endpoint. That is assuming you actually want the data from the assignments endpoint, otherwise you can just use the subjects endpoint.

4 Likes

Alternately, just GET https://api.wanikani.com/v2/subjects/1234 for an individual subject. You’ll need to provide a bearer token for authorization. See the docs for more information.

It returns the UTF-8 encoding in the characters attribute. For the 1234 example, it returns the following:

{
    "id": 1234,
    "object": "kanji",
    "url": "https://api.wanikani.com/v2/subjects/1234",
    "data_updated_at": "2022-05-05T14:40:22.352065Z",
    "data": {
        "created_at": "2012-12-06T03:53:25.532898Z",
        "level": 24,
        "slug": "視",
        "hidden_at": null,
        "document_url": "https://www.wanikani.com/kanji/%E8%A6%96",
        "characters": "視",
        "meanings": [
            {
                "meaning": "Look At",
                "primary": true,
                "accepted_answer": true
            }
        ],
        "auxiliary_meanings": [],
        "readings": [
            {
                "type": "onyomi",
                "primary": true,
                "reading": "し",
                "accepted_answer": true
            },
            {
                "type": "kunyomi",
                "primary": false,
                "reading": "み",
                "accepted_answer": false
            }
        ],
        "component_subject_ids": [
            80,
            91
        ],
        "amalgamation_subject_ids": [
            4707,
            4710,
            4711,
            4712,
            4713,
            5430,
            8189
        ],
        "visually_similar_subject_ids": [
            1223,
            857,
            1191,
            770
        ],
        "meaning_mnemonic": "When you <radical>see</radical> a <radical>spirit</radical> you have to <kanji>look at</kanji> it. Look at it directly, because if you look away then it could disappear.",
        "meaning_hint": "Look at the spirit. Look at its shape and into its eyes. Just don't look away.",
        "reading_mnemonic": "You <kanji>look at</kanji> the spirit for as long as you can, until you hear a <reading>shee</reading>p (<ja>し</ja>) sound. You look away for a second, see the sheep look at you, and when you look back the spirit is gone. Damn!",
        "reading_hint": "Now you have to look at this sheep. Maybe the sheep was projecting the spirit... or maybe it's just a sheep. You'll have to look at it a bit longer to know for sure.",
        "lesson_position": 24,
        "spaced_repetition_system_id": 1
    }
}
4 Likes