Download full repository archive by specific branch via api

Hello, I’m trying to download from repository full archive.
i just upgraded to newest version, and earlier it was going by:
curl --header "PRIVATE-TOKEN: <my_private_token>" -o path/to/save_file

After upgrade it don’t work, I found why, and I know I have to use API to do this. But my problem is I don’t know how to download a specific branch archive.

I’m trying this:
curl --header "PRIVATE-TOKEN: <my_private_token>"<my_procejct_ID>/repository/archive.tar.gz? -o path/to/save_file

But it don’t download a branch which i want. In documentation i see i can add sha parameter, but it takes a specific commit, not branch.

So how to download always last commit from a specific branch.

OK, its done but in 2 lines of code.
1 - get sha of last commit in branch
2 - add?sha=<sha from 1> in download command

This does not work for me. I still get the master (default) branch. I also tried ref=<banch name>. I can’t find any way to download an archive of anything but the default branch.

EDIT: The problem is apparently that only one query param is allowed in the URL. I’m using wget and this does not work:

wget -O myfile https://someHost/api/v4/projects/<id>/repository/<token>&sha=<commit>

If I reverse the order of the query params, the private_token is ignored instead. I made it work by specifying the private token in a header-line, like this:

wget -O myfile --header=PRIVATE-TOKEN:<token> https://someHost/api/v4/projects/<id>/repository/<commit>

Than you. That last wget construct worked for me. That’s great for getting individual branches. How do I use wget to download the whole repository (all branches)?