REST API: retrieve id only ids of relations

You can. Check this link from the docs:

/api/articles?populate[category][fields][0]=name&populate[category][fields][1]=url

Tha way you will populate only name and url of the category relation