Page MenuHomePhabricator

Create API to retrieve list of short urls
Open, LowPublic

Description

Per discussion at T228779. The target can already be checked manually by visiting the link, but this would make it easier.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Why? Just look at the Location header.

km@km-pt ~> curl -i 'https://w.wiki/42' | grep location
location: https://el.wikipedia.org/wiki/%CE%A0%CF%8D%CE%BB%CE%B7:%CE%9A%CF%8D%CF%81%CE%B9%CE%B1

Can this be done in AJAX?

Theoretically, sure. But not on Wikimedia sites because of CORS. What's the use case?

Can this be done in AJAX?

Theoretically, sure. But not on Wikimedia sites because of CORS. What's the use case?

For example, a user wants to check if there is a link to a specific page already, without creating a new link if one doesn't exist

For example, a user wants to check if there is a link to a specific page already, without creating a new link if one doesn't exist

How would this API help with that? In that case you'd want to provide the long URL and see if any short code exists. But that's not a good use case anyways, because short URLs are so cheap, just create it.

Sorry, I meant check if a short url is already taken, because they may be waiting and hoping for a specific one (just as specific urls were assigned before the feature went live for everyone) - eg w.wiki/wiki. Or, it could be used to see how many have been created so far

@Legoktm is there any downside to adding this feature?

@Legoktm is there any downside to adding this feature?

After thinking a bit more, no, I don't think there's any downside. For other wikis that don't set up dumps, this could be a useful alternative. I would suggest that the API be named something like allshortcodes, and lists all codes. There would be a parameter like ascstart=... which allows for continuation, and people could use that get a specific one. Does that seem reasonable?

@Legoktm is there any downside to adding this feature?

After thinking a bit more, no, I don't think there's any downside. For other wikis that don't set up dumps, this could be a useful alternative. I would suggest that the API be named something like allshortcodes, and lists all codes. There would be a parameter like ascstart=... which allows for continuation, and people could use that get a specific one. Does that seem reasonable?

Yes, quite. I'll take a crack at this next week. Thanks

Change 528291 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/extensions/UrlShortener@master] Add API module to query targets

https://gerrit.wikimedia.org/r/528291

This comment was removed by DannyS712.

@Legoktm ping just want to make sure the patch provided is on your radar; I've addressed the issues you previously raised

Don't really have time to focus on this - will try to address the issues on the patch at some point, but if anyone else wants to take over feel free

Reedy renamed this task from Create API to retrieve target of short url to Create API to retrieve list of short urls.Feb 20 2024, 10:37 PM