npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@loongship-kit/data

v0.1.1

Published

Pure frontend SDK for Loongship data APIs.

Readme

@loongship-kit/data

Pure frontend TypeScript SDK for Loongship data APIs.

Install

pnpm add @loongship-kit/data

Client call

import lsData from "@loongship-kit/data";

const client = lsData.create({
  key: "your-user-key"
});

const res = await client.ship.search({
  kw: "cosco",
  max: 10
});

Per-request key overrides the client default:

params.key > client key

For baseURL, timeout, and headers, precedence is:

request options > client defaults

Hooks are client-scoped too:

const client = lsData.create({
  key: "your-user-key",
  hooks: {
    async onRequest(context) {
      return {
        ...context,
        requestOptions: {
          ...context.requestOptions,
          headers: {
            ...context.requestOptions.headers,
            "X-Trace-Id": crypto.randomUUID()
          }
        }
      };
    }
  }
});

API Modules Reference

The SDK is organized into several modules. Each module provides specific data queries through the client instance.

| Client Path | Description | Available Methods | |---|---|---| | client.ship | 船舶查询 (Ship) | search, detail, batchGet, area, nearby, archive | | client.typhoon | 台风查询 (Typhoon) | list, history, current, currentByName | | client.track | 轨迹查询 (Track) | query, full | | client.weather | 气象数据 (Weather) | current, forecast, rawDownload | | client.port | 港口数据 (Port) | callByShip, callByPort, callByShipPort, currentStatus | | client.push | 订阅推送 (Push) | updateShips, setCallbackUrl | | client.area | 区域数据 (Area) | create, list, delete, update | | client.tide | 潮汐数据 (Tide) | portSearch, record |

Note: All related parameter types and response data types are exported directly (e.g., TyphoonListParams, TyphoonListData).

Response

Successful requests return a normalized response:

{
  code: 0,
  data: []
}

To include the original raw payload:

const client = lsData.create({ key: "your-user-key" });

const res = await client.ship.search(
  { kw: "cosco" },
  { raw: true }
);

console.log(res.raw);

Mock mode

For demos or frontend integration, you can enable mock mode per request:

const client = lsData.create({ key: "your-user-key" });

const res = await client.ship.search(
  { kw: "cosco" },
  { mock: true }
);

It also works with SDK instances:

const weather = await client.weather.current(
  { lon: 121000000, lat: 31000000 },
  { mock: true, raw: true }
);

console.log(weather.raw);

Mock mode returns randomized type-shaped demo data and skips the real HTTP request. It is intended for UI demos only, so the returned content is not stable or business-accurate. signal still works in mock mode, while timeout is ignored because no network request is sent.

Interception and errors

If no hook handles them:

  • business errors throw LoongshipApiError
  • network / timeout / HTTP errors also throw LoongshipApiError
import lsData, { LoongshipApiError } from "@loongship-kit/data";

const client = lsData.create({ key: "your-user-key" });

try {
  await client.ship.search({ kw: "cosco", key: "bad-key" });
} catch (error) {
  if (error instanceof LoongshipApiError) {
    console.log(error.code, error.message);
  }
}

The SDK may also throw:

  • MissingApiKeyError when no usable key is available
  • CanceledError when a request is aborted via AbortController

To intercept request lifecycle for one client, use:

  • hooks.onRequest
  • hooks.onResponse
  • hooks.onError

Cancel request

const controller = new AbortController();

const promise = client.ship.search(
  { kw: "cosco" },
  { signal: controller.signal }
);

controller.abort();

Documentation

Generate and preview the VitePress documentation locally:

pnpm run docs:dev

To build the static HTML site:

pnpm run docs:build