Giter VIP home page Giter VIP logo

wanikani-js-api's Introduction

wanikani-api-js

NPM

Overview

wanikani-api-js is a simple JavaScript WaniKani API wrapper.

Getting Started

Prerequisites

  • Node

Installation

To install wanikani-api-js simply run:

npm install wanikani-api-js

in your project folder.

Running the Tests

To run the test a few changes need to be done.

  1. Open the config.json in the tests folder
  2. 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;

Usage

JavaScript

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();

TypeScript

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();

Documentation

WaniKani

Variables

  • endpoint

    • The WaniKani api endpoint
    • Type: string
    • Get & Set
    • Default: https://api.wanikani.com/v2/
  • authToken

  • configService

    • The service where all configs are stored
    • Type: ConfigService
    • Get & Set

Constructor

  • WaniKaniApi(authToken?: string)

Functions

  • getUser(): Promise
    • Parameters

    • Returns

      • A Promise containing user
        • Type: IUser

Owner [abstract]

Constructor

  • Owner(configService?: ConfigService)
    • Parameters
      • configService [optional]
        • A custom configService
        • Type: ConfigService

Functions

  • asJson(): Promise
    • Parameters

      • None
    • Returns

      • A promise containing the data of the owner
        • Type: JSON

User [extends Owner]

A WaniKani User.

Constructor

  • User(configService?: ConfigService)
    • Parameters
      • configService [optional]
        • A custom configService
        • Type: ConfigService

Functions

  • asUserData(): Promise
    • Parameters

      • None
    • Returns

      • A promise containing the data of the user
        • Type: IUserData

Changelog

v0.1.0

  • โœจ Add Basic Support for Users
  • โœจ Add ConfigService
  • โœจ Add HttpClient
  • โœจ Add Declarations
  • โœจ Add Registry
  • โœจ Add Interfaces
  • โœ… Add Tests
  • ๐Ÿท Add Types

wanikani-js-api's People

Contributors

cbodtorf avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.