UrlBae
URL ShortenersIntroducing the URLbae Public API!
URLbae is a URL shortening service that allows users to compress long URLs into short ones. The URLbae Public API allows developers to integrate URL shortening functionality into their applications and websites.
Getting Started
To get started with the URLbae Public API, you need to sign up for an API key. You can sign up for an API key on the URLbae Developers page.
Once you have your API key, you can start using the API to shorten your URLs.
API Examples in JavaScript
Here are some JavaScript examples that demonstrate how to use the URLbae Public API:
Shorten a URL
To shorten a URL using the URLbae Public API, you need to make a POST request to the https://urlbae.com/api/shorten
endpoint. Here's an example in JavaScript using the fetch
API:
const url = 'https://www.example.com/very/long/url/that/needs/to/be/shortened';
fetch('https://urlbae.com/api/shorten', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({
url: url
})
})
.then(response => response.json())
.then(data => console.log(data.short_url))
.catch(error => console.error(error));
Expand a Short URL
To expand a short URL using the URLbae Public API, you need to make a GET request to the https://urlbae.com/api/expand
endpoint. Here's an example in JavaScript using the fetch
API:
const shortUrl = 'https://urlbae.com/abcde';
fetch(`https://urlbae.com/api/expand?url=${encodeURIComponent(shortUrl)}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
}
})
.then(response => response.json())
.then(data => console.log(data.long_url))
.catch(error => console.error(error));
Get Stats for a Short URL
To get stats for a short URL using the URLbae Public API, you need to make a GET request to the https://urlbae.com/api/stats
endpoint. Here's an example in JavaScript using the fetch
API:
const shortUrl = 'https://urlbae.com/abcde';
fetch(`https://urlbae.com/api/stats?url=${encodeURIComponent(shortUrl)}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
Conclusion
The URLbae Public API is a powerful tool that developers can use to integrate URL shortening functionality into their applications and websites. With these JavaScript examples, you can start using the API in your own projects right away.