> ## Documentation Index
> Fetch the complete documentation index at: https://x-preview-mintlify-58ae8dc1.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Media by media key



## OpenAPI

````yaml get /2/media/{media_key}
openapi: 3.0.0
info:
  description: X API v2 core endpoints
  version: '2.167'
  title: X API v2
  termsOfService: https://developer.x.com/en/developer-terms/agreement-and-policy.html
  contact:
    name: X Developers
    url: https://developer.x.com/
  license:
    name: X Developer Agreement and Policy
    url: https://developer.x.com/en/developer-terms/agreement-and-policy.html
servers:
  - description: X API
    url: https://api.x.com
security: []
tags:
  - name: Account Activity
    description: Endpoints relating to retrieving, managing Account Activity subscriptions
    externalDocs:
      description: Find out more
      url: >-
        https://docs.x.com/x-api/enterprise-gnip-2.0/fundamentals/account-activity
  - name: Activity
    description: Endpoints relating to retrieving, managing activity subscriptions
    externalDocs:
      description: Find out more
      url: >-
        https://docs.x.com/x-api/enterprise-gnip-2.0/fundamentals/account-activity
  - name: Articles
    description: Endpoints related to retrieving, creating & modifying Articles
    externalDocs:
      description: Find out more
      url: https://docs.x.com/x-api/articles/introduction
  - name: Broadcasts
    description: Endpoints related to live broadcasts and their chat
    externalDocs:
      description: Find out more
      url: https://developer.x.com/
  - name: Chat
    description: Endpoints related to Chat encrypted messaging
    externalDocs:
      description: Find out more
      url: https://developer.x.com/
  - name: Communities
    description: Endpoints related to retrieving and managing Communities
    externalDocs:
      description: Find out more
      url: https://docs.x.com/x-api/communities/introduction
  - name: Community Notes
    description: Endpoints related to retrieving, searching, and modifying Community Notes
    externalDocs:
      description: Find out more
      url: https://docs.x.com/x-api/community-notes/introduction
  - name: Compliance
    description: Endpoints related to keeping X data in your systems compliant
    externalDocs:
      description: Find out more
      url: https://docs.x.com/x-api/compliance/batch-compliance/introduction
  - name: Connections
    description: Endpoints related to streaming connections
    externalDocs:
      description: Find out more
      url: https://developer.x.com/en/docs/x-api/connections
  - name: Direct Messages
    description: Endpoints related to retrieving, managing Direct Messages
    externalDocs:
      description: Find out more
      url: https://docs.x.com/x-api/direct-messages/introduction
  - name: General
    description: Miscellaneous endpoints for general API functionality
    externalDocs:
      description: Find out more
      url: https://docs.x.com/x-api/introduction
  - name: Lists
    description: Endpoints related to retrieving, managing Lists
    externalDocs:
      description: Find out more
      url: https://docs.x.com/x-api/lists/introduction
  - name: Media
    description: Endpoints related to retrieving and uploading Media
    externalDocs:
      description: Find out more
      url: https://docs.x.com/x-api/media/introduction
  - name: News
    description: Endpoint for retrieving news stories
    externalDocs:
      description: Find out more
      url: https://developer.x.com/
  - name: Posts
    description: Endpoints related to retrieving, searching, and modifying Posts
    externalDocs:
      description: Find out more
      url: https://docs.x.com/x-api/posts/introduction
  - name: Spaces
    description: Endpoints related to retrieving, managing Spaces
    externalDocs:
      description: Find out more
      url: https://docs.x.com/x-api/spaces/introduction
  - name: Stream
    description: Endpoints related to streaming
    externalDocs:
      description: Find out more
      url: https://developer.x.com/
  - name: Trends
    description: Endpoint for retrieving trends
    externalDocs:
      description: Find out more
      url: https://docs.x.com/x-api/trends/introduction
  - name: Usage
    description: Endpoints related to retrieving usage
    externalDocs:
      description: Find out more
      url: https://docs.x.com/x-api/usage/introduction
  - name: Users
    description: Endpoints related to retrieving, managing relationships of Users
    externalDocs:
      description: Find out more
      url: https://docs.x.com/x-api/users/introduction
  - name: Webhooks
    description: Endpoints relating to retrieving, managing webhooks and webhook configs
    externalDocs:
      description: Find out more
      url: >-
        https://docs.x.com/x-api/enterprise-gnip-2.0/fundamentals/account-activity
