Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I retrieve a Trello Board's shortLink from a card page?

I'm making a Google Chrome extension for Trello, and want to get the shortLink of the current Board, while viewing a Card URL.

For example:

This card https://trello.com/c/v9eqAHMX/20-api-documentation

Belongs to this board https://trello.com/b/nPNSBZjB/trello-resources

If the current page is the board then I can extract the shortLink (nPNSBZjB in this case) from window.location.pathname. But if the current page is a card, is it possible to retrieve the board's shortlink using javascript?

Keeping track of the last board URL that was visited works in most cases, but not when a user lands directly on the card URL (without going via the board).

Thanks.

like image 392
doctororange Avatar asked Nov 22 '25 16:11

doctororange


1 Answers

Your best bet will be to use the card's shortLink to make a few API requests. Using this route, you can get the board's long id from the card's shortLink. If you need the shortLink (the id would, for most purposes, suffice), you can use the id and this route.

There are ways to do it synchronously, but they will be very fragile and prone to breaking on client updates, so I would not recommend them.

like image 117
Aaron Dufour Avatar answered Nov 25 '25 11:11

Aaron Dufour



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!