0.0.6 • Published 2 years ago

@mokoko/sdk v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@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;
}
0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

3 years ago

0.0.1

3 years ago