1.3.1 • Published 3 years ago
short.io v1.3.1
short.io (NodeJS Module)
Easy to use module, made to interact with the short.io API, shorten links, delete them & more.
How to use short.io ?
Here's some exemple to kickstart your short.io integration, if you need documentation, refer to the GitHub Repository's Wiki.
IchiiDev/short.io is not affiliated to the website and enterprise short.io
Basics
If you want to use your short.io account with this package, here's some data you should get from your account:
- domain: The full domain redirected on the short.io service, exemple: short.domain.com.
- domainId: The ID of the managed domain, you can get it in the URL of the links panel, exemple: https://app.short.io/users/dashboard/00000/links < 00000.
- api_key: Your account API Key, you can manage yours here: https://app.short.io/settings/integrations/api-key/ (Only use your private key and do not publish it).
Get a list of specific links from your domain
const shortio = require("short.io");
// Create your short.io API Wrapper Instance
const short = new shortio("short.domain.com", 00000, "ZdegKTLwycVBilTxW77hY8Zq4utAn7Xk");
// This* gets a maximum of 150 links from your domain
short.getLinks().then(links => {
console.log(links); // Print your links
});
*More options available on the package's wiki page
Get a precise link from the API
const shortio = require("short.io");
// Create your short.io API Wrapper Instance
const short = new shortio("short.domain.com", 00000, "ZdegKTLwycVBilTxW77hY8Zq4utAn7Xk");
// This gets a precise link informations, the 00000 is the link ID.
short.getLink(00000).then(link => {
console.log(link);
});
Push a link to your shortner domain
const shortio = require("short.io");
// Create your short.io API Wrapper Instance
const short = new shortio("short.domain.com", 00000, "ZdegKTLwycVBilTxW77hY8Zq4utAn7Xk");
// This* creates a link on your short.io service.
short.createLink({ originalURL: "https://discord.gg/fr" }).then(link => {
console.log(link);
});
*More options available on the package's wiki page
Delete a link from your shortner domain
const shortio = require("short.io");
// Create your short.io API Wrapper Instance
const short = new shortio("short.domain.com", 00000, "ZdegKTLwycVBilTxW77hY8Zq4utAn7Xk");
// This deletes a link, the 00000 is the link ID.
short.deleteLink(00000) // Delete the link
.then(result => console.log(result)) // Display the result for debug
.catch(e => console.log(e)); // Catch error if one occures
How to contribute ?
Feel free to fork my work and propose changes. If you have any issues with my work, please open an Issue.
Contributors
- @IchiiDev:
contact@ichiidev.xyz
(Contact E-Mail).
What's new ?
v1.1.O
: Security update
- Changed request dependency package from
request
tonode-fetch
(request
was deprecated). - Added promises to the
deleteLink()
andarchiveLink()
function.
v1.1.1
: Documentation Update
- Fixed the
getLinks()
function, added more parameters likeoffset
,tag
andlimit
. - Added more documentation to the code
v1.2.0
: Link Management Update
- Added the
updateLink()
function to permit link edition - Added the
getByOriginalURL()
function to get a link object by querying it's originalURL. - Removed useless functions parameters
- Corrected JS Doc errors
v1.3.0
: Statistics 🥳
- Added domain, clicks and links stats methods
- Fixed some code execution errors
- Removed useless constants from the code
What's coming ?
- Add more classes to improve package ergonomics => V2 (TypeScript)
- Global rewrite of the package in TS to improve documentation and code quality + user ergonomic => V2
V2 will come directly as the next update, there wont be any 1.4.0 for domain management (Theses methods will be added along with the V2)