Media
Media Items
Media Items are the core objects in Ittybit.
They act as containers for your related media assets.
The simplest Media Item could contain just a single image. Whilst more complex examples might include multiple audio and video tracks, as well as multiple intelligence items and custom metadata.
Each new upload or ingested file creates a new Media Item.
Sources
A Source is a single variant of the original media. Every Media Item will have at least one Source, which is a direct copy of the original media.
Media Items can contain any number of additional Sources, enabling you to store multiple variants of the original media for different devices and use cases, together in a single Media Item resource.
Tracks
Additionally Media with a kind
of video
may have one or more Tracks.
Tracks provide additional features which can be used by Players to provide a more engaging experience for your viewers:
- Subtitles
- Chapters
- Thumbnails
Intelligence
Media Items can also contain one or more Intelligence items.
Intelligence items are JSON-formatted objects containing rich data extracted from the media file by Ittybit's AI models:
- Description: A visual description of images or videos useful for SEO and accessibility.
- Summary: A text summary of video and audio content, including suggested title, preview paragraph, and tags.
- Speech: Highly accurate speech-to-text transcription with word-level timestamps and optional speaker identification.
- NSFW Detection: Scan media for any nudity, violence, or other explicit content.
Metadata
Media Items can also contain custom metadata in a JSON object containing your own key-value pairs.
Metadata is useful for storing additional information you need to associate with the media. Other customer use metadata to store things like:
- User ID of the user who uploaded the media
- Content ID of an article the media is associated with
- Expiry Date for media that can be periodically cleaned up
- Custom Tags for easy search and filtering
Examples
Example A
A Media Item with a kind
of image
might have two Sources:
- one Source with a
format
ofwebp
- another Source with a
format
ofjpeg
Example B
A Media Item with a kind
of video
might have three Sources:
- one Source with a
height
of1080px
- one Source with a
height
of480px
- one Source with
format
ofjpeg
andlabel
ofthumbnail
Example C
A Media Item with a kind
of video
might have:
- one Source with a
format
ofmp4
- another Source with a
format
ofjpeg
- one Intelligence with a
kind
ofspeech
- another Intelligence with a
kind
ofobjects
- one Track with a
kind
ofsubtitles
Endpoints
Create Media Item
Endpoint
https://api.ittybit.com/media
HTTP Method
POST
Description
Creates a new media item by ingesting a file from a url.
Note: To upload a file directly to Ittybit, including via secure client-side uploads, you can use the Uploads API.
Body Parameters
-
url string (required)
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.
-
title string
A title for the media item. This can be used to identify the media item in the media library. Defaults to the filename.
-
filename string
The filename will be used in the URL that accesses the original source for the media. It can contain letters, numbers, underscores, and hyphens. If not provided, we will use the file's
id
and an extension based on the filetype e.g./[folder_path]/file_abcdefgh1234.mp4
.Note that the filename must be unique within the given folder unless the
overwrite
parameter is set totrue
. -
folder string
An optional folder value can be provided to help you organise your media, or to match the folder structure of an existing media library. Folder values can be a path or a single folder name and will be used in the URLs used to access your media files. If not provided, we will use the default folder for your project e.g.
/media/[filename]
. -
overwrite boolean
If
true
, the media item will be created even if another file with the same filename already exists in the given folder. Note that overwritten files are not deleted and can be accessed (or renamed or deleted) via the Files API. Defaults tofalse
. -
metadata object
A set of key-value pairs to store with the media item. Values must be
strings
. In addition, nested objects are not supported – if you have an interesting use case for this, please let us know about it.
List Media Items
Endpoint
https://api.ittybit.com/media
HTTP Method
GET
Description
Returns a list of all media items in your project.
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
,duration
,width
,height
,fps
, orfilename
. -
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
. -
metadata.KEY string
Filter media by metadata values. Multiple parameters can be chained, and results will contain only the results that match all the provided metadata key-value pairs e.g. to find all media with a
user_id
of123
and asource
ofYourApp/iOS
, you can add the query params?metadata.user_id=123&metadata.source=YourApp/iOS
. Values are case-sensitive, will be URL-decoded for comparison, and must be an exact string match.
View Media Item
Endpoint
https://api.ittybit.com/media/:id
HTTP Method
GET
Description
Returns the details for a single media item.
Response Parameters
-
id string
Unique identifier for the media item.
-
object string
The type of object. Always
media
. -
title string
The title of the media item or
null
if no title has been set. -
folder string
The folder the media item is stored in or
null
if no folder has been set. -
kind string
The kind of the original file. Possible values are
image
,video
,audio
. -
width integer
The width of the original file in pixels.
-
height integer
The height of the original file in pixels.
-
duration number
The duration of the original file in seconds (for video, audio, and animated images).
-
fps number
The frames per second of the original file (for video and animated images).
-
filesize integer
The size of the original file in bytes.
-
total_filesize integer
The total size of all the media files in the media item. This is the sum of the filesizes of all source, track, and intelligence files.
-
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
oraudio
. -
intelligence array
An array of Intelligence objects that describe the rich data that has been extracted from the media.
-
original string
The URL to the original asset.
-
... urls strings
If the media item has additional sources, tracks, or intelligence, and any of those files have a label, then the url to the file will be included in the top-level media object with the label as the key e.g. a source with the label
poster
will be included asposter: https://[... url to file]
. -
placeholder string
A base64-encoded placeholder image for the media item. This is only present for media with a
kind
ofimage
orvideo
. -
background string
The dominant color in the original asset, in hexadecimal format e.g.
#FF94A4
. This is only present for media with akind
ofimage
orvideo
. -
metadata object
A JSON object containing key-value pairs forany custom metadata you have attached to the media item.
-
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 Item
Endpoint
https://api.ittybit.com/media/:id
HTTP Method
PATCH
Description
Update a media item's title, folder, and/or metadata.
Body Parameters
-
title string
A new title for the media item.
-
folder string
A new folder for the media item. All Source, Intelligence, and Track files will be moved to the new folder. Note that existing links will need to be updated. Filenames can be updated by using the Files API.
-
overwrite boolean
If
true
, the folder will be updated even if files already exist in the given folder with the same filename as files in the media item. Note that overwritten files are not deleted and can be accessed (or renamed or deleted) via the Files API. Defaults tofalse
. -
metadata object
The new metadata to attach to the media item. Values will be merged with existing values. To remove a value you can set it to
null
. To remove all metadata, you can pass an empty object:{}
.
Delete Media Item
Endpoint
https://api.ittybit.com/media/:id
HTTP Method
DELETE
Description
Deletes a media item and all its sources, tracks, intelligence, and metadata.
Individual files can be deleted using the Files API.
NOTE: To avoid accidental data loss we 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.