> ## Documentation Index
> Fetch the complete documentation index at: https://x-preview-mintlify-b4f5bfb1.mintlify.site/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">
    <a href={href}>
      <button className="x-btn">
        <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 title="Python SDK" lines wrap icon="python" 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 title="JavaScript SDK" lines wrap icon="square-js" 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 title="Example response" lines wrap icon="https://mintcdn.com/x-preview-mintlify-b4f5bfb1/E43Ep5Gv29gM6HJ6/icons/xds/icon-brackets.svg?fit=max&auto=format&n=E43Ep5Gv29gM6HJ6&q=85&s=e49413e02c3658182f7b9e2cb5663b95" 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 title="Python SDK" lines wrap icon="python" 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 title="JavaScript SDK" lines wrap icon="square-js" 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 title="Example response" lines wrap icon="https://mintcdn.com/x-preview-mintlify-b4f5bfb1/E43Ep5Gv29gM6HJ6/icons/xds/icon-brackets.svg?fit=max&auto=format&n=E43Ep5Gv29gM6HJ6&q=85&s=e49413e02c3658182f7b9e2cb5663b95" 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="https://mintcdn.com/x-preview-mintlify-b4f5bfb1/VFX2XSyPqtT4SVsH/icons/xds/icon-people.svg?fit=max&auto=format&n=VFX2XSyPqtT4SVsH&q=85&s=a87838641b92da2bd42d8ec4805b86c7" href="/x-api/users/lookup/quickstart/user-lookup" width="24" height="24" data-path="icons/xds/icon-people.svg">
    Look up other users
  </Card>

  <Card title="Integration guide" icon="https://mintcdn.com/x-preview-mintlify-b4f5bfb1/E43Ep5Gv29gM6HJ6/icons/xds/icon-book.svg?fit=max&auto=format&n=E43Ep5Gv29gM6HJ6&q=85&s=58d2163a527af71742b049fc4dc92669" href="/x-api/users/lookup/integrate" width="24" height="24" data-path="icons/xds/icon-book.svg">
    Key concepts and best practices
  </Card>

  <Card title="API Reference" icon="https://mintcdn.com/x-preview-mintlify-b4f5bfb1/NEh9mjpH7RaTDEed/icons/xds/icon-code.svg?fit=max&auto=format&n=NEh9mjpH7RaTDEed&q=85&s=07116236bb3000cffffbf6c9bac6d47e" href="/x-api/users/get-my-user" width="24" height="24" data-path="icons/xds/icon-code.svg">
    Full endpoint documentation
  </Card>
</CardGroup>
