@mokoko/sdk
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

@mokoko/sdk

Unofficial SDK of Lostark Open API

Installation

yarn add @mokoko/sdk

Usage (Node.js)

import { getSDK } from "@mokoko/sdk";
import { fetch } from "node-fetch";

const sdk = getSDK({
  fetchFn: fetch,
  apiKey: "your_api_key",
});

sdk.getNews().then((news) => console.log(news));

Throttling

import { getSDK } from "@mokoko/sdk";
import { fetch } from "node-fetch";

const sdk = getSDK({
  fetchFn: fetch,
  apiKey: "your_api_key",
  limit: 100, // Rate limit of your client
});

async function run() {
  const results = await Promise.all(
    MANY_AUCTION_REQUESTS.map((req) => sdk.auctionsGetItems(req))
  ); // Async operations are throttled through SDK.

  // do something...
}

getSDK() options

export interface SdkProps {
  /**
   * Fetch function for isomorphic usage.
   */
  fetchFn:
    | ((url: string, init?: RequestInit) => Promise<Response>)
    | ((url: string, init?: NodeRequestInit) => Promise<NodeResponse>);

  /**
   * API Key from Lostark Open API Developer Portal.
   */
  apiKey: string;

  /**
   * API Rate limit for throttling
   * @default 100
   */
  limit?: number;

  /**
   * Maximum retry attempt on 429 error
   * @default 3
   */
  maxRetry?: number;

  /**
   * Reporter for logging usage.
   */
  reporter?: Reporter;
}

Readme

Keywords

none

Package Sidebar

Install

npm i @mokoko/sdk

Weekly Downloads

5

Version

0.0.6

License

MIT

Unpacked Size

46.2 kB

Total Files

54

Last publish

Collaborators

  • icepeng