client.media (MediaClient).
Methods
add_post_to_amplify_programs
POST /2/media/amplify/posts
Add Post to Amplify Programs
Publishes one of the authenticated user’s video posts into one or more active Amplify pre-roll programs the user is enrolled in as a publisher.
Parameters
Returns:AddPostToAmplifyProgramsResponse
add_to_library
POST /2/media/library
Add Media to Library
Adds previously uploaded media to the authenticated user’s Media Library with its library metadata. The user must own the media. Geo restrictions, content expiry, the preview image and the audience policy are set with the Media metadata endpoint.
Parameters
Returns:AddToLibraryResponse
append_upload
POST /2/media/upload/{id}/append
Append Media Upload
Appends one segment of the file to a chunked upload. Send the segment base64-encoded in media (raw bytes in multipart bodies) and its position in the file in segment_index, counting from 0. A segment can be up to 8 MB; in a JSON body keep it to 4 MB or less, because base64 adds a third. After the last segment, call Finalize Media Upload.
Parameters
Returns:AppendUploadResponse
create_metadata
POST /2/media/metadata
Create Media Metadata
Creates metadata for a Media file.
Parameters
Returns:CreateMetadataResponse
create_subtitles
POST /2/media/subtitles
Create Media Subtitles
Creates subtitles for a specific Media file.
Parameters
Returns:CreateSubtitlesResponse
delete_subtitles
DELETE /2/media/subtitles
Delete Media Subtitles
Deletes subtitles for a specific Media file.
Parameters
Returns:DeleteSubtitlesResponse
finalize_upload
POST /2/media/upload/{id}/finalize
Finalize Media Upload
Completes a chunked upload once every segment is appended. For video the result carries processing_info: the media can go on a Post only when its state is succeeded, so call Get Media Upload Status until it is. A result without processing_info is ready to use.
Parameters
Returns:FinalizeUploadResponse
get_amplify_program
GET /2/media/amplify/programs/{program_id}
Get Amplify Program
Returns one Amplify pre-roll program the authenticated user is enrolled in as a publisher. A program the user is not enrolled in is reported as not found.
Parameters
Returns:GetAmplifyProgramResponse
get_amplify_program_posts
GET /2/media/amplify/programs/{program_id}/posts
Get Amplify Program Posts
Returns the posts published into an Amplify pre-roll program the authenticated user is enrolled in as a publisher.
Parameters
Returns:GetAmplifyProgramPostsResponse
get_amplify_programs
GET /2/media/amplify/programs
Get Amplify Programs
Returns the Amplify pre-roll programs the authenticated user is enrolled in as a publisher.
GetAmplifyProgramsResponse
get_analytics
GET /2/media/analytics
Get Media Analytics
Retrieves analytics data for media.
Parameters
Returns:GetAnalyticsResponse
get_by_key
GET /2/media/{media_key}
Get Media by Media Key
Retrieves details of a specific Media file by its media key.
Parameters
Returns:GetByKeyResponse
get_by_keys
GET /2/media
Get Media by Media Keys
Retrieves details of Media files by their media keys.
Parameters
Returns:GetByKeysResponse
get_library_categories
GET /2/media/library/categories
Get Media Library Categories
Returns the video categories a publisher can assign to a media library item and the advertiser categories whose ads can be blocked from running against it.
Parameters
Returns:GetLibraryCategoriesResponse
get_upload_status
GET /2/media/upload
Get Media Upload Status
Returns how far X has processed an uploaded media file, in processing_info.state: pending, in_progress, succeeded or failed. Call it after Finalize Media Upload returns processing_info, waiting check_after_secs between calls, until the state is succeeded. A failed state means the media can’t be used.
Parameters
Returns:GetUploadStatusResponse
initialize_upload
POST /2/media/upload/initialize
Initialize Media Upload
Starts a chunked media upload and returns its id. Use it for video and for other files too large for one request. For a video on a Post, set media_category to tweet_video, media_type to the file’s type (for example video/mp4) and total_bytes to the file’s size. Send the file with Append Media Upload, call Finalize Media Upload, then pass the id in media.media_ids on Create or Edit Post.
Parameters
Returns:InitializeUploadResponse
remove_from_library
DELETE /2/media/library/{media_key}
Remove Media Library Item
Removes an item from the authenticated user’s Media Library. Posts scheduled through the API that have not yet been published and still use the media are cancelled. Published posts and the underlying media are not affected.
Parameters
Returns:RemoveFromLibraryResponse
update_in_library
PUT /2/media/library/{media_key}
Update Media Library Item
Updates the library metadata of an item in the authenticated user’s Media Library. Only the fields sent are changed; the others keep their values. Geo restrictions, content expiry, the preview image and the audience policy are set with the Media metadata endpoint.
Parameters
Returns:UpdateInLibraryResponse
upload
POST /2/media/upload
Upload Media
Uploads a media file in one request and returns its id. Send the file base64-encoded in media (raw bytes in multipart bodies). For a Post, set media_category to tweet_image (JPG, PNG, GIF or WEBP, up to 5 MB) or tweet_gif, then pass the returned id in media.media_ids on Create or Edit Post. DM media uses dm_image or dm_gif. For video, use Initialize Media Upload.
Parameters
Returns:UploadResponse