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

# Get User by Username

> Get a user profile by their username (screen name). Returns comprehensive profile data including bio, follower/following counts, verification status, and account metadata. The most common way to look up a user profile.



## OpenAPI

````yaml get /v1/twitter/users/{username}/by_username
openapi: 3.1.0
info:
  title: ScrapeBadger Twitter API
  description: >-
    The ScrapeBadger Twitter API provides programmatic access to Twitter/X data
    through a simple REST interface. Retrieve tweets, user profiles, followers,
    lists, communities, trends, and geographic data — all with a single API key.


    All endpoints require authentication via the `x-api-key` header. Each
    request consumes credits from your account balance. Paginated endpoints
    return a `next_cursor` field that you can pass to subsequent requests to
    retrieve additional pages of results.


    **Base URL:** `https://scrapebadger.com/v1/twitter`


    **Rate Limits:** Requests are rate-limited per API key. If you exceed your
    limit, you will receive a `429` response. Implement exponential backoff and
    retry logic for production use.


    **Credits:** Each successful API call deducts credits from your balance. If
    your balance reaches zero, subsequent requests will return `402 Payment
    Required`.
  version: 1.0.0
  contact:
    name: ScrapeBadger Support
    url: https://scrapebadger.com
    email: support@scrapebadger.com
servers:
  - url: https://scrapebadger.com
    description: Production
security:
  - apiKey: []
tags:
  - name: Tweets
    description: >-
      Retrieve tweets, search tweets, and access tweet metadata including
      replies, quotes, retweeters, favoriters, edit history, and community
      notes.
  - name: Users
    description: >-
      Retrieve user profiles, followers, following lists, mentions,
      subscriptions, and search for users.
  - name: Lists
    description: Access Twitter list details, list tweets, and search within lists.
  - name: Communities
    description: Retrieve community details, community tweets, and search for communities.
  - name: Trends
    description: Get trending topics globally or by location.
  - name: Geo
    description: Search for geographic places and retrieve place details.
  - name: Spaces
    description: Access Twitter Spaces and live broadcast details.
  - name: Stream Monitors
    description: >-
      Create and manage real-time stream monitors that track Twitter accounts
      and deliver new tweets via WebSocket or webhook.
  - name: Stream Webhooks
    description: >-
      Manage webhook endpoints for stream monitor delivery. Webhooks receive
      HMAC-SHA256 signed payloads when new tweets are detected.
  - name: Stream Logs
    description: >-
      Access delivery logs and billing logs for stream monitors. Track tweet
      detection latency, webhook delivery status, and credit consumption.
  - name: Filter Rules
    description: >-
      Create and manage filter rules that monitor Twitter using Advanced Search
      queries at configurable intervals. Delivered via WebSocket or webhook.
paths:
  /v1/twitter/users/{username}/by_username:
    get:
      tags:
        - Users
      summary: Get user by username
      description: >-
        Get a user profile by their username (screen name). Returns
        comprehensive profile data including bio, follower/following counts,
        verification status, and account metadata. The most common way to look
        up a user profile.
      operationId: getUserByUsername
      parameters:
        - name: username
          in: path
          required: true
          description: The username (screen name) of the user, without the @ symbol.
          schema:
            type: string
            example: elonmusk
      responses:
        '200':
          description: Successfully retrieved user profile.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserData'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '429':
          $ref: '#/components/responses/RateLimitExceeded'
components:
  schemas:
    UserData:
      type: object
      description: >-
        Comprehensive user profile data including bio, metrics, verification
        status, and account metadata.
      required:
        - id
        - username
        - name
        - created_at
      properties:
        id:
          type: string
          description: Unique numeric user identifier.
          example: '44196397'
        username:
          type: string
          description: The user's screen name (handle).
          example: elonmusk
        name:
          type: string
          description: The user's display name.
          example: Elon Musk
        description:
          type:
            - string
            - 'null'
          description: The user's bio/description.
          example: Mars & Cars, Chips & Dips
        location:
          type:
            - string
            - 'null'
          description: The user's self-reported location.
          example: Mars
        url:
          type:
            - string
            - 'null'
          description: URL in the user's profile.
        profile_image_url:
          type:
            - string
            - 'null'
          description: URL of the user's profile image.
        profile_banner_url:
          type:
            - string
            - 'null'
          description: URL of the user's profile banner.
        followers_count:
          type: integer
          description: Number of followers.
          default: 0
        following_count:
          type: integer
          description: Number of accounts this user follows.
          default: 0
        tweet_count:
          type: integer
          description: Total number of tweets posted.
          default: 0
        listed_count:
          type: integer
          description: Number of lists this user appears on.
          default: 0
        favourites_count:
          type:
            - integer
            - 'null'
          description: Number of tweets this user has liked.
        media_count:
          type:
            - integer
            - 'null'
          description: Number of media items posted.
        verified:
          type: boolean
          description: Whether the user is verified (legacy verification).
          default: false
        verified_type:
          type:
            - string
            - 'null'
          description: Type of verification (e.g., Government, Business).
        is_blue_verified:
          type:
            - boolean
            - 'null'
          description: Whether the user has a Twitter Blue/Premium subscription.
        created_at:
          type: string
          description: Account creation timestamp.
          example: Tue Jun 02 20:12:29 +0000 2009
        created_at_datetime:
          type:
            - string
            - 'null'
          description: Account creation date in ISO 8601 format.
        protected:
          type:
            - boolean
            - 'null'
          description: Whether the user's tweets are protected (private).
        possibly_sensitive:
          type:
            - boolean
            - 'null'
          description: Whether the user's content may be sensitive.
        followed_by:
          type:
            - boolean
            - 'null'
          description: Whether this user follows the authenticated user.
        following:
          type:
            - boolean
            - 'null'
          description: Whether the authenticated user follows this user.
        can_dm:
          type:
            - boolean
            - 'null'
          description: Whether the authenticated user can send a DM to this user.
        professional_type:
          type:
            - string
            - 'null'
          description: Professional account type, if applicable.
        pinned_tweet_ids:
          type:
            - array
            - 'null'
          description: IDs of the user's pinned tweets.
          items:
            type: string
    ErrorResponse:
      type: object
      description: Error response returned for failed requests.
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message describing what went wrong.
  responses:
    Unauthorized:
      description: Authentication failed. The API key is missing, invalid, or expired.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: Invalid or missing API key
    PaymentRequired:
      description: >-
        Insufficient credits. Your account balance has been exhausted. Purchase
        more credits at https://scrapebadger.com/dashboard/billing.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: Insufficient credits
    RateLimitExceeded:
      description: >-
        Rate limit exceeded. Too many requests in a given time period. Implement
        exponential backoff and retry.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: Rate limit exceeded. Please retry after a short delay.
  securitySchemes:
    apiKey:
      type: apiKey
      name: x-api-key
      in: header
      description: >-
        Your ScrapeBadger API key. You can find this in your dashboard at
        https://scrapebadger.com/dashboard/api-keys.

````