Media
Introduction
Media describes the original assets in your Project.
Media can be uploaded or ingested in a range of formats and can have a kind
of image
, video
, or audio
.
A Media Item can contain a number of Sources which describe the different variants of the media that have been created and Intelligence Items which describe rich data that has been extracted from the media.
Additionally Media with a kind
of video
may have one or more Tracks, which provide additional metadata (like subtitles) to Players.
Example A
A Media Item with a kind
of image
might have one Source with a format
of webp
and another with a format
of jpeg
.
Example B
A Media Item with a kind
of video
might have one Source with a height
of 1080px
, one Source with a height
of 480px
, and another Source with format
of jpeg
and label
of thumbnail
.
Example C
A Media Item with a kind
of video
might have one Source with a format
of mp4
, one Source with a format
of jpeg
, one Intelligence with a kind
of speech
, another Intelligence with a kind
of objects
, and a Track with a kind
of subtitles
.
Endpoints
List Media
Returns a list of all media.
Endpoint
GET /media
Query Parameters
-
page integer
The page number to return. Default is 1.
-
limit integer
The number of items to return per page. Default is 12. Maximum is 100.
-
sort string
The field to sort by. Default is
created
. Possible values arecreated
,updated
,filesize
. -
order string
The order to sort by. Default is
desc
. Possible values areasc
,desc
. -
kind string
The kind of media to return. Possible values are
image
,video
,audio
. -
status string
The status of the media to return. Possible values are
active
,processing
,waiting
.
Create Media
Creates a new media item by ingesting a file passed in via the url
prop.
To upload a file directly to Ittybit, including via secure client-side uploads, you can use the Uploads API.
Endpoint
POST /media
Body Parameters
-
url string
A URL to the file to ingest. The file must be publicly accessible or have a signed URL with an expiry > 10 minutes in the future.
-
alias string
A unique alias for the media. This will be used to generate the media URL. It should be unique to your project. It can contain letters, numbers, and hyphens. If not provided, we will use the default URL in the format
/:media_id/original
. -
metadata object
A set of key-value pairs to store with the media. This can be used to store any additional information you need to associate with the media. For example, you might want to store the original filename, the user who uploaded the media, or any other data that is relevant to your project. Values can be a
string
,integer
,number
,boolean
, ornull
. Nested objects are not supported – if you have an interesting use case for this, please let us know about it.
View Media
Returns the details for a single media item.
Endpoint
GET /media/:id
Response Parameters
-
id string
Unique identifier for the media item.
-
kind string
The kind of media. Possible values are
image
,video
,audio
. -
width integer
The width of the original asset in pixels.
-
height integer
The height of the original asset in pixels.
-
duration number
The duration of the original asset in seconds (for video, audio, and animated images).
-
fps number
The frames per second of the original asset (for video).
-
filesize integer
The size of the original asset in bytes.
-
sources array
An array of Source objects that describe the different variants of the media that have been created.
-
tracks array
An array of Track objects that describe additional metadata files that have been created for the media. This is only present for media with a
kind
ofvideo
. -
intelligence array
An array of Intelligence objects that describe the rich data that has been extracted from the media.
-
metadata object
A JSON object containing any custom metadata you have attached to the media item. Values can be a
string
,integer
,float
,boolean
, ornull
. Nested objects are not supported – if you have an interesting use case for this, please let us know about it. -
status string
The status of the media item. Possible values are
active
,processing
,waiting
. -
created datetime
The date and time the media item was created. ISO 8601 format.
-
updated datetime
The date and time the media item was last updated. ISO 8601 format.
Update Media
Updates a media item's metadata.
Endpoint
PATCH /media/:id
Body Parameters
-
metadata object
The new metadata to attach to the media item. This will fully replace the existing metadata, so to retain values you should include them in the new object. To remove a value you can exclude it from the new object. To remove all metadata, you can pass an empty object:
{}
.
Delete Media
Deletes a media item.
NOTE: This action will delete the media AND all its sources, intelligence, and metadata. To avoid accidental data loss we will retain the data and files for ~24 hours before permanently deleting it. If you need to restore an item within this period, please contact support.
Endpoint
DELETE /media/:id