Overview
Learn how to transform, convert or compress your media files using Ittybit's Sources API
.
Delivering the right kind of file to your users is essential to ensure accessibility across various devices and improve loading times, enhancing user experience. These optimizations reduce storage costs and bandwidth usage, making content more efficient and engaging for a wider audience.
Step-by-step guide
-
Locate the media item you want to transform. As
input
you can use themedia_id
,file_id
or the URL. You can find themedia id
in the Media object. You will also need anAPI Key
. -
Determine the kind of output you want to generate. You can choose from the following options:
image
,video
oraudio
. You then have to choose the desired output format. A full list of available formats can be found below. -
Use the following code snippets to transform your file.
const API_KEY = "YOUR API KEY HERE" // Your Ittybit API key const response = await fetch("https://api.ittybit.com/tasks", { headers: { Method: "POST", Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json", body: JSON.stringify({ input: "med_abcdefgh1234", // Required parameter: media id or file URL output: { kind: "video", // Required parameter: desired output kind format: "mp4" // Required parameter: desired output format }, }), }, });
const API_KEY = "YOUR API KEY HERE" // Your Ittybit API key const response = await fetch("https://api.ittybit.com/tasks", { headers: { Method: "POST", Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json", body: JSON.stringify({ input: "med_abcdefgh1234", // Required parameter: media id or file URL (example is a video file) output: { kind: "image", // Required parameter: desired output kind format: "jpg" // Required parameter: desired output kind }, }), }, });
const API_KEY = "YOUR API KEY HERE" // Your Ittybit API key const response = await fetch("https://api.ittybit.com/tasks", { headers: { Method: "POST", Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json", body: JSON.stringify({ input: "med_abcdefgh1234", // Required parameter: media id or file URL (example is a .mov video file) output: { kind: "video", // Required parameter: desired output kind format: ".mp4" // Required parameter: desired output kind }, }), }, });
const API_KEY = "YOUR API KEY HERE" // Your Ittybit API key const response = await fetch("https://api.ittybit.com/tasks", { headers: { Method: "POST", Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json", body: JSON.stringify({ input: "med_abcdefgh1234", // Required parameter: media id or file URL (example is a video file) output: { kind: "audio", // Required parameter: desired output kind format: ".mp3" // Required parameter: desired output kind }, }), }, });
const API_KEY = "YOUR API KEY HERE" // Your Ittybit API key const response = await fetch("https://api.ittybit.com/tasks", { headers: { Method: "POST", Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json", body: JSON.stringify({ input: "med_abcdefgh1234", // Required parameter: media id or file URL (example is a video file) output: { kind: "video", // Required parameter: desired output kind format: ".mp4" // Required parameter: desired output kind height: 720, // Optional parameter: desired output height }, }), }, });
About the API
Endpoint
POST https://api.ittybit.com/sources
Body parameters
{ "input": "MEDIA_ID", // Required parameter: media id or file URL "output": { "kind": "video" // or "images" or "audio" "format": "mp4" // for a full list of available formats, see below. } }
Required
-
input string
The ID of the media to use as the input for the task. You may use a
media_id
: theid
from a Media object, or afile_id
: theid
from a File object or a URL to the media file. -
output object
Defines the output for the task. The
output
object must include akind
and may include additional options that are specific to thekind
of task.
Available kinds
"video"
"audio"
"image"
Available formats
Video
"mp4"
"webm"
"mov"
"avi"
Audio
"mp3"
"wav"
"ogg"
"flac"
Image
"jpeg"
"png"
"webp"
"gif"
Optional parameters and modifiers
-
width number
The width of the output file in pixels.
-
height number
The height of the output file in pixels.
-
quality number
The quality of the output file. A number between 0 and 1. The default value is 0.8
Next: Combine with Automations API
You can use the Automations API with Sources API to automatically generate lower-resolution versions of media to save on bandwidth. This is useful for large media libraries or social networks with user-generated content.
See the guide here: Automations
Or see Tracks in action within an Automations API request:
const response = await fetch("https://api.ittybit.com/automations", { headers: { Method: "POST", Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json", body: JSON.stringify({ "name": "All video uploads", "trigger": { "event": "media.created", "conditions": [ {"prop": "kind", "value": "video"} ] }, "tasks": [ { "kind": "image", "start": 0 }, { "kind": "video", "width": 600, "format": "mp4", "filename": "600.mp4", "next": [ { "kind": "speech", "next": [ { "kind": "subtitles" } ] }, { "kind": "thumbnails" } ] } ] }), }, });
Considerations
This guide is being updated. Please check back soon for more information.