The Ugurly package is a JavaScript library for shortening URLs using the Ugurly service.
You can install the Ugurly package via npm:
npm install ugurly
const ugurly = require("ugurly");
// Replace "YOUR_API_KEY" with your actual API key
const apiKey = "YOUR_API_KEY";
const client = new ugurly(apiKey);
(async () => {
try {
const { shortUrl } = await client.createShortURL("https://example.com");
console.log("Shortened URL:", shortUrl);
} catch (error) {
console.error("Error:", error.message);
}
})();
Creates a new instance of the Ugurly client with the specified API key.
-
apiKey
: The API key provided by Ugurly.
Shortens the given long URL and returns the shortened URL.
-
longUrl
: The long URL to shorten.
Returns a Promise that resolves to an object containing the shortened URL:
{
shortUrl: "https://ugurly.vercel.app/r/jshhsjs"
}
If an error occurs during URL shortening, the Promise will be rejected with an Error object containing the error message.
Contributions are welcome! Please feel free to open issues or submit pull requests.
This package is licensed under the MIT License.