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 🙏

© 2025 – Pkg Stats / Ryan Hefner

tly-api

v1.0.0

Published

A Node.js client for the T.ly URL Shortener API

Readme

T.LY API Client

A Node.js client for the T.LY URL Shortener API. This package provides convenient methods to manage short links, tags, and pixels through T.LY's API.

Table of Contents

Installation

Install the package via npm:


npm install tly-api

Getting Started

  1. Obtain an API Token: Sign up or log in to T.LY and retrieve your API token from the T.LY dashboard.

  2. Initialize the Client:

    const TlyClient = require('tly-api');
    
    // Replace 'YOUR_API_TOKEN' with your actual T.LY API token.
    const tly = new TlyClient('YOUR_API_TOKEN');
  3. Use the Methods: You can now call any of the available methods (short link creation, pixel management, tag management, etc.) on the tly instance.

API Reference

Below is a summary of the methods available on the TlyClient class. For detailed parameter structures, refer to the inline code comments.

Pixel Management

  • createPixel(data) Creates a new pixel. Example data:

    {
      name: 'My Facebook Pixel',
      pixel_id: '123456789',
      pixel_type: 'facebook'
    }
  • listPixels() Retrieves a list of all pixels.

  • getPixel(id) Retrieves a single pixel by its ID.

  • updatePixel(id, data) Updates the pixel's attributes. Example data:

    {
      id: 123,
      name: 'Updated Pixel',
      pixel_id: '987654321',
      pixel_type: 'facebook'
    }
  • deletePixel(id) Deletes the pixel by its ID.

Short Link Management

  • createShortLink(data) Creates a new short link. Example data:

    {
      long_url: 'https://example.com',
      short_id: 'customalias',
      domain: 't.ly',
      expire_at_datetime: '2025-12-31T23:59:59Z',
      expire_at_views: 1000,
      description: 'My short link',
      public_stats: false,
      password: 'optionalPassword',
      tags: [1, 2],
      pixels: [101, 102],
      meta: { 'title': 'Custom Title' }
    }
  • getShortLink(shortUrl) Retrieves a short link by its short URL (e.g., t.ly/alias).

  • updateShortLink(data) Updates an existing short link. Important: data should include short_url along with any fields to update.

  • deleteShortLink(data) Deletes a short link. Important: data must include the short_url you wish to delete.

  • expandShortLink(data) Retrieves the long URL behind a short URL. Example data:

    {
      short_url: 't.ly/alias',
      password: 'ifProtected'
    }
  • listShortLinks(params) Retrieves a paginated list of short links. Example params:

    {
      search: 'example',
      tag_ids: [1],
      pixel_ids: [101],
      start_date: '2025-01-01',
      end_date: '2025-01-31',
      domains: ['t.ly']
    }
  • bulkShortenLinks(data) Shortens multiple links at once. Example data:

    {
      domain: 't.ly',
      links: [
        { long_url: 'https://site1.com' },
        { long_url: 'https://site2.com' }
      ],
      tags: [1, 2],
      pixels: [101, 102]
    }
  • getStats(shortUrl) Retrieves analytics data for a given short URL.

Tag Management

  • listTags() Retrieves a list of all tags.

  • createTag(data) Creates a new tag. Example data:

    {
    	tag: 'Marketing';
    }
  • getTag(id) Retrieves a single tag by its ID.

  • updateTag(id, data) Updates the tag’s attributes. Example data:

    {
    	tag: 'New Tag Name';
    }
  • deleteTag(id) Deletes the tag by its ID.

Example

Below is a simple usage example demonstrating how to create and retrieve a short link:

const TlyClient = require('tly-api');

// Replace 'YOUR_API_TOKEN' with your actual T.LY API token.
const tly = new TlyClient('YOUR_API_TOKEN');

async function runExample() {
	try {
		// Create a new short link
		const createdLink = await tly.createShortLink({
			long_url: 'https://www.example.com',
			description: 'Example Link',
		});
		console.log('Created Short Link:', createdLink);

		// Retrieve the details of the created short link
		const shortUrl = createdLink.short_url;
		const linkInfo = await tly.getShortLink(shortUrl);
		console.log('Retrieved Link Info:', linkInfo);
	} catch (error) {
		console.error('Error:', error.response ? error.response.data : error.message);
	}
}

runExample();

License

This package is licensed under the MIT License.