Learn to create video sources, transcode jobs, configure storage, and set up webhooks with code examples.
The Chunkify API provides an easy interface to state of the art video transcoding. It allows you to have a powerful and lightning fast video transcoding solution and easily integrate it within your existing workflows.
We will see some of the steps displayed in the workflow page.
Create a source from a hosted file
You can create a source from an already hosted file. Once the source is created, you can access all its specs.
We strongly recommend using S3 or an equivalent cloud storage for your
hosted source files to ensure fast uploads and optimal performances.
importChunkifyfrom'@chunkify/chunkify';constclient=newChunkify({projectAccessToken:'My Project Access Token',});// Create the source
constsource=awaitclient.sources.create({url:'https://example.com/video.mp4'});// You can access the source specs
console.log(source);
fromchunkifyimportChunkifyclient=Chunkify(project_access_token="My Project Access Token",)# Create the sourcesource=client.sources.create(url="https://example.com/video.mp4",)# Access the source specsprint(source)
useChunkify\Client;$client=newClient(projectAccessToken:'My Project Access Token',);// Create the source
$source=$client->sources->create(url:'https://example.com/video.mp4',);// You can access the source specs
print_r($source);
import("context""fmt""github.com/chunkifydev/chunkify-go""github.com/chunkifydev/chunkify-go/option")client:=chunkify.NewClient(option.WithProjectAccessToken("My Project Access Token"),)// Create the source
source,err:=client.Sources.New(context.TODO(),chunkify.SourceNewParams{URL:"https://example.com/video.mp4",})iferr!=nil{log.Fatal(err)}// You can access the source specs
fmt.Printf("%+v\n",source)
Configure your development environment
Install and configure an official Chunkify SDK to run the code above.
Create a transcode job
When your source is ready to use, you can create a transcode job using the source ID. Here is a basic example using h264 format and 720p resolution.
importChunkifyfrom'@chunkify/chunkify';constclient=newChunkify({projectAccessToken:'My Project Access Token',});// Transcode using h264 format with 720p resolution
constjob=awaitclient.jobs.create({source_id: source.id,format:{id:'mp4_h264',height: 720,}});
fromchunkifyimportChunkifyclient=Chunkify(project_access_token="My Project Access Token",)# Transcode using h264 format with 720p resolutionjob=client.jobs.create(source_id=source.id,format={"id":"mp4_h264","height":720,})
useChunkify\Client;$client=newClient(projectAccessToken:'My Project Access Token',);// Transcode using h264 format with 720p resolution
$job=$client->jobs->create(sourceID:$source->id,format:['id'=>'mp4_h264','height'=>720],);
import("context""github.com/chunkifydev/chunkify-go""github.com/chunkifydev/chunkify-go/option")client:=chunkify.NewClient(option.WithProjectAccessToken("My Project Access Token"),)// Transcode using h264 format with 720p resolution
jobParams:=chunkify.JobNewParams{SourceID:source.ID,Format:chunkify.JobNewParamsFormatUnion{OfMP4H264:&chunkify.MP4H264Param{Height:chunkify.Int(720),},},}job,err:=client.Jobs.New(context.TODO(),jobParams)iferr!=nil{log.Fatal(err)}
Learn more about transcoder settings
See how to configure your video processing settings.
Learn more about video format and codecs
See how to configure your transcode format and codec settings.
Setting up your storage
The storage is where the processed files are kept.
Currently Chunkify supports AWS S3 storages and Cloudflare R2 storages.
By default Chunkify provides a test storage, this is for development and
test purposes only. All the files will be deleted 24h after their creation.
For production you'll need to setup your own storage to keep your processed
files safe.
To setup your own storage you have to create one and attach it to your project. The project ID is availaible in the Chunkify app under
the project settings, or you can use the API to get it.
importChunkifyfrom'@chunkify/chunkify';letclient=newChunkify({projectAccessToken:'My Project Access Token',});// Create a new storage
conststorage=awaitclient.storages.create({storage:{access_key_id:'1234567890',bucket:'my-bucket',provider:'aws',region:'us-east-1',secret_access_key:'1234567890',base_prefix:'chunkify/',public:false,}});// Attach the storage to your project to use it
// Note: This requires a team access token, not a project access token
client=newChunkify({teamAccessToken:'My Team Access Token',});awaitclient.projects.update('projectId',{storage_id: storage.id});
fromchunkifyimportChunkifyclient=Chunkify(project_access_token="My Project Access Token",)# Create a new storagestorage=client.storages.create(storage={"access_key_id":"1234567890","bucket":"my-bucket","provider":"aws","region":"us-east-1","secret_access_key":"1234567890","base_prefix":"chunkify/","public":False,})# Attach the storage to your project to use it# This requires a team access token, not a project access tokenclient=Chunkify(team_access_token="My Team Access Token",)client.projects.update(project_id=project.id,storage_id=storage.id,)
useChunkify\Client;$client=newClient(projectAccessToken:'My Project Access Token',);// Create a storage
$storage=$client->storages->create(['bucket'=>'my-bucket','provider'=>'aws','accessKeyID'=>'1234567890','secretAccessKey'=>'abcdefghijklmnopqrstuvwxyz','region'=>'us-east-1','basePrefix'=>'chunkify/','public'=>false,]);// Attach the storage to your project to use it
// Note: This requires a team access token, not a project access token
$client=newClient(teamAccessToken:'My Team Access Token',);$client->projects->update(projectID:'projectId',storageID:$storage->id,);
import("context""github.com/chunkifydev/chunkify-go""github.com/chunkifydev/chunkify-go/option")client:=chunkify.NewClient(option.WithProjectAccessToken("My Project Access Token"),)// Create a new Storage
storage,err:=client.Storages.New(context.TODO(),chunkify.StorageNewParams{OfAws:&chunkify.StorageNewParamsStorageAws{AccessKeyID:"1234567890",Bucket:"my-bucket",Region:"us-east-1",SecretAccessKey:"1234567890",BasePrefix:"chunkify/",Public:chunkify.Bool(false),},})iferr!=nil{panic(fmt.Errorf("Error creating storage: %v",err))}// Attach the storage to your project to use it
// Note: This requires a team access token, not a project access token
client=chunkify.NewClient(option.WithTeamAccessToken("My Team Access Token"),)err=client.Projects.Update(context.TODO(),project.ID,chunkify.ProjectUpdateParams{chunkify.String(storage.ID),},)iferr!=nil{panic(fmt.Errorf("Error updating project: %v",err))}
Learn more about storages
Check how we are handling storages and files.
Setting up a Webhook
Webhooks are a powerful tool that enables event-driven behavior. Rather than periodically checking the status of your jobs, you can set up a webhook to trigger a workflow when a job is completed.
Chunkify can send notifications for various events throughout the transcoding process.
Here when a job is completed Chunkify will send a notification to the webhook URL
importChunkifyfrom'@chunkify/chunkify';constclient=newChunkify({projectAccessToken:'My Project Access Token',});// Create a webhook
constwebhook=awaitclient.webhooks.create({url:'https://example.com/webhook',events:['job.completed'],})
fromchunkifyimportChunkifyclient=Chunkify(project_access_token="My Project Access Token",)# Create a webhookwebhook=client.webhooks.create(url="https://example.com/webhook",events=["job.completed"],)
useChunkify\Client;$client=newClient(projectAccessToken:'My Project Access Token',);// Create a webhook
$webhook=$client->webhooks->create(url:'https://example.com/webhook',events:['job.completed'],);
import("context""github.com/chunkifydev/chunkify-go""github.com/chunkifydev/chunkify-go/option")client:=chunkify.NewClient(option.WithProjectAccessToken("My Project Access Token"),)// Create a webhook
webhookParams:=chunkify.WebhookNewParams{URL:"https://example.com/webhook",Events:[]string{"job.completed",},}webhook,err:=client.Webhooks.New(context.TODO(),webhookParams)iferr!=nil{log.Fatal(err)}
We provide a way to test your webhook/notification workflow locally, for
this you can use our CLI, see how to do it in the CLI section
Learn more about webhooks
Understand how our webhooks and notifications system works.
# Quickstart
> Learn to create video sources, transcode jobs, configure storage, and set up webhooks with code examples.
The Chunkify API provides an easy interface to state of the art video transcoding. It allows you to have a powerful and lightning fast video transcoding solution and easily integrate it within your existing workflows.
We will see some of the steps displayed in the [workflow](/docs/workflow) page.
### Create a source from a hosted file
You can create a source from an already hosted file. Once the source is created, you can access all its specs.
<note>
We strongly recommend using S3 or an equivalent cloud storage for your
hosted source files to ensure fast uploads and optimal performances.
</note>
<codegroup>
<codeblock lang="Typescript">
```typescript
import Chunkify from '@chunkify/chunkify';
const client = new Chunkify({
projectAccessToken: 'My Project Access Token',
});
// Create the source
const source = await client.sources.create({ url: 'https://example.com/video.mp4' });
// You can access the source specs
console.log(source);
```
</codeblock>
<codeblock lang="Python">
```python
from chunkify import Chunkify
client = Chunkify(
project_access_token="My Project Access Token",
)
# Create the source
source = client.sources.create(
url="https://example.com/video.mp4",
)
# Access the source specs
print(source)
```
</codeblock>
<codeblock lang="PHP">
```php
use Chunkify\Client;
$client = new Client(
projectAccessToken: 'My Project Access Token',
);
// Create the source
$source = $client->sources->create(
url: 'https://example.com/video.mp4',
);
// You can access the source specs
print_r($source);
```
</codeblock>
<codeblock lang="Go">
```go Go
import (
"context"
"fmt"
"github.com/chunkifydev/chunkify-go"
"github.com/chunkifydev/chunkify-go/option"
)
client := chunkify.NewClient(
option.WithProjectAccessToken("My Project Access Token"),
)
// Create the source
source, err := client.Sources.New(context.TODO(), chunkify.SourceNewParams{
URL: "https://example.com/video.mp4",
})
if err != nil {
log.Fatal(err)
}
// You can access the source specs
fmt.Printf("%+v\n", source)
```
</codeblock>
</codegroup>
<card title="Configure your development environment" icon="<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-wrench-icon lucide-wrench"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z"/></svg>" layout="horizontal" href="/docs/integration/sdk">
Install and configure an official Chunkify SDK to run the code above.
</card>
### Create a transcode job
When your source is ready to use, you can create a transcode job using the source ID. Here is a basic example using h264 format and 720p resolution.
<codegroup>
<codeblock lang="Typescript">
```typescript
import Chunkify from '@chunkify/chunkify';
const client = new Chunkify({
projectAccessToken: 'My Project Access Token',
});
// Transcode using h264 format with 720p resolution
const job = await client.jobs.create({
source_id: source.id,
format: {
id: 'mp4_h264',
height: 720,
}
});
```
</codeblock>
<codeblock lang="Python">
```python
from chunkify import Chunkify
client = Chunkify(
project_access_token="My Project Access Token",
)
# Transcode using h264 format with 720p resolution
job = client.jobs.create(
source_id=source.id,
format={
"id": "mp4_h264",
"height": 720,
}
)
```
</codeblock>
<codeblock lang="PHP">
```php
use Chunkify\Client;
$client = new Client(
projectAccessToken: 'My Project Access Token',
);
// Transcode using h264 format with 720p resolution
$job = $client->jobs->create(
sourceID: $source->id,
format: ['id' => 'mp4_h264', 'height' => 720],
);
```
</codeblock>
<codeblock lang="Go">
```go
import (
"context"
"github.com/chunkifydev/chunkify-go"
"github.com/chunkifydev/chunkify-go/option"
)
client := chunkify.NewClient(
option.WithProjectAccessToken("My Project Access Token"),
)
// Transcode using h264 format with 720p resolution
jobParams := chunkify.JobNewParams{
SourceID: source.ID,
Format: chunkify.JobNewParamsFormatUnion{
OfMP4H264: &chunkify.MP4H264Param{
Height: chunkify.Int(720),
},
},
}
job, err := client.Jobs.New(context.TODO(), jobParams)
if err != nil {
log.Fatal(err)
}
```
</codeblock>
</codegroup>
<card title="Learn more about transcoder settings" icon="<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-video-icon lucide-video"><path d="m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"/><rect x="2" y="6" width="14" height="12" rx="2"/></svg>" layout="horizontal" href="/docs/transcoders">
See how to configure your video processing settings.
</card>
<card title="Learn more about video format and codecs" icon="<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-film-icon lucide-film"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 3v18"/><path d="M3 7.5h4"/><path d="M3 12h18"/><path d="M3 16.5h4"/><path d="M17 3v18"/><path d="M17 7.5h4"/><path d="M17 16.5h4"/></svg>" layout="horizontal" href="/docs/formats">
See how to configure your transcode format and codec settings.
</card>
### Setting up your storage
The storage is where the processed files are kept.
Currently Chunkify supports AWS S3 storages and Cloudflare R2 storages.
<warning>
By default Chunkify provides a test storage, this is for development and
test purposes only. All the files will be deleted 24h after their creation.
For production you'll need to setup your own storage to keep your processed
files safe.
</warning>
To setup your own storage you have to create one and attach it to your project. The project ID is availaible in the Chunkify app under
the project settings, or you can use the API to get it.
<codegroup>
<codeblock lang="Typescript">
```typescript
import Chunkify from '@chunkify/chunkify';
let client = new Chunkify({
projectAccessToken: 'My Project Access Token',
});
// Create a new storage
const storage = await client.storages.create({
storage: {
access_key_id: '1234567890',
bucket: 'my-bucket',
provider: 'aws',
region: 'us-east-1',
secret_access_key: '1234567890',
base_prefix: 'chunkify/',
public: false,
}
});
// Attach the storage to your project to use it
// Note: This requires a team access token, not a project access token
client = new Chunkify({
teamAccessToken: 'My Team Access Token',
});
await client.projects.update('projectId', { storage_id: storage.id });
```
</codeblock>
<codeblock lang="Python">
```python
from chunkify import Chunkify
client = Chunkify(
project_access_token="My Project Access Token",
)
# Create a new storage
storage = client.storages.create(
storage={
"access_key_id":"1234567890",
"bucket":"my-bucket",
"provider":"aws",
"region":"us-east-1",
"secret_access_key":"1234567890",
"base_prefix":"chunkify/",
"public":False,
}
)
# Attach the storage to your project to use it
# This requires a team access token, not a project access token
client = Chunkify(
team_access_token="My Team Access Token",
)
client.projects.update(
project_id=project.id,
storage_id=storage.id,
)
```
</codeblock>
<codeblock lang="PHP">
```php
use Chunkify\Client;
$client = new Client(
projectAccessToken: 'My Project Access Token',
);
// Create a storage
$storage = $client->storages->create([
'bucket' => 'my-bucket',
'provider' => 'aws',
'accessKeyID' => '1234567890',
'secretAccessKey' => 'abcdefghijklmnopqrstuvwxyz',
'region' => 'us-east-1',
'basePrefix' => 'chunkify/',
'public' => false,
]);
// Attach the storage to your project to use it
// Note: This requires a team access token, not a project access token
$client = new Client(
teamAccessToken: 'My Team Access Token',
);
$client->projects->update(
projectID: 'projectId',
storageID: $storage->id,
);
```
</codeblock>
<codeblock lang="Go">
```go
import (
"context"
"github.com/chunkifydev/chunkify-go"
"github.com/chunkifydev/chunkify-go/option"
)
client := chunkify.NewClient(
option.WithProjectAccessToken("My Project Access Token"),
)
// Create a new Storage
storage, err := client.Storages.New(context.TODO(), chunkify.StorageNewParams{
OfAws: &chunkify.StorageNewParamsStorageAws{
AccessKeyID: "1234567890",
Bucket: "my-bucket",
Region: "us-east-1",
SecretAccessKey: "1234567890",
BasePrefix: "chunkify/",
Public: chunkify.Bool(false),
},
})
if err != nil {
panic(fmt.Errorf("Error creating storage: %v", err))
}
// Attach the storage to your project to use it
// Note: This requires a team access token, not a project access token
client = chunkify.NewClient(
option.WithTeamAccessToken("My Team Access Token"),
)
err = client.Projects.Update(
context.TODO(),
project.ID,
chunkify.ProjectUpdateParams{
chunkify.String(storage.ID),
},
)
if err != nil {
panic(fmt.Errorf("Error updating project: %v", err))
}
```
</codeblock>
</codegroup>
<card title="Learn more about storages" icon="<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-hard-drive-icon lucide-hard-drive"><line x1="22" x2="2" y1="12" y2="12"/><path d="M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"/><line x1="6" x2="6.01" y1="16" y2="16"/><line x1="10" x2="10.01" y1="16" y2="16"/></svg>" layout="horizontal" href="/docs/storage">
Check how we are handling storages and files.
</card>
### Setting up a Webhook
Webhooks are a powerful tool that enables event-driven behavior. Rather than periodically checking the status of your jobs, you can set up a webhook to trigger a workflow when a job is completed.
Chunkify can send notifications for various events throughout the transcoding process.
Here when a job is completed Chunkify will send a notification to the webhook URL
<codegroup>
<codeblock lang="Typescript">
```typescript
import Chunkify from '@chunkify/chunkify';
const client = new Chunkify({
projectAccessToken: 'My Project Access Token',
});
// Create a webhook
const webhook = await client.webhooks.create({
url: 'https://example.com/webhook',
events: ['job.completed'],
})
```
</codeblock>
<codeblock lang="Python">
```python
from chunkify import Chunkify
client = Chunkify(
project_access_token="My Project Access Token",
)
# Create a webhook
webhook = client.webhooks.create(
url="https://example.com/webhook",
events=["job.completed"],
)
```
</codeblock>
<codeblock lang="PHP">
```php
use Chunkify\Client;
$client = new Client(
projectAccessToken: 'My Project Access Token',
);
// Create a webhook
$webhook = $client->webhooks->create(
url: 'https://example.com/webhook',
events: ['job.completed'],
);
```
</codeblock>
<codeblock lang="Go">
```go
import (
"context"
"github.com/chunkifydev/chunkify-go"
"github.com/chunkifydev/chunkify-go/option"
)
client := chunkify.NewClient(
option.WithProjectAccessToken("My Project Access Token"),
)
// Create a webhook
webhookParams := chunkify.WebhookNewParams{
URL: "https://example.com/webhook",
Events: []string{
"job.completed",
},
}
webhook, err := client.Webhooks.New(context.TODO(), webhookParams)
if err != nil {
log.Fatal(err)
}
```
</codeblock>
</codegroup>
<tip>
We provide a way to test your webhook/notification workflow locally, for
this you can use our CLI, see how to do it in the [CLI section](/docs/cli)
</tip>
<card title="Learn more about webhooks" layout="horizontal" icon="<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-webhook-icon lucide-webhook"><path d="M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2"/><path d="m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06"/><path d="m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8"/></svg>" href="/docs/integration/webhooks">
Understand how our webhooks and notifications system works.
</card>