---
title: "Retrieves a single user by their username from X."
method: POST
path: "/getByUsername"
---

# Retrieves a single user by their username from X.

`POST /getByUsername`

This function fetches a specific user from X using their username. It allows for optional expansions to be included in the response. The function returns a promise that resolves to the user data, including various user attributes and public metrics.

## Request body

- object
  - `body` object — Body of the getByUsername sls call
    - `arguments` unknown[], required
      - unknown
    - `auth` object — Authentication object
      - `strategy` 'apikey' — Authentication strategy
      - `variables` unknown[] — Variables for the authentication strategy
        - unknown
    - `packageName` string — @microfox/twitter

## Response `200`

Successful response with user data

- object
  - `data` object, required
    - `id` string, required — The unique identifier of the user
    - `name` string, required — The name of the user
    - `username` string, required — The username of the user
    - `created_at` string — The creation time of the user's account
    - `protected` boolean — Whether the user's tweets are protected
    - `profile_image_url` string — The URL of the user's profile image
    - `description` string — The user's bio
    - `location` string — The user's location
    - `url` string — The user's profile URL
    - `verified` boolean — Whether the user is verified
    - `verified_type` string — The type of verification the user has
    - `public_metrics` object
      - `followers_count` number — The number of followers the user has
      - `following_count` number — The number of users the user is following
      - `tweet_count` number — The number of tweets the user has posted
      - `listed_count` number — The number of lists the user is included in
  - `errors` object[]
    - `detail` string — A detailed description of the error
    - `status` number — The HTTP status code of the error
    - `title` string — The title of the error
    - `type` string — The type of the error

## Other responses

- `400` — Bad request
- `500` — Internal server error

---

[API](https://skmtc.net/microfox-ai/apis/microfox-x-sdk-api.md) · [All operations](https://skmtc.net/microfox-ai/apis/microfox-x-sdk-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/microfox-ai/microfox-x-sdk-api/versions/329b4bca235b/schema)
