How do you use the whoami endpoint?

The whoami endpoint is listed on your public facing API page here: Hugging Face Hub Endpoints

However I cannot curl this endpoint. It always returns unauthorized.

There’s a been a stackoverflow question hanging around that matches my issue exactly, so I’ll link it here:

Is this endpoint intended to be usable? If so, how?

My intent was to check token validity before trying to use them to run models, so that I could quickly identify bad tokens.

Thanks for any help.

1 Like

Hey there! Thanks for raising!

The endpoint was updated to whoami-v2, it seems we missed updating that doc page. Here is a working example

curl https://huggingface.co/api/whoami-v2 -H "Authorization: Bearer your_token"

Note that we also have a Python library with a whoami method you can use if that’s useful. huggingface_hub/src/huggingface_hub at main · huggingface/huggingface_hub · GitHub

3 Likes