Ugurly
Introduction
The Ugurly package is a JavaScript library for shortening URLs using the Ugurly service.
Installation
You can install the Ugurly package via npm:
npm install ugurly
Usage
const ugurly = require("ugurly");
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);
}
})();
API Reference
new ugurly(apiKey)
Creates a new instance of the Ugurly client with the specified API key.
apiKey
: The API key provided by Ugurly.
createShortURL(longUrl)
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"
}
Error Handling
If an error occurs during URL shortening, the Promise will be rejected with an Error object containing the error message.
Contributing
Contributions are welcome! Please feel free to open issues or submit pull requests.
License
This package is licensed under the MIT License.