Introducing StretchLink.cc

I made something in the process of making something else. I didn’t finish the something else, but figured I’d share the thing…

I got an itch to revive StretchLink, my little menu bar app that expanded shortened links as you copied them, so you had a full URL when you pasted. It was great for seeing where a link would take you before following it. Given the state of the internet, that seemed useful.

I have the code to resolve links internally, but I like the flexibility of an API. The original StretchLink relied on an API that has since died, so I decided to just write my own. It’s not complicated.

So here’s stretchlink.cc. A simple little API that takes a shortened URL and outputs the long version. It can remove tracking info if you like, as well as reduce Amazon product links down to the bare minimum the URL needs to function. It can output plain text (just the resolved URL), Markdown (with optional title), or JSON (including original url, expanded url, and optional title).

I added caching and concurrency, for what it’s worth. If this gets used, it would scale well. I doubt it will, but I like to cover my bases. I’ve written a couple of Shortcuts that leverage it for double checking URLs you’ve been sent before clicking them. I’ll share those separately. If you make anything useful with the API, please do share in the comments (which are connected to the Forum).

Check out the landing page for detailed instructions.


This is a companion discussion topic for the original entry at https://brettterpstra.com/2024/12/21/introducing-stretchlink-dot-cc

Great to see Stretchlink revived! As humble contribution and sign of my gratitude, I offer this Shortcut to make interactive use of the stretchlink.cc API: Stretchlink cc

The Shortcut uses a dictionary for default parameter values and a menu to selectively change those, based on the desired output format. It should work on iPhone, iPad, Mac and maybe even Vision Pro.

1 Like

This is so close to something I had just been thinking about building myself! I use NextDNS to filter ads, and unfortunately it also often blocks requests for marketing/tracked links that I do want to open, like package tracking number or unsubscribe links from emails. Similar to what you did, I was going to set up a hosted script (i.e. not using NextDNS) that would request a URL, grab the redirection location, and return it. Two things I was going to do differently were that I’d follow multiple redirects (with a limit), and I’d use GET requests instead of HEAD, since I’ve found some links that only send the redirect in response to a GET. Would you be open to a PR with those changes? Or what’s your license if I wanted to host my own?

Mine should follow up to 5 redirects.

Oh, I bet you’re looking at the repo I posted to GitHub. That’s actually a stub app. Three version that runs stretchlink.cc is completely different.

Oh cool. It’s probably better than the one I threw together yesterday, will give it a play.

1 Like

Thanks for that Shortcut! I see some value myself in an Alfred workflow to do something with this; I’m not a developer so I’ll be able to borrow a lot of the implementation details from that Shortcut if and when I get around to making it!