> ## Documentation Index
> Fetch the complete documentation index at: https://docs.x.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Authenticated User Quickstart

> This guide walks you through retrieving the currently authenticated user's profile using the. Reference for the X API v2 standard tier covering quickstart.

export const Button = ({href, children}) => {
  return <div className="not-prose group">
    <a href={href}>
      <button className="flex items-center space-x-2.5 py-1 px-4 bg-primary-dark dark:bg-white text-white dark:text-gray-950 rounded-full group-hover:opacity-[0.9] font-medium">
        <span>
          {children}
        </span>
        <svg width="3" height="24" viewBox="0 -9 3 24" class="h-6 rotate-0 overflow-visible"><path d="M0 0L3 3L0 6" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg>
      </button>
    </a>
  </div>;
};

This guide walks you through retrieving the currently authenticated user's profile using the `/me` endpoint.

<Note>
  **Prerequisites**

  Before you begin, you'll need:

  * A [developer account](https://developer.x.com/en/portal/petition/essential/basic-info) with an approved App
  * User Access Token (OAuth 1.0a or OAuth 2.0 PKCE)
</Note>

***

## Get the authenticated user

Make a request to the `/me` endpoint with a User Access Token:

<CodeGroup dropdown>
  ```bash cURL theme={null}
  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"
  ```

  ```python Python SDK theme={null}
  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}")
  ```

  ```javascript JavaScript SDK theme={null}
  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}`);
  ```
</CodeGroup>

***

## Response

```json theme={null}
{
  "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:

<CodeGroup dropdown>
  ```bash cURL theme={null}
  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"
  ```

  ```python Python SDK theme={null}
  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
  ```

  ```javascript JavaScript SDK theme={null}
  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
  ```
</CodeGroup>

### Response with expansion

```json theme={null}
{
  "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

| Field               | Description               |
| :------------------ | :------------------------ |
| `created_at`        | Account creation date     |
| `description`       | User bio                  |
| `profile_image_url` | Avatar URL                |
| `verified`          | Verification status       |
| `public_metrics`    | Follower/following counts |
| `location`          | User-defined location     |
| `url`               | User's website            |
| `protected`         | Protected account status  |
| `pinned_tweet_id`   | Pinned Post ID            |

***

## Authentication requirement

<Warning>
  The `/me` endpoint requires User Context authentication. App-Only (Bearer Token) authentication is not supported.
</Warning>

Use either:

* [OAuth 1.0a User Context](/resources/fundamentals/authentication)
* [OAuth 2.0 Authorization Code with PKCE](/resources/fundamentals/authentication#oauth-2-0-authorization-code-flow-with-pkce-2)

***

## Next steps

<CardGroup cols={2}>
  <Card title="User lookup" icon="users" href="/x-api/users/lookup/quickstart/user-lookup">
    Look up other users
  </Card>

  <Card title="Integration guide" icon="book" href="/x-api/users/lookup/integrate">
    Key concepts and best practices
  </Card>

  <Card title="API Reference" icon="code" href="/x-api/users/get-my-user">
    Full endpoint documentation
  </Card>
</CardGroup>
