Skip to main content

Username to ID (/username-to-id)

What is it? This utility endpoint converts a human-readable X handle (e.g., elonmusk) into its unique, numerical X User ID (e.g., 44196397). Why use it?
  • Handling Renames: X handles can be changed by users at any time, but User IDs are permanent. For database consistency, you should always store and track users by their ID.
  • Optimizing Requests: Many advanced Sorsa.io endpoints (like verification or follower lists) perform faster or more reliably when passed a user_id instead of a link.
  • Cross-Referencing: Use this to map data between different social platforms or internal CRM systems.
Python Implementation:
import requests

API_KEY = "YOUR_API_KEY"
URL = "https://api.sorsa.io/v3/username-to-id"

params = {"username": "VitalikButerin"}
headers = {"ApiKey": API_KEY}

response = requests.get(URL, params=params, headers=headers)
data = response.json()

if response.status_code == 200:
    user_id = data.get("id")
    print(f"The User ID for @VitalikButerin is: {user_id}")