Just hit the profile page URL and get the HTTP staus code. If https://twitter.com/ksdhbfslbflsdbs returns 404, it's not available.
Not quit the same (a username might be reserved internally), but either way, nobody else can use the name.
Not quit the same (a username might be reserved internally), but either way, nobody else can use the name.