---
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 profile information 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

- object
  - `data` object, required
    - `id` string, required
    - `name` string, required
    - `username` string, required
    - `created_at` string
    - `protected` boolean
    - `profile_image_url` string
    - `description` string
    - `location` string
    - `url` string
    - `verified` boolean
    - `verified_type` string
    - `public_metrics` object
      - `followers_count` number
      - `following_count` number
      - `tweet_count` number
      - `listed_count` number
  - `errors` object[]
    - `detail` string
    - `status` number
    - `title` string
    - `type` string

## Other responses

- `400` — Bad request
- `500` — Server error

## Changes

- **2025-05-28** `9a6d6c9f0b84` — 2 warning, 10 info
  - removed the optional property `errors/items/message` from the response with the `400` status
  - removed the optional property `errors/items/message` from the response with the `500` status
  - added the optional property `errors/items/detail` to the response with the `400` status
  - added the optional property `errors/items/detail` to the response with the `500` status
  - …8 more

[Change history](https://skmtc.dev/microfox-ai/apis/microfox-x-sdk-api/changes/getByUsername/post.md)

---

[API](https://skmtc.dev/microfox-ai/apis/microfox-x-sdk-api.md) · [All operations](https://skmtc.dev/microfox-ai/apis/microfox-x-sdk-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/microfox-ai/microfox-x-sdk-api/revisions/9a6d6c9f0b84/schema)
