Sources API
Ittybit's Sources API allows you to compress, convert and transform your media files so that you can deliver the best version of your media to your users.
The API takes an input of a file_id
or url
(required) and outputs a new file object. Additionally, you can include optional parameters to modify the output.
Endpoint
# Sources GET https://api.ittybit.com/sources POST https://api.ittybit.com/sources
Sample request
Convert a video file to a different 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({ file_id: "med_abcdefgh1234", // Required parameter: media id or file URL kind: "video", // Required parameter: desired output kind format: "mp4" // Required parameter: desired output format }), }, });
Sample response
"meta":{ "id": "req_abcdefgh1234", "org_id": "org_abcdefgh1234", "project_id": "prj_abcdefgh5678", "method": "POST", "host": "https://api.ittybit.com", "path": "/tasks", "version": "2024-08-21", "status": 200, "type": "object" }, "data": { "id": "tsk_abcdefgh5678", "object": "task", "input": "med_abcdefgh1234", "kind": "video", "format": "mp4", "status": "processing", "created": "2024-03-30T15:00:00Z", "updated": "2024-03-30T15:00:00Z", }, "links": { "self": "https://api.ittybit.com/tasks/tsk_abcdefgh5678", "parent": "https://api.ittybit.com /tasks", }
Immediately after making a request, a Task
is created and the response returned will be a Task Object
in JSON format. The status will show as processing
until the task is completed. Making the same request again once it has completed will return the Task Object
with the status as completed
and the output data which will include a link to the output source file.
Body Parameters
{_ "file_id": "file_abcdefgh1234", "kind": "video", "format": "mp4" }
Required:
-
Either
url
orfile_id
must be provided.url
string - The URL of the file to use as the input for the task. This must be a publicly accessible URL.file_id
string - The ID of the file to use as the input for the task. This must be a file that has been uploaded to Ittybit. You can find thefile_id
in the response when you upload a file via the API.
-
kind
string - The desired output type. SeeTasks
for availablekinds
:
Available formats
For a complete list of available kinds
and other modifiers, see the Tasks documentation.
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
Considerations
- Videos can be converted to audio or images. However, audio and images cannot be converted to videos.
- The output format must be compatible with the input file type. For example, a .mov file cannot be converted to a .mp3 file.
- This API can not upscale media files. For example, a 480p video cannot be converted to a 1080p video.