Upload video from source
api.video enables you to upload a video container file via a URL , or clone one of your existing videos .
Upload a file from a URL
Uploading a video from a video URL enables you go through the whole video upload process in only 1 step. Paste a URL that points to your video container (for example, the .mp4
file of your video) into the source
field in your request:
cURL
curl --user *your_api_key*: \
--request POST \
--url https://ws.api.video/videos \
--header 'Content-Type: application/json' \
--data '
{
"title": "My First Video",
"source": "https://www.myvideourl.com/video.mp4"
}
'
Javascript
const client = new ApiVideoClient ( { apiKey : " YOUR_API_KEY" } ) ;
const video = await client . videos . create ( {
title : " My First Video" ,
source : " https://www.myvideourl.com/video.mp4"
} ) ;
PHP
// First install the api client: "composer require api-video/php-api-client"
// Documentation: https://github.com/apivideo/api.video-php-client/blob/main/docs/Api/VideosApi.md#create
$client = new \ApiVideo\Client\Client(
'https://ws.api.video',
'YOUR_API_KEY',
new \Symfony\Component\HttpClient\Psr18Client()
);
$video = $client->videos()->create((new \ApiVideo\Client\Model\VideoCreationPayload())
->setTitle("My First Video")
->setSource("https://www.myvideourl.com/video.mp4"));
Java
ApiVideoClient client = new ApiVideoClient ( " YOUR_API_KEY" ) ;
VideoCreationPayload videoCreationPayload = new VideoCreationPayload ( ) ;
videoCreationPayload. setTitle ( " My First Video" ) ;
videoCreationPayload. setSource ( " https://www.myvideourl.com/video.mp4" ) ;
try {
Video video = client. videos ( ) . create ( videoCreationPayload) ;
} catch ( ApiException e ) {
}
Kotlin
val client = ApiVideoClient(" YOUR_API_KEY" )
val videoCreationPayload = VideoCreationPayload()
videoCreationPayload. title = " My First Video"
videoCreationPayload. source = " https://www.myvideourl.com/video.mp4"
try {
val video = client. videos(). create(videoCreationPayload)
} catch (e: ApiException) {
}
Python
from apivideo . api . videos_api import VideosApi
from apivideo . model . video_creation_payload import VideoCreationPayload
from apivideo import AuthenticatedApiClient , ApiException
with AuthenticatedApiClient ( " YOUR_API_KEY" ) as api_client :
video_creation_payload = VideoCreationPayload (
title = " My First Video" ,
source = " https://www.myvideourl.com/video.mp4"
)
try :
video = VideosApi ( api_client ) . create ( video_creation_payload )
except ApiException as e :
Go
client := apivideosdk . ClientBuilder ( " YOUR_API_KEY" ) . Build ( )
videoCreationPayload := apivideosdk . VideoCreationPayload { }
videoCreationPayload . SetTitle ( " My First Video" )
videoCreationPayload . SetSource ( " https://www.myvideourl.com/video.mp4" )
video , err := client . Videos . Create ( videosCreationPayload )
if video != nil {
}
Swift
ApiVideoClient. apiKey = " Y O U R _ A P I _ K E Y "
let videoCreationPayload = VideoCreationPayload(
title: " M y F i r s t V i d e o " ,
source: " h t t p s : / / w w w . m y v i d e o u r l . c o m / v i d e o . m p 4 "
)
VideosAPI. create(videoCreationPayload: videoCreationPayload) { video, error in
if let video = video {
}
if let error = error {
}
}
C#
// First add the "ApiVideo" NuGet package to your project
// Documentation: https://github.com/apivideo/api.video-csharp-client/blob/main/docs/VideosApi.md#create
var apiVideoClient = new ApiVideoClient("YOUR_API_KEY");
var videoCreationPayload = new VideoCreationPayload()
{
title = "My First Video",
source = "https://www.myvideourl.com/video.mp4"
};
try
{
var video = apiVideoClient.Videos().create(videoCreationPayload);
}
catch (ApiException e)
{
// Manage error here
}
Replace the link in the example above with your video container (for example, the .mp4
file of your video). If you don’t have a video URL to test this, you can use this one for example.
Clone an existing video
You can clone a video that already exists in your api.video project. Just paste your video's videoId
into the source
field in your request:
cURL
curl --user *your_api_key*: \
--request POST \
--url https://ws.api.video/videos \
--header 'Content-Type: application/json' \
--data '
{
"title": "My Cloned Video",
"source": "your_video_id_here"
}
'
Javascript
const client = new ApiVideoClient ( { apiKey : " YOUR_API_KEY" } ) ;
const video = await client . videos . create ( {
title : " My Cloned Video" ,
source : " your_video_id_here"
} ) ;
PHP
// First install the api client: "composer require api-video/php-api-client"
// Documentation: https://github.com/apivideo/api.video-php-client/blob/main/docs/Api/VideosApi.md#create
$client = new \ApiVideo\Client\Client(
'https://ws.api.video',
'YOUR_API_KEY',
new \Symfony\Component\HttpClient\Psr18Client()
);
$video = $client->videos()->create((new \ApiVideo\Client\Model\VideoCreationPayload())
->setTitle("My Cloned Video")
->setSource("your_video_id_here"));
Java
ApiVideoClient client = new ApiVideoClient ( " YOUR_API_KEY" ) ;
VideoCreationPayload videoCreationPayload = new VideoCreationPayload ( ) ;
videoCreationPayload. setTitle ( " My Cloned Video" ) ;
videoCreationPayload. setSource ( " your_video_id_here" ) ;
try {
Video video = client. videos ( ) . create ( videoCreationPayload) ;
} catch ( ApiException e ) {
}
Kotlin
val client = ApiVideoClient(" YOUR_API_KEY" )
val videoCreationPayload = VideoCreationPayload()
videoCreationPayload. title = " My Cloned Video"
videoCreationPayload. source = " your_video_id_here"
try {
val video = client. videos(). create(videoCreationPayload)
} catch (e: ApiException) {
}
Python
from apivideo . api . videos_api import VideosApi
from apivideo . model . video_creation_payload import VideoCreationPayload
from apivideo import AuthenticatedApiClient , ApiException
with AuthenticatedApiClient ( " YOUR_API_KEY" ) as api_client :
video_creation_payload = VideoCreationPayload (
title = " My Cloned Video" ,
source = " your_video_id_here"
)
try :
video = VideosApi ( api_client ) . create ( video_creation_payload )
except ApiException as e :
Go
client := apivideosdk . ClientBuilder ( " YOUR_API_KEY" ) . Build ( )
videoCreationPayload := apivideosdk . VideoCreationPayload { }
videoCreationPayload . SetTitle ( " My Cloned Video" )
videoCreationPayload . SetSource ( " your_video_id_here" )
video , err := client . Videos . Create ( videosCreationPayload )
if video != nil {
}
Swift
ApiVideoClient. apiKey = " Y O U R _ A P I _ K E Y "
let videoCreationPayload = VideoCreationPayload(
title: " M y C l o n e d V i d e o " ,
source: " y o u r _ v i d e o _ i d _ h e r e 4 "
)
VideosAPI. create(videoCreationPayload: videoCreationPayload) { video, error in
if let video = video {
}
if let error = error {
}
}
C#
// First add the "ApiVideo" NuGet package to your project
// Documentation: https://github.com/apivideo/api.video-csharp-client/blob/main/docs/VideosApi.md#create
var apiVideoClient = new ApiVideoClient("YOUR_API_KEY");
var videoCreationPayload = new VideoCreationPayload()
{
title = "My Cloned Video",
source = "your_video_id_here"
};
try
{
var video = apiVideoClient.Videos().create(videoCreationPayload);
}
catch (ApiException e)
{
// Manage error here
}
API response
202 - Accepted video object creation from source URL or source Video ID (for cloning)
{
" videoId" : " your_video_id_here" ,
" assets" : {
. . .
" player" : " https://embed.api.video/vod/{videoId}" ,
. . .
}
}
Watch and share your video
The easiest way to play your video is to use the api.video player URL that you received in the API response :
"player": "https://embed.api.video/vod/{videoId}"
To watch your video, just paste the link into your favorite browser. Use the same link to share your video.
Manage your video
You can do many things to manage existing videos in your api.video environment: