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

@lyng/sdk

v1.0.1

Published

Official JavaScript SDK for the Lyng URL shortener API

Readme

@lyng/sdk

Official JavaScript / TypeScript SDK for the lyng URL shortener API.

npm version license

Installation

npm install @lyng/sdk

Requires Node.js v18 or later. Ships with TypeScript declarations — no @types package needed.

Quick start

import Lyng from '@lyng/sdk'

const lyng = new Lyng({ apiKey: process.env.LYNG_API_KEY! })

const { shortUrl } = await lyng.links.create({ url: 'https://example.com' })
console.log(shortUrl) // https://lyng.my.id/abc123

Getting an API key

  1. Sign up at lyng.my.id
  2. Go to Dashboard → Developer
  3. Create a project and click Create key

Your key starts with lk_ and is shown only once — save it somewhere safe.

Store it as an environment variable rather than hardcoding it:

# .env
LYNG_API_KEY=lk_your_key_here

Reference

lyng.links.create(options)

Shortens a URL and returns the new short link.

const { shortUrl, slug } = await lyng.links.create({
  url: 'https://example.com',
})

Options

| Field | Type | Required | Description | |--------|----------|----------|-------------| | url | string | Yes | The URL to shorten. Must start with http:// or https://. | | slug | string | No | Custom slug for the short link (e.g. my-linklyng.my.id/my-link). Premium accounts only. |

Returns

| Field | Type | Description | |------------|----------|-------------| | shortUrl | string | The complete short URL, ready to share. | | slug | string | The short code at the end of the URL. |

// Custom slug — Premium accounts only
const { shortUrl } = await lyng.links.create({
  url: 'https://example.com',
  slug: 'my-link',
})
// https://lyng.my.id/my-link

lyng.links.list()

Returns your 100 most recently created links, newest first.

const { links } = await lyng.links.list()

for (const link of links) {
  console.log(link.shortUrl, link.clicks)
}

Returns { links: LyngLink[] }

Each item in the array has the following shape:

| Field | Type | Description | |---------------|----------|-------------| | slug | string | The unique short code. | | shortUrl | string | The full short URL. | | originalUrl | string | The original long URL. | | clicks | number | Number of times the link has been visited. | | createdAt | string | ISO 8601 creation timestamp. |


Error handling

All API errors throw a LyngError with a message string and a status number matching the HTTP status code.

import Lyng, { LyngError } from '@lyng/sdk'

try {
  await lyng.links.create({ url: 'https://example.com' })
} catch (err) {
  if (err instanceof LyngError) {
    console.error(err.status)  // 429
    console.error(err.message) // "Link limit reached."
  }
}

Common status codes

| Status | Meaning | |--------|---------| | 400 | Bad request — missing or invalid fields. | | 401 | Invalid or missing API key. | | 403 | Feature not available on your plan (e.g. custom slugs require Premium). | | 409 | Slug already taken. | | 429 | Free account link limit (60) reached. | | 500 | Server error — try again later. |

See the full error code reference for details and fix suggestions.


TypeScript types

All types are exported from the package:

import type { LyngLink, CreateLinkOptions, CreateLinkResult } from '@lyng/sdk'

| Type | Description | |---------------------|-------------| | LyngLink | A single link object returned by links.list(). | | CreateLinkOptions | Options accepted by links.create(). | | CreateLinkResult | Return value of links.create(). |


Links

License

MIT