Skip to main content
This guide walks you through retrieving the currently authenticated user’s profile using the /me endpoint.
PrerequisitesBefore you begin, you’ll need:
  • A developer account with an approved App
  • User Access Token (OAuth 1.0a or OAuth 2.0 PKCE)

Get the authenticated user

Make a request to the /me endpoint with a User Access Token:
cURL
curl "https://api.x.com/2/users/me?\
user.fields=created_at,description,verified,public_metrics,profile_image_url" \
  -H "Authorization: Bearer $USER_ACCESS_TOKEN"
from xdk import Client

client = Client(bearer_token="YOUR_USER_ACCESS_TOKEN")

# Get the authenticated user
response = client.users.get_me(
    user_fields=["created_at", "description", "verified", "public_metrics", "profile_image_url"]
)

print(f"Username: {response.data.username}")
print(f"ID: {response.data.id}")
print(f"Followers: {response.data.public_metrics.followers_count}")
import { Client } from "@xdevplatform/xdk";

const client = new Client({ accessToken: "YOUR_USER_ACCESS_TOKEN" });

// Get the authenticated user
const response = await client.users.getMe({
  userFields: ["created_at", "description", "verified", "public_metrics", "profile_image_url"],
});

console.log(`Username: ${response.data?.username}`);
console.log(`ID: ${response.data?.id}`);
console.log(`Followers: ${response.data?.public_metrics?.followers_count}`);

Response

{
  "data": {
    "id": "2244994945",
    "name": "X Developers",
    "username": "XDevelopers",
    "created_at": "2013-12-14T04:35:55.000Z",
    "description": "The voice of the X developer community",
    "verified": true,
    "profile_image_url": "https://pbs.twimg.com/profile_images/...",
    "public_metrics": {
      "followers_count": 583423,
      "following_count": 2048,
      "tweet_count": 14052,
      "listed_count": 1672
    }
  }
}

Use case

The /me endpoint is essential when:
  • Verifying authentication — Confirm the user is properly authenticated
  • Getting the user ID — Retrieve the authenticated user’s ID for other API calls
  • Personalizing experiences — Display the user’s profile in your app
  • On behalf of requests — Know who you’re making requests for

Include pinned Post

Request the user’s pinned Post:
cURL
curl "https://api.x.com/2/users/me?\
user.fields=pinned_tweet_id&\
expansions=pinned_tweet_id&\
tweet.fields=created_at,text" \
  -H "Authorization: Bearer $USER_ACCESS_TOKEN"
from xdk import Client

client = Client(bearer_token="YOUR_USER_ACCESS_TOKEN")

# Get authenticated user with pinned Post
response = client.users.get_me(
    user_fields=["pinned_tweet_id"],
    expansions=["pinned_tweet_id"],
    tweet_fields=["created_at", "text"]
)

print(f"Username: {response.data.username}")
# Pinned Post is in response.includes.tweets
import { Client } from "@xdevplatform/xdk";

const client = new Client({ accessToken: "YOUR_USER_ACCESS_TOKEN" });

// Get authenticated user with pinned Post
const response = await client.users.getMe({
  userFields: ["pinned_tweet_id"],
  expansions: ["pinned_tweet_id"],
  tweetFields: ["created_at", "text"],
});

console.log(`Username: ${response.data?.username}`);
// Pinned Post is in response.includes?.tweets

Response with expansion

{
  "data": {
    "id": "2244994945",
    "name": "X Developers",
    "username": "XDevelopers",
    "pinned_tweet_id": "1234567890"
  },
  "includes": {
    "tweets": [
      {
        "id": "1234567890",
        "text": "Welcome to my profile!",
        "created_at": "2024-01-01T00:00:00.000Z"
      }
    ]
  }
}

Available fields

FieldDescription
created_atAccount creation date
descriptionUser bio
profile_image_urlAvatar URL
verifiedVerification status
public_metricsFollower/following counts
locationUser-defined location
urlUser’s website
protectedProtected account status
pinned_tweet_idPinned Post ID

Authentication requirement

The /me endpoint requires User Context authentication. App-Only (Bearer Token) authentication is not supported.
Use either:

Next steps

User lookup

Look up other users

Integration guide

Key concepts and best practices

API Reference

Full endpoint documentation