Hi so I am trying to make a verification bot on discord but Im having trouble getting the users userid from your username.
Does anyone know how to do this?
I am nowhere near a pro at web web development and all that shmuck. I havent touched anythin of that since late 2018 so ive basically forgotten mostly everything. My only thing i can think of is that you could try to use the users api?
https://users.roblox.com/docs/index.html
You can use the /v1/usernames/users
users API endpoint to bulk fetch users and their user data (including IDs).
Based on the docs provided on the API docs page as mentioned by @Herobrinekd1, example code using the requests library would look something like this in Python:
import requests
API_ENDPOINT = "https://users.roblox.com/v1/usernames/users"
def getUserId(username):
requestPayload = {
"usernames": [
username
],
"excludeBannedUsers": True # Whether to include banned users within the request, change this as you wish
}
responseData = requests.post(API_ENDPOINT, json=requestPayload)
# Make sure the request succeeded
assert responseData.status_code == 200
userId = responseData.json()["data"][0]["id"]
print(f"getUserId :: Fetched user ID of username {username} -> {userId}")
return userId
getUserId("JadtrugamingYT1") # This will print and return the OP's ID :)
Here’s an example output of the code:
Hope this helped!
2 Likes
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.