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 🙏

© 2024 – Pkg Stats / Ryan Hefner

gotiny

v1.5.5

Published

SDK for GoTiny: A lightweight link shortener API

Downloads

75

Readme

GoTiny is no longer available

Read more: GoTiny is shutting down


GoTiny SDK

SDK for GoTiny: A lightweight link shortener API

Table of Contents

Installation

npm install gotiny

Usage

Create GoTiny link

To create a new GoTiny link, pass the long url as an argument in the gotiny.set() function.

const gotiny = require("gotiny")

// Using Then

gotiny.set("https://amazon.com/very-long-url")
  .then(res => console.log(res))
  .catch(err => console.log(err))

// Using Async/Await

const createShortLink = async (input) => {

  try {
    const res = await gotiny.set(input)
    console.log(res)
  } catch (err) {
    console.log(err)
  }

}

createShortLink("https://amazon.com/very-long-url")

The response will always be an array of objects, each of which contains a tiny link, formatted in different ways.

  • long: The original url that was used to create the GoTiny link
  • code: The short code used to identify the GoTiny link
  • tiny: The short link created by GoTiny
  • link: The short link created by GoTiny, prefixed by the http-protocol

Example response:

// gotiny.set("https://amazon.com/very-long-url")

[
  {
    long: "https://amazon.com/very-long-url",
    code: "y68hxc",
    tiny: "gotiny.cc/y68hxc",
    link: "https://gotiny.cc/y68hxc",
  },
]

Automatic URL Parsing

GoTiny automatically filters URLs from the user input. This way, you as a developer won't have to provide a clean link, but can just feed an entire paragraph into GoTiny. It will create a short url from every url that it finds and include it in the response array.

Example response:

// gotiny.set("The top 3 most popular websites are youtube.com, www.google.com and apple.com.")

[
  {
    long: "youtube.com",
    code: "86df6c",
    tiny: "gotiny.cc/86df6c",
    link: "https://gotiny.cc/86df6c",
  },
  {
    long: "www.google.com",
    code: "6wrsnf",
    tiny: "gotiny.cc/6wrsnf",
    link: "https://gotiny.cc/6wrsnf",
  },
  {
    long: "apple.com",
    code: "c56ned",
    tiny: "gotiny.cc/c56ned",
    link: "https://gotiny.cc/c56ned",
  },
];

Note that you’re not required to use the long attribute in your code. GoTiny will automatically resolve the short link in the users web browser to point to the original url.

Options

Options are provided by passing an object to the gotiny.set() function. The object should have a long key with the long link as a value, as wel as any of the supported options. Options currently supported are:

| Key | Type | Description | | :------------ | :------ | :------------------------------------------------------------------------------------------ | | custom | string | Generates a custom link (e.g. gotiny.cc/custom-link). Custom codes should consist of 4-32 lowercase letters, numbers, - and/or _ symbols. | | useFallback | boolean | Set to false if you don't want to use a randomly generated 6-character fallback code and throw an error instead when a custom code can't be used. |

To generate multiple links at once, you can pass an array of objects in to the gotiny.set() function.

gotiny.set({
  long: "https://amazon.com/very-long-url", 
  custom: "amazon", // generate gotiny.cc/amazon
  useFallback: false // don't use randomly generated code when "amazon" can't be used
})
  .then(res => console.log(res))
  .catch(err => console.log(err))

Resolve GoTiny link

To resolve a GoTiny link, pass the link as an argument in the gotiny.get() function. The full link will return as plain text.

const gotiny = require("gotiny")

gotiny.get("https://gotiny.cc/y68hxc")
  .then(res => console.log(res)) // https://amazon.com/very-long-url
  .catch(err => console.log(err))

Add an object with an extended key set to true as a second argument to return a more detailed object.

const gotiny = require("gotiny")

gotiny.get("https://gotiny.cc/y68hxc", { extended: true })
  .then(res => console.log(res)) // { code: 'y68hxc', long: 'https://amazon.com/very-long-url' }
  .catch(err => console.log(err))

Alternatively, you can omit the http-protocol or pass just the GoTiny code to the gotiny.get() function.

About GoTiny Links

The unique links that GoTiny generates are always 16 characters long, including the domain name. GoTiny links are all lowercase and don't include characters that could be confused with each other (e.g. o/0 or 1/i/l).

Privacy

GoTiny does not collect, handle or store any user information.

License

MIT

Other Repositories