Media - daneden/Twift GitHub Wiki

Media

Media refers to any image, GIF, or video attached to a Tweet. The media object is not a primary object on any endpoint, but can be found and expanded in the Tweet object.

public struct Media: Codable, Identifiable 

Inheritance

Codable, Fielded, Identifiable

Nested Type Aliases

ID

public typealias ID = String

Field

Additional fields that can be requested on the Media object

public typealias Field = PartialKeyPath<Self>

Properties

mediaKey

Unique identifier of the expanded media content.

public let mediaKey: ID

id

A convenience accessor for the mediaKey property mapped to the more standard id key path

public var id: ID 

type

Type of media

public let type: MediaType

durationMs

Available when type is video. Duration in milliseconds of the video.

public let durationMs: Int?

height

Height of this content in pixels.

public let height: Int?

nonPublicMetrics

Non-public engagement metrics for the media content at the time of the request. Requires user context authentication.

public let nonPublicMetrics: Metrics?

organicMetrics

Engagement metrics for the media content, tracked in an organic context, at the time of the request. Requires user context authentication.

public let organicMetrics: Metrics?

promotedMetrics

Engagement metrics for the media content, tracked in a promoted context, at the time of the request. Requires user context authentication.

public let promotedMetrics: Metrics?

publicMetrics

Public engagement metrics for the media content at the time of the request.

public let publicMetrics: PublicMetrics?

width

Width of this content in pixels.

public let width: Int?

altText

A description of an image to enable and support accessibility. Can be up to 1000 characters long. Alt text can only be added to images at the moment.

public let altText: String?

previewImageUrl

URL to the static placeholder preview of this content.

public let previewImageUrl: URL?

url

URL to the media content

public let url: URL?

variants

Each media object may have multiple display or playback variants, with different resolutions or formats

public let variants: [Variant]?
⚠️ **GitHub.com Fallback** ⚠️