@bachman-dev/wanikani-api-types - v2.0.0
    Preparing search index...

    Class ApiRequestFactory

    A factory for preparing requests to the WaniKani API, with methods that return an ApiRequest that can be used in any HTTP library/package to make the request.

    Index

    Constructors

    Properties

    assignments: {
        get: (
            idOrParams?: SafeInteger | AssignmentParameters,
            options?: ApiRequestOptions,
        ) => ApiRequest;
        start: (
            assignmentId: SafeInteger,
            payload: AssignmentPayload,
            options?: ApiRequestOptions,
        ) => ApiRequest;
    } = ...

    Types of Assignment Requests available in the WaniKani API.

    Type declaration

    baseUrl: "https://api.wanikani.com/v2"

    The base URL of the WaniKani API

    levelProgressions: {
        get: (
            idOrParams?: SafeInteger | CollectionParameters,
            options?: ApiRequestOptions,
        ) => ApiRequest;
    } = ...

    Types of Level Progression Requests available in the WaniKani API.

    Type declaration

    resets: {
        get: (
            idOrParams?: SafeInteger | CollectionParameters,
            options?: ApiRequestOptions,
        ) => ApiRequest;
    } = ...

    Types of Reset Requests available in the WaniKani API.

    Type declaration

    reviews: {
        create: (
            payload: ReviewPayload,
            options?: ApiRequestOptions,
        ) => ApiRequest;
        get: (
            idOrParams?: SafeInteger | ReviewParameters,
            options?: ApiRequestOptions,
        ) => ApiRequest;
    } = ...

    Types of Review Requests available in the WaniKani API.

    Type declaration

    reviewStatistics: {
        get: (
            idOrParams?: SafeInteger | ReviewStatisticParameters,
            options?: ApiRequestOptions,
        ) => ApiRequest;
    } = ...

    Types of Review Statistic Requests available in the WaniKani API.

    Type declaration

    spacedRepetitionSystems: {
        get: (
            idOrParams?: SafeInteger | CollectionParameters,
            options?: ApiRequestOptions,
        ) => ApiRequest;
    } = ...

    Types of Spaced Repetition System (SRS) Requests available in the WaniKani API.

    Type declaration

    srs: {
        get: (
            idOrParams?: SafeInteger | CollectionParameters,
            options?: ApiRequestOptions,
        ) => ApiRequest;
    } = ...

    An alias for Spaced Repetition System requests.

    Type declaration

    studyMaterials: {
        create: (
            payload: StudyMaterialCreatePayload,
            options?: ApiRequestOptions,
        ) => ApiRequest;
        get: (
            idOrParams?: SafeInteger | StudyMaterialParameters,
            options?: ApiRequestOptions,
        ) => ApiRequest;
        update: (
            studyMaterialId: SafeInteger,
            payload: Partial,
            options?: ApiRequestOptions,
        ) => ApiRequest;
    } = ...

    Types of Study Material Requests available in the WaniKani API.

    Type declaration

    subjects: {
        get: (
            idOrParams?: SafeInteger | SubjectParameters,
            options?: ApiRequestOptions,
        ) => ApiRequest;
    } = ...

    Types of Subject Requests available in the WaniKani API.

    Type declaration

    summary: { get: (options?: ApiRequestOptions) => ApiRequest } = ...

    Types of Summary Requests available in the WaniKani API.

    Type declaration

    • get: (options?: ApiRequestOptions) => ApiRequest

      Get a summary of a user's available and upcoming lessons/reviews from the WaniKani API.

      A TypeError if trying to set type-checked request headers.

    user: {
        get: (options?: ApiRequestOptions) => ApiRequest;
        updatePreferences: (
            payload: UserPreferencesPayload,
            options?: ApiRequestOptions,
        ) => ApiRequest;
    } = ...

    Types of User Requests available in the WaniKani API.

    Type declaration

    voiceActors: {
        get: (
            idOrParams?: SafeInteger | CollectionParameters,
            options?: ApiRequestOptions,
        ) => ApiRequest;
    } = ...

    Types of Voice Actor Requests available in the WaniKani API.

    Type declaration

    Methods

    • Add additional custom headers to be used in all requests generated by the factory.

      Parameters

      • headers: Record<string, string>

        An object containing HTTP headers and their values.

      Returns this

      The factory, with the added custom headers.

      A TypeError if trying to set type-checked request headers.

    • Sets a new WaniKani API Revision to use in requests returned by the factory.

      Parameters

      • revision: "20170710"

        The WaniKani API Revision to use.

      Returns this

      The factory, with the newly set WaniKani API Revision.

      A valibot!ValiError if the WaniKani API Revision is invalid.

    • Sets a new WaniKani API Token to use in requests returned by the factory.

      Parameters

      • token: string

        The new WaniKani API Token to use.

      Returns this

      The factory, with the newly set WaniKani API Token.

    • Sets the custom headers for all requests gerated by the factory to those passed to this function, removing any previously set custom headers, and keeping API Revision and Token settings.

      Parameters

      • headers: Record<string, string>

        An object containing HTTP headers and their values.

      Returns this

      The factory, with the only custom headers being those passed to this function.

      A TypeError if trying to set type-checked request headers.