WkApi - A Standard Javascript API

Hey guys.

Recently, I’ve noticed that web applications or extensions that interact with Wanikani’s API all use their own implementations of interaction. What this means is that any time someone wants to create a new web-based application, they need to either copy someone else’s code and finangle it to work with their own apps, or reinvent the wheel.

So, as a Typescript learning exercise to myself, and as a service to others, I have written a self-contained library that will handle all facets of interaction with the Wanikani API, include JSONP requests, caching, throttling, and more. The library has no external dependencies, except perhaps an ES6 Promise polyfill.

In order to use this library, one simply instantiates a WkApi object with the user’s API Key, and gets access to all types of API information.

Please take a look.

WkApi on Github


I am open to suggestions or improvements. I am by no means an experienced library developer (all my time has been on discrete projects), and this is my first foray into writing open-source software.

Outstanding!

I’m also on the Typescript-Angular-SPA learning train these days. I want to create an application that will help me pick apart tweets in Japanese, which will lean heavily on the Wanikani API for subscribers. This will help quite a bit!

Amazing work! Will try it out later. The docs look to be well written as well, which is always welcome.

Sweet! I always wished we had something like this. I’ll definitely check this out.

I’ve no idea what this means, but it sounds impressive!

Oh this is sweet. Will definitely check it out! Thanks for doing this :

Nice  :-)

I’m working on a framework with a similar concept (eliminating the reinvent-the-wheel), but for higher-level functionality, and mine is more of a shared-library, rather than static-linked.  So, you load the framework as a standalone userscript, and client scripts can access its functionality via an interface object attached to ‘window.wkdata’.  That way, you only have one instance of the framework, and is prevents duplicate API calls from different scripts (i.e. results from API calls are cached and shared among all scripts that ask for it).

Development is on hold for another week or so, though.  We have an exchange student (Japan) that is returning home soon, and we want to spend as much time with her as we can before she leaves.  After that, I’m gonna go hog-wild on script development :slight_smile:

EDIT:  Side question… how widely adopted is native Promise nowadays?  I’m using jquery’s Deferred interface myself.

For Promises, I believe they are supporter in most modern browsers, but the polyfill is also very small.

I wanted to avoid libraries for file size purposes, but also because jQuery deferreds have a host of issues.

But awesome, we need more vehicles for WK development out there.

Update:

v1.1.0

  • Default max levels per request changed to 20 to be a multiple of level 60.
  • Refactored to properly use Promises instead of antipatterns everywhere. This cut code size considerably.
  • Beginning to refactor to use more functional methods.


Blimey. This is great.

I completely missed this when you first posted it.

Thanks for sharing your work.

This is awesome!!! How long did this take you to do? I’m a noob programmer so I have no concept of how long projects take =/. Sorry!

ecchash said... This is awesome!!! How long did this take you to do? I'm a noob programmer so I have no concept of how long projects take =/. Sorry!
 This was probably two days of spare-time dev, but I've been at this for many years. At first, it'll feel like you're beating on a brick wall, only sometimes making progress through it. But that's also the best way to learn--decide what you want to make, and just keep going until you have. Then remake it as you learn new techniques.

Neato!