Skip to content

abhishekjnvk/tiny-url-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

tiny-url-generator npm package

A simple URL shortener written in node.js using tiny.piedevelopers.com as the API.

Installation

npm install tiny-url-generator

Usage

const ls = require('tiny-url-generator');

ls.generate({
  url: "https://piedevelopers.com",
  title: "PieDeveloper"
})
  .then((res) => {
    console.log("Response: ", res);
  })
  .catch((err) => {
    console.log("Error: ", err);
  });

sample output

{
  "message": "OK",
  "status": true,
  "data": {
    "link": "https://tiny.piedevelopers.com/go/YnLg9Q",
    "title": "PieDeveloper",
    "timestamp": 1690042585,
    "expiry": 0,
    "isAnalyticsEnabled": 0
  }
}

API Reference

generate()

Generates a short URL 

Parameters

  • title
    The title of the URL.
  • url
    The URL to shorten.
  • expiry (optional)
    The expiry time of the URL. (0 = never)
  • analytics_password (Optional)
    The password for the analytics page (optional). if not provided, analytics will be disabled.

Response

The response is a JSON object with the following properties:

  • link
    The shortened URL.
  • title
    The title of the URL.
  • expiry
    The expiry time of the URL.
  • analytics_link
    The URL to the analytics page (optional)

Rate Limiting

The API has a rate limit of 40 requests per minute. If you exceed this limit, you will receive a 429 Too Many Requests response.

Contributing

Pull requests are welcome. For major changes, please open an issue.

License

MIT

About

Tiny URL Generator is a Node.js package that enables developers to easily generate short URLs from long ones within their projects, simplifying the process of URL management and sharing.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published