My goal is to get the tree for the latest SHA in the default branch

GET /repos/:owner/:repo/git/trees/:sha

How do I find the lastest SHA from the default branch?

I know that I can call

GET /repos/:owner/:repo/branches/:branch

But I can't just use "master" for the branch as not all repos use master as the default branch.

How do I find out what the default branch for a repo is?

This is also now avaialable with the github cli as well

gh repo list <Your_Name> --json nameWithOwner,defaultBranchRef

If you want to slightly cleanup the output, you can remap with jq

gh repo list <Your_Name> --json nameWithOwner,defaultBranchRef \
  --jq ".[] | { nameWithOwner , defaultBranch: .defaultBranchRef.name}"

The advantage to this approach being auth is integrated and much easier to manage