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

@tinyurl-ca/sdk

v1.0.1

Published

Official JavaScript/TypeScript SDK for TinyURL.ca API

Readme

TinyURL.ca JavaScript/TypeScript SDK

Official JavaScript/TypeScript SDK for the TinyURL.ca API.

Installation

npm install @tinyurl-ca/sdk

Quick Start

import { TinyURLClient } from '@tinyurl-ca/sdk';

// Initialize client
const client = new TinyURLClient({
  apiKey: 'your_api_key_here'
});

// Shorten a URL
const link = await client.createLink({
  url: 'https://example.com'
});

console.log(link.shortUrl); // https://tinyurl.ca/abc123

API Reference

Initialize Client

import { TinyURLClient } from '@tinyurl-ca/sdk';

const client = new TinyURLClient({
  apiKey: 'your_api_key_here',
  baseURL: 'https://tinyurl.ca/api/v1' // optional
});

Create a Link

const link = await client.createLink({
  url: 'https://example.com',
  customCode: 'my-link',      // optional
  title: 'My Website',         // optional
  expiresIn: 86400            // optional, seconds
});

// Response
{
  id: 'abc123',
  shortCode: 'my-link',
  shortUrl: 'https://tinyurl.ca/my-link',
  originalUrl: 'https://example.com',
  title: 'My Website',
  clicks: 0,
  createdAt: '2026-04-04T00:00:00Z',
  expiresAt: '2026-04-05T00:00:00Z'
}

Get Link Details

const link = await client.getLink('link_id');

List Links

const links = await client.listLinks({
  limit: 50,    // optional, default 50
  offset: 0     // optional, default 0
});

Delete Link

await client.deleteLink('link_id');

Shorten URL (convenience method)

const shortUrl = await client.shorten('https://example.com');
// Returns: 'https://tinyurl.ca/abc123'

// With custom code
const customUrl = await client.shorten('https://example.com', 'promo');
// Returns: 'https://tinyurl.ca/promo'

TypeScript Support

Full TypeScript support with type definitions included.

import { TinyURLClient, Link, CreateLinkOptions } from '@tinyurl-ca/sdk';

const options: CreateLinkOptions = {
  url: 'https://example.com',
  customCode: 'my-link'
};

const link: Link = await client.createLink(options);

Error Handling

try {
  const link = await client.createLink({
    url: 'https://example.com',
    customCode: 'taken'
  });
} catch (error) {
  if (error.response?.status === 409) {
    console.log('Custom code already in use');
  } else {
    console.error('Error:', error.message);
  }
}

Examples

Node.js

const { TinyURLClient } = require('@tinyurl-ca/sdk');

const client = new TinyURLClient({
  apiKey: process.env.TINYURL_API_KEY
});

async function main() {
  // Create link
  const link = await client.createLink({
    url: 'https://mywebsite.com',
    title: 'My Website'
  });
  
  console.log('Short URL:', link.shortUrl);
  
  // List all links
  const links = await client.listLinks();
  console.log('Total links:', links.length);
}

main();

Next.js API Route

import { TinyURLClient } from '@tinyurl-ca/sdk';
import { NextRequest, NextResponse } from 'next/server';

const client = new TinyURLClient({
  apiKey: process.env.TINYURL_API_KEY!
});

export async function POST(request: NextRequest) {
  const { url } = await request.json();
  
  const link = await client.createLink({ url });
  
  return NextResponse.json({ shortUrl: link.shortUrl });
}

Express.js

const express = require('express');
const { TinyURLClient } = require('@tinyurl-ca/sdk');

const app = express();
const client = new TinyURLClient({
  apiKey: process.env.TINYURL_API_KEY
});

app.post('/shorten', async (req, res) => {
  try {
    const { url } = req.body;
    const link = await client.createLink({ url });
    res.json({ shortUrl: link.shortUrl });
  } catch (error) {
    res.status(500).json({ error: error.message });
  }
});

app.listen(3000);

License

MIT

Support

  • Documentation: https://tinyurl.ca/docs
  • Issues: https://github.com/raj-iwt/tinyurl-sdk/issues
  • Email: [email protected]