Getting the latest LTS codename through cURL

You can do what do-release-upgrade does and use https://changelogs.ubuntu.com/meta-release-lts to get the list of LTS releases and parse that:

% curl -s https://changelogs.ubuntu.com/meta-release-lts | grep Name: | tail -n1
Name: Focal Fossa

The format of https://changelogs.ubuntu.com/meta-release-lts is fairly simple and shouldn't be difficult to parse. There's also https://changelogs.ubuntu.com/meta-release for all releases.