# How to get SRS stats with V2 API?

**URL:** <https://community.wanikani.com/t/how-to-get-srs-stats-with-v2-api/43146>\
**Category:** API And Third-Party Apps\
**Created:** [April 15, 2020, 2:15pm UTC](https://community.wanikani.com/t/how-to-get-srs-stats-with-v2-api/43146 "2020-04-15T14:15:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MZetko](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/mzetko/32/43042_2.png) [@MZetko](https://community.wanikani.com/u/MZetko)\
**Post date:** [April 15, 2020, 2:15pm UTC](https://community.wanikani.com/t/how-to-get-srs-stats-with-v2-api/43146/1 "2020-04-15T14:15:09Z")

</div>

I would like to display user’s current SRS stats (the count of Apprentice, Guru, Master, Enlightened and Burned items on the user dashboard) with the new V2 API, is that possible in an efficient manner?

---

<div class="post-metadata">

**Author:** ![razorcat](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/razorcat/32/187649_2.png) [@razorcat](https://community.wanikani.com/u/razorcat)\
**Post date:** [April 15, 2020, 2:42pm UTC](https://community.wanikani.com/t/how-to-get-srs-stats-with-v2-api/43146/2 "2020-04-15T14:42:41Z")

</div>

There isn’t a simple getter for SRS totals (although it would be really convenient if the `srs_stages` endpoint added an item\_total property…), so what I ended up doing for [my userscript](https://community.wanikani.com/t/userscript-yet-another-wk-dashboard-individual-srs-totals/37373) was having to loop through all items and accumulate counters for each SRS stage.

```javascript
const wkSRSTotals = [0, 0, 0, 0, 0, 0, 0, 0, 0];
const config = {
    wk_items: {
        options: {assignments: true}
    }
};
window.wkof.ItemData.get_items(config).then((processItems) => {
    for (let item of processItems) {
        const srsLevel = item && item.assignments && item.assignments.srs_stage;
        if (srsLevel != null) {
            wkSRSTotals[srsLevel - 1]++;
        }
    }
})

```

I’m using the open framework API wrappers here for userscript convenience, but you could technically implement the same logic using the base API in any language…

---

<div class="post-metadata">

**Author:** ![Kumirei](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/kumirei/32/480522_2.png) [@Kumirei](https://community.wanikani.com/u/Kumirei)\
**Post date:** [April 15, 2020, 2:50pm UTC](https://community.wanikani.com/t/how-to-get-srs-stats-with-v2-api/43146/3 "2020-04-15T14:50:13Z")

</div>

Could also use the `.get_index()` method.

```javascript
wkof.ItemData.get_items('assignments')
    .then(items => wkof.ItemData.get_index(items, 'srs_stage'))
    .then(breakdown => {
        // Do stuff
});

```

---

<div class="post-metadata">

**Author:** ![sansarret](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/sansarret/32/370654_2.png) [@sansarret](https://community.wanikani.com/u/sansarret)\
**Post date:** [April 15, 2020, 8:08pm UTC](https://community.wanikani.com/t/how-to-get-srs-stats-with-v2-api/43146/4 "2020-04-15T20:08:03Z")

</div>

Not sure which API version does it use, but this script does it plus shows leaches:

> [@\[Userscript\] WaniKani Dashboard SRS and Leech Breakdown](https://community.wanikani.com/t/userscript-wanikani-dashboard-srs-and-leech-breakdown/32756/):
>
> warning This is a third-party script/app and is not created by the WaniKani team. By using this, you understand that it can stop working at any time or be discontinued indefinitely. What is it? This script updates the dashboard to display SRS breakdown and leech information. It is a replacement of most of the functionality in this [no-longer-supported script](https://community.wanikani.com/t/unsupported-dashboard-userscript-leech-apprentice-and-guru-detail-aka-srs-level-progress/19353). It uses the same leech formula as the one from that script, which is also the same formula used in the [Leech Training filter](https://community.wanikani.com/t/userscript-wanikani-open-framework-additional-filters-recent-lessons-leech-training-related-items-and-more/30512). Before: …

---

<div class="post-metadata">

**Author:** ![seanblue](https://sea1.discourse-cdn.com/wanikanicommunity/user_avatar/community.wanikani.com/seanblue/32/579844_2.png) [@seanblue](https://community.wanikani.com/u/seanblue)\
**Post date:** [April 15, 2020, 8:14pm UTC](https://community.wanikani.com/t/how-to-get-srs-stats-with-v2-api/43146/5 "2020-04-15T20:14:52Z")

</div>

That uses API v2 through the Open Framework.