paths:
  /2/media/{media_key}:
    get:
      tags:
        - Media
      summary: Get Media by media key
      operationId: getMediaByMediaKey
      parameters:
        - name: media_key
          in: path
          required: true
          schema:
            type: string
            pattern: ^([0-9]+)_([0-9]+)$
          style: simple
        - $ref: '#/components/parameters/MediaFieldsParameter'
      responses:
        '200':
          description: The request has succeeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetMediaByMediaKeyResponse'
        default:
          description: The request has failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
      security:
        - OAuth2UserToken:
            - tweet.read
        - UserToken: []
        - BearerToken: []
components:
  parameters:
    MediaFieldsParameter:
      name: media.fields
      in: query
      description: A comma separated list of Media fields to display.
      required: false
      schema:
        type: array
        description: The fields available for a Media object.
        minItems: 1
        uniqueItems: true
        items:
          type: string
          enum:
            - alt_text
            - duration_ms
            - height
            - media_key
            - non_public_metrics
            - organic_metrics
            - preview_image_url
            - promoted_metrics
            - public_metrics
            - type
            - url
            - variants
            - width
      explode: false
      style: form
  schemas:
    GetMediaByMediaKeyResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/Media'
        errors:
          type: array
          items:
            $ref: '#/components/schemas/Problem'
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string
    Problem:
      oneOf:
        - $ref: '#/components/schemas/ResourceNotFoundProblem'
        - $ref: '#/components/schemas/InvalidRequestProblem'
        - $ref: '#/components/schemas/NotAuthorizedForResourceProblem'
        - $ref: '#/components/schemas/NotAuthorizedForFieldProblem'
        - $ref: '#/components/schemas/FieldUnauthorizedProblem'
        - $ref: '#/components/schemas/FieldHydrationFailureProblem'
        - $ref: '#/components/schemas/ResourceUnavailableProblem'
        - $ref: '#/components/schemas/DisallowedResourceProblem'
        - $ref: '#/components/schemas/InternalErrorProblem'
      discriminator:
        propertyName: type
        mapping:
          https://api.x.com/2/problems/disallowed-resource:
            $ref: '#/components/schemas/DisallowedResourceProblem'
          https://api.x.com/2/problems/field-hydration-failure:
            $ref: '#/components/schemas/FieldHydrationFailureProblem'
          https://api.x.com/2/problems/field-unauthorized:
            $ref: '#/components/schemas/FieldUnauthorizedProblem'
          https://api.x.com/2/problems/internal-error:
            $ref: '#/components/schemas/InternalErrorProblem'
          https://api.x.com/2/problems/invalid-request:
            $ref: '#/components/schemas/InvalidRequestProblem'
          https://api.x.com/2/problems/not-authorized-for-field:
            $ref: '#/components/schemas/NotAuthorizedForFieldProblem'
          https://api.x.com/2/problems/not-authorized-for-resource:
            $ref: '#/components/schemas/NotAuthorizedForResourceProblem'
          https://api.x.com/2/problems/resource-not-found:
            $ref: '#/components/schemas/ResourceNotFoundProblem'
          https://api.x.com/2/problems/resource-unavailable:
            $ref: '#/components/schemas/ResourceUnavailableProblem'
    Media:
      type: object
      properties:
        alt_text:
          type: string
        duration_ms:
          type: integer
        height:
          type: integer
        media_key:
          type: string
        non_public_metrics:
          $ref: '#/components/schemas/MediaNonPublicMetrics'
        organic_metrics:
          $ref: '#/components/schemas/MediaOrganicMetrics'
        preview_image_url:
          type: string
        promoted_metrics:
          $ref: '#/components/schemas/MediaPromotedMetrics'
        public_metrics:
          $ref: '#/components/schemas/MediaPublicMetrics'
        type:
          type: string
        url:
          type: string
        variants:
          $ref: '#/components/schemas/MediaVariants'
        width:
          type: integer
    ResourceNotFoundProblem:
      type: object
      required:
        - type
        - title
        - detail
        - resource_type
      properties:
        detail:
          type: string
        parameter:
          type: string
        resource_id:
          type: string
        resource_type:
          type: string
        status:
          type: integer
        title:
          type: string
        type:
          type: string
          enum:
            - https://api.x.com/2/problems/resource-not-found
        value:
          type: string
    InvalidRequestProblem:
      type: object
      required:
        - type
        - title
        - detail
      properties:
        detail:
          type: string
        parameter:
          type: string
        status:
          type: integer
        title:
          type: string
        type:
          type: string
          enum:
            - https://api.x.com/2/problems/invalid-request
        value:
          type: string
    NotAuthorizedForResourceProblem:
      type: object
      required:
        - type
        - title
        - detail
        - resource_type
      properties:
        detail:
          type: string
        parameter:
          type: string
        resource_id:
          type: string
        resource_type:
          type: string
        section:
          type: string
        status:
          type: integer
        title:
          type: string
        type:
          type: string
          enum:
            - https://api.x.com/2/problems/not-authorized-for-resource
        value:
          type: string
    NotAuthorizedForFieldProblem:
      type: object
      required:
        - type
        - title
        - detail
        - field
      properties:
        detail:
          type: string
        field:
          type: string
        parameter:
          type: string
        resource_id:
          type: string
        resource_type:
          type: string
        section:
          type: string
        status:
          type: integer
        title:
          type: string
        type:
          type: string
          enum:
            - https://api.x.com/2/problems/not-authorized-for-field
        value:
          type: string
    FieldUnauthorizedProblem:
      type: object
      required:
        - type
        - title
        - detail
        - field
      properties:
        detail:
          type: string
        field:
          type: string
        resource_type:
          type: string
        section:
          type: string
        status:
          type: integer
        title:
          type: string
        type:
          type: string
          enum:
            - https://api.x.com/2/problems/field-unauthorized
    FieldHydrationFailureProblem:
      type: object
      required:
        - type
        - title
        - detail
        - field
      properties:
        detail:
          type: string
        field:
          type: string
        resource_type:
          type: string
        section:
          type: string
        status:
          type: integer
        title:
          type: string
        type:
          type: string
          enum:
            - https://api.x.com/2/problems/field-hydration-failure
    ResourceUnavailableProblem:
      type: object
      required:
        - type
        - title
        - detail
        - resource_type
      properties:
        detail:
          type: string
        resource_id:
          type: string
        resource_type:
          type: string
        status:
          type: integer
        title:
          type: string
        type:
          type: string
          enum:
            - https://api.x.com/2/problems/resource-unavailable
    DisallowedResourceProblem:
      type: object
      required:
        - type
        - title
        - detail
      properties:
        detail:
          type: string
        resource_id:
          type: string
        resource_type:
          type: string
        section:
          type: string
        status:
          type: integer
        title:
          type: string
        type:
          type: string
          enum:
            - https://api.x.com/2/problems/disallowed-resource
    InternalErrorProblem:
      type: object
      required:
        - type
        - title
        - detail
      properties:
        detail:
          type: string
        status:
          type: integer
        title:
          type: string
        type:
          type: string
          enum:
            - https://api.x.com/2/problems/internal-error
    MediaNonPublicMetrics:
      type: object
      description: Nonpublic engagement metrics for the media at the time of the request.
      properties:
        playback_0_count:
          type: integer
          description: Number of users who started playback (0% quartile) of this video.
          format: int64
          nullable: true
        playback_100_count:
          type: integer
          description: >-
            Number of users who completed playback (100% quartile) of this
            video.
          format: int64
          nullable: true
        playback_25_count:
          type: integer
          description: Number of users who watched at least 25% of this video.
          format: int64
          nullable: true
        playback_50_count:
          type: integer
          description: Number of users who watched at least 50% of this video.
          format: int64
          nullable: true
        playback_75_count:
          type: integer
          description: Number of users who watched at least 75% of this video.
          format: int64
          nullable: true
    MediaOrganicMetrics:
      type: object
      description: >-
        Organic nonpublic engagement metrics for the media at the time of the
        request.
      properties:
        playback_0_count:
          type: integer
          description: Number of users who started playback (0% quartile) of this video.
          format: int64
          nullable: true
        playback_100_count:
          type: integer
          description: >-
            Number of users who completed playback (100% quartile) of this
            video.
          format: int64
          nullable: true
        playback_25_count:
          type: integer
          description: Number of users who watched at least 25% of this video.
          format: int64
          nullable: true
        playback_50_count:
          type: integer
          description: Number of users who watched at least 50% of this video.
          format: int64
          nullable: true
        playback_75_count:
          type: integer
          description: Number of users who watched at least 75% of this video.
          format: int64
          nullable: true
        view_count:
          type: integer
          description: >-
            The number of organic views of this video. Null when the backend
            returns quartile data without a view count.
          format: int64
          nullable: true
    MediaPromotedMetrics:
      type: object
      description: >-
        Promoted nonpublic engagement metrics for the media at the time of the
        request.
      properties:
        playback_0_count:
          type: integer
          description: Number of users who started playback (0% quartile) of this video.
          format: int64
          nullable: true
        playback_100_count:
          type: integer
          description: >-
            Number of users who completed playback (100% quartile) of this
            video.
          format: int64
          nullable: true
        playback_25_count:
          type: integer
          description: Number of users who watched at least 25% of this video.
          format: int64
          nullable: true
        playback_50_count:
          type: integer
          description: Number of users who watched at least 50% of this video.
          format: int64
          nullable: true
        playback_75_count:
          type: integer
          description: Number of users who watched at least 75% of this video.
          format: int64
          nullable: true
        view_count:
          type: integer
          description: >-
            The number of promoted views of this video. Null when the backend
            returns quartile data without a view count.
          format: int64
          nullable: true
    MediaPublicMetrics:
      type: object
      description: Public engagement metrics for the media at the time of the request.
      required:
        - view_count
      properties:
        view_count:
          type: integer
          description: The number of times this video has been viewed.
          format: int64
    MediaVariants:
      type: array
      description: >-
        Each media object may have multiple display or playback variants, with
        different resolutions or formats.
      items:
        type: object
        description: A single playback or display variant of a media object.
        properties:
          bit_rate:
            type: integer
            description: >-
              The bit rate of this variant, in bits per second. Absent for
              playlist variants.
            format: int64
            nullable: true
          content_type:
            type: string
            description: >-
              The MIME type of this variant, for example "video/mp4" or
              "application/x-mpegURL".
            nullable: true
          url:
            type: string
            description: The URL to this media variant.
            nullable: true
  securitySchemes:
    OAuth2UserToken:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://api.x.com/2/oauth2/authorize
          tokenUrl: https://api.x.com/2/oauth2/token
          scopes:
            block.read: View accounts you have blocked.
            bookmark.read: Read your bookmarked Posts.
            bookmark.write: Create and delete your bookmarks.
            broadcast.read: View your live broadcasts and their chat.
            broadcast.write: Manage your live broadcasts and send chat messages on your behalf.
            dm.read: Read all your Direct Messages.
            dm.write: Send and manage your Direct Messages.
            follows.read: View accounts you follow and accounts following you.
            follows.write: Follow and unfollow accounts on your behalf.
            like.read: View Posts you have liked and likes you can see.
            like.write: Like and unlike Posts on your behalf.
            list.read: >-
              View Lists, members, and followers of Lists you created or are a
              member of, including private Lists.
            list.write: Create and manage Lists on your behalf.
            media.write: Upload media, such as photos and videos, on your behalf.
            mute.read: View accounts you have muted.
            mute.write: Mute and unmute accounts on your behalf.
            offline.access: Request a refresh token for the app.
            space.read: View all Spaces you have access to.
            timeline.read: View all Custom Timelines you can see.
            tweet.moderate.write: Hide and unhide replies to your posts.
            tweet.read: >-
              View all posts you can see, including those from protected
              accounts.
            tweet.write: Create and repost on your behalf.
            users.read: View any account you can see, including protected accounts.
    UserToken:
      type: http
      scheme: OAuth
    BearerToken:
      type: http
      scheme: bearer

````