Checking a password against a breach list sounds like something you should never do online. The range API makes it safe enough, because the password never leaves your machine.
The Pwned Passwords API uses k-anonymity. You send the first five characters of the password’s SHA-1 hash to https://api.pwnedpasswords.com/range/, and it returns every hash suffix with that prefix, each with a count. You compare the rest locally. No API key is needed.
read -rs PW; echo
H=$(printf %s "$PW" | sha1sum | cut -c1-40)
curl -s "https://api.pwnedpasswords.com/range/${H:0:5}" | grep -i "${H:5:35}"
unset PW H
A line like 0018A45C4D1DEF81644B54AB7F969B88D65:1 means the password turned up in breaches that many times. No output means it is not in the list. The read -rs keeps the password off the screen and out of your shell history, and grep -i covers the upper case letters in the response.
The docs also describe an Add-Padding: true request header. It pads the response to between 800 and 1,000 entries, so the size no longer hints at how many real matches there were. Padded entries always have a count of 0 and can be discarded.
curl -s -H "Add-Padding: true" "https://api.pwnedpasswords.com/range/${H:0:5}"
A hit means the password is public and has to go. A miss only means it was not in that list. I would use this on a password I already have, and leave new ones to a password manager. Type real passwords only on a machine you trust.
Further reading: Have I Been Pwned API v3