wanikani-api-js is a simple JavaScript WaniKani API wrapper.
- Node
To install wanikani-api-js simply run:
npm install wanikani-api-js
in your project folder.
To run the test a few changes need to be done.
- Open the
config.json
in thetests
folder - The WaniKani AuthToken can also be set in
config.json
or later as a parameter in the test command.
The tests can then be run via:
npm test
or
npm test -- --authToken=<Your WaniKani Auth Token>
in case the auth token was not already set in the config.json
;
const WaniKaniApi = require('wanikani-js-api').WaniKaniApi;
const wanikani = new WaniKaniApi(apiToken);
wanikani.authToken = '<api_token_here>';
async function printUserData() {
const user = await wanikani.getUser();
const userData = await user.asUserData();
console.log(userData);
}
printUserData();
import {WaniKaniApi} from 'wanikani-js-api';
class WaniKaniApiSample {
public wanikani: WaniKaniApi = new WaniKaniApi();
wanikani.authToken = '<api_token_here>';
public async printUserData() {
const user: JSON = await this.wanikani.getUser()
const userData: JSON = await user.asUserData()
console.log(userData);
}
}
const waniKaniApi: WaniKaniApi = new WaniKaniApiSample();
waniKaniApi.printUserData();
-
endpoint
- The WaniKani api endpoint
- Type: string
- Get & Set
- Default:
https://api.wanikani.com/v2/
-
authToken
- The WaniKani AuthToken
- Type: string
- Get & Set
- Default: Not set.
-
configService
- The service where all configs are stored
- Type: ConfigService
- Get & Set
- WaniKaniApi(authToken?: string)
- Parameters
- authToken [optional]
- The WaniKani AuthToken
- Type: string
- authToken [optional]
- Parameters
- getUser(): Promise
-
Parameters
-
Returns
- A Promise containing user
- Type: IUser
- A Promise containing user
-
- Owner(configService?: ConfigService)
- Parameters
- configService [optional]
- A custom configService
- Type: ConfigService
- configService [optional]
- Parameters
- asJson(): Promise
-
Parameters
- None
-
Returns
- A promise containing the data of the owner
- Type: JSON
- A promise containing the data of the owner
-
A WaniKani User.
- User(configService?: ConfigService)
- Parameters
- configService [optional]
- A custom configService
- Type: ConfigService
- configService [optional]
- Parameters
- asUserData(): Promise
-
Parameters
- None
-
Returns
- A promise containing the data of the user
- Type: IUserData
- A promise containing the data of the user
-
- โจ Add Basic Support for Users
- โจ Add ConfigService
- โจ Add HttpClient
- โจ Add Declarations
- โจ Add Registry
- โจ Add Interfaces
- โ Add Tests
- ๐ท Add Types