Tasks

Introduction

endpoints

_10
# Transform Tasks
_10
GET https://api.ittybit.com/tasks
_10
POST https://api.ittybit.com/tasks
_10
_10
# Task Details
_10
GET https://api.ittybit.com/tasks/:id

Tasks are the most direct way to create new objects from your existing Media.

Each task receives an input (typically a file_id) and creates an output. The output object must include a kind and may also include a set of options that are specific to the kind of task.

You can see a list of tasks, create new tasks, and view the status of a task using the endpoints below.


Endpoints

List Tasks

request.js
request.sh

_10
const BASE_URL = "https://api.ittybit.com";
_10
_10
const response = await fetch(`https://api.ittybit.com/tasks`, {
_10
headers: {
_10
Authorization: `Bearer ${ITTYBIT_API_KEY}`,
_10
},
_10
});

Returns a list of recent tasks.

Endpoint

GET /tasks

response.json

_37
{
_37
"meta":{
_37
"id": "req_abcdefgh1234",
_37
"org_id": "org_abcdefgh1234",
_37
"project_id": "prj_abcdefgh1234",
_37
"method": "GET",
_37
"host": "https://api.ittybit.com",
_37
"path": "/tasks",
_37
"version": "2024-08-21",
_37
"status": 200,
_37
"type": "list",
_37
"total": 18,
_37
"limit": 12,
_37
"page": 1,
_37
"pages": 2
_37
},
_37
"data": [
_37
{
_37
"id": "tsk_abcdefgh1234",
_37
"object": "task",
_37
"input": "med_abcdefgh1234",
_37
"output": {
_37
"kind": "image",
_37
"filename": "poster.jpg",
_37
"width": 640,
_37
},
_37
"created": "2024-03-30T13:00:00Z",
_37
"updated": "2024-03-30T13:00:01Z",
_37
"status": "ready"
_37
}
_37
],
_37
"links": {
_37
"self": "https://api.ittybit.com/tasks",
_37
"next": "https://api.ittybit.com/tasks?page=2",
_37
"prev": null,
_37
}
_37
}

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 are created, updated, filesize.

  • order string

    The order to sort by. Default is desc. Possible values are asc, desc.

  • kind string

    The kind of tasks to return. Possible values are image, video, audio, or any of the source, track, or intelligence task kinds.

  • status string

    The status of the tasks to return. Possible values are ready, processing, waiting, error.


Create Task

request.js
request.sh

_17
const BASE_URL = "https://api.ittybit.com";
_17
_17
const response = await fetch(`https://api.ittybit.com/tasks`, {
_17
headers: {
_17
Method: "POST",
_17
Authorization: `Bearer ${ITTYBIT_API_KEY}`,
_17
"Content-Type": "application/json",
_17
body: JSON.stringify({
_17
input: "med_abcdefgh1234",
_17
output: {
_17
kind: "image",
_17
filename: "poster.jpg",
_17
width: 640,
_17
},
_17
}),
_17
},
_17
});

Creates a new task, which will use the file passed in via the input prop and create a new file based on the output props.

The example given creates a new image from a video, with the filename poster.jpg and a width of 640 pixels.

For a full list of available output kinds and options, see the Sources, Intelligence, and Tracks documentation.

Endpoint

POST /tasks

response.json

_30
{
_30
"meta":{
_30
"id": "req_abcdefgh1234",
_30
"org_id": "org_abcdefgh1234",
_30
"project_id": "prj_abcdefgh5678",
_30
"method": "POST",
_30
"host": "https://api.ittybit.com",
_30
"path": "/tasks",
_30
"version": "2024-08-21",
_30
"status": 200,
_30
"type": "object"
_30
},
_30
"data": {
_30
"id": "tsk_abcdefgh5678",
_30
"object": "task",
_30
"input": "med_abcdefgh1234",
_30
"output": {
_30
"kind": "image",
_30
"filename": "poster.jpg",
_30
"width": 640,
_30
},
_30
"status": "processing",
_30
"created": "2024-03-30T15:00:00Z",
_30
"updated": "2024-03-30T15:00:00Z",
_30
},
_30
"links": {
_30
"self": "https://api.ittybit.com/tasks/tsk_abcdefgh5678",
_30
"parent": "https://api.ittybit.com/tasks",
_30
}
_30
}

Body Parameters

  • input string

    The ID of the media to use as the input for the task. You can use a media_id: the id from a Media object, or a file_id: the id from a File object.

  • output object

    Defines the output for the task. The output object must include a kind and may include additional options that are specific to the kind of task. The Sources, Intelligence, and Tracks documentation contain a full list of all available output kinds and their available options.


View Task

request.js
request.sh

_10
const BASE_URL = "https://api.ittybit.com";
_10
_10
const response = await fetch(`https://api.ittybit.com/tasks/tsk_abcdefgh1234`, {
_10
headers: {
_10
Authorization: `Bearer ${ITTYBIT_API_KEY}`,
_10
},
_10
});

Returns the details for a single task.

Endpoint

GET /tasks/:id

response.json

_32
{
_32
"meta":{
_32
"id": "req_abcdefgh1234",
_32
"org_id": "org_abcdefgh1234",
_32
"project_id": "prj_abcdefgh1234",
_32
"method": "GET",
_32
"host": "https://api.ittybit.com",
_32
"path": "/tasks/tsk_abcdefgh1234",
_32
"version": "2024-08-21",
_32
"status": 200,
_32
"type": "object"
_32
},
_32
"data": {
_32
"id": "tsk_abcdefgh1234",
_32
"object": "task",
_32
"input": "med_abcdefgh1234",
_32
"output": {
_32
"id": "file_abcdefgh1234",
_32
"object": "source",
_32
"kind": "image",
_32
// ... Source object
_32
// https://ittybit.com/docs/api/sources
_32
},
_32
"status": "ready",
_32
"created": "2024-03-30T13:00:00Z",
_32
"updated": "2024-03-30T13:00:01Z",
_32
},
_32
"links": {
_32
"self": "https://api.ittybit.com/tasks/tsk_abcdefgh1234",
_32
"parent": "https://api.ittybit.com/tasks",
_32
}
_32
}

Response Parameters

  • id string

    Unique identifier for the task.

  • object string

    Always task.

  • input string

    The ID of the Media or File that was used as the input for the task.

  • output integer

    An object that details the created output. Will always include an id, object, and kind. The object will depend on the kind passed in to the task when it was created. If the task has completed successfully, the output object will include the created Source, Intelligence, or Track object.

  • status string

    The status of the task. Possible values are waiting, processing, ready, error.

  • created datetime

    The date and time the task was created. ISO 8601 format.

  • updated datetime

    The date and time the task was last updated. ISO 8601 format.