JavaScript API Tree
If you need more than events and methods offer, the API tree will be of use
API allows you to do many things, such as creating video, updating video (and its data) and removing the same and as such allows you to do things your way, while still communicating with our servers.
It is good to point out that if you are looking for a way to do it quickly and easily, checking out our Browser Interaction pages might be a better option, while API is definitely good for all those things that you need a bit of extra touch on.
API Segments
There are 2 main parts of the API connected to your media:
- Main media element or container. For example "Videos"
- Video object will work directly with a video and will hold all of the details of the same
- Streams
- Streams are part of the video object and as such you can have many streams available under the same video and action on a single stream would not affect the video as a whole, just that specific stream.
All of the calls are done with the use of your Ziggeo application. This way you can easily have multiple applications on the same page doing their own API calls.
It also means that you will need to have the application already created and available at the moment that you are making the call. The best place to see how, is to check out our header page.
In our example here the application will be declared as follows, however options in the application generally can only affect the auth request.
Ziggeo (on page) Application Initialization
<script>
var ziggeo_app = new ZiggeoApi.V2.Application({
token:"APPLICATION_TOKEN",
webrtc_streaming_if_necessary: true,
webrtc_on_mobile: true,
auth: true
});
</script>
URL Structure
VIDEOS /v1/applications/*application_token*/videos/*videos_token_or_key*/
The videos resource allows you to access all single videos. Each video may contain more than one stream.
STREAMS /v1/applications/*application_token*/videos/*video_token_or_key*/streams/*streams_token_or_key*/
The streams resource allows you to directly access all streams associated with a single video.
AUDIOS /v1/applications/*application_token*/audios/*audios_token_or_key*/
The audios resource allows you to access all single audios. Each audios may contain more than one audio stream.
AUDIO STREAMS /v1/applications/*application_token*/audios/*audio_token_or_key*/streams/*audio_streams_token_or_key*/
The audio streams resource allows you to directly access all streams associated with a single audio.
IMAGES /v1/applications/*application_token*/images/*images_token_or_key*/
The images resource allows you to access all single images. Each image may contain more than one image stream.
IMAGE STREAMS /v1/applications/*application_token*/images/*image_token_or_key*/streams/*image_streams_token_or_key*/
The image streams resource allows you to directly access all streams associated with a single image.
VIDEO CALLS /v1/applications/*application_token*/*video_calls_token_or_key*/
Working with Videos API
- Videos
- index
Query an array of videos (will return at most 50 videos by default). Newest videos come first.
RAW: [GET]
/v1/applications/*application_token*/videos/
Return type: JSON
Arguments limit Limit the number of returned videos. Can be set up to 100. skip Skip the first [n] entries. reverse Reverse the order in which videos are returned. states Filter videos by state tags Filter the search result to certain tags
var response = ziggeo_app.videos.index(data_object); response.success( function (data) { //Your success code here. }); response.error(function (error) { //Your error handling code here });
This function can also be used with auth tokens as follows:var response = ziggeo_app.videos.index(data_object, {"server_auth": "your_auth_token" }); response.success( function (data) { //Your success code here. }); response.error(function (error) { //Your error handling code here });
- destroy
Delete a single video by token or key.
RAW: [DELETE]
/v1/applications/*application_token*/videos/*video_token*
Arguments video_token_or_key Token or a key identifying the same.
var response = ziggeo_app.videos.destroy(token_or_key); response.success( function (data) { //Your success code here. }); response.error(function (error) { //Your error handling code here });
This function can also be used with auth tokens as follows:var response = ziggeo_app.videos.destroy(token_or_key, {"server_auth": "your_auth_token" }); response.success( function (data) { //Your success code here. }); response.error(function (error) { //Your error handling code here });
- destroy_file
Delete all of the video's stream files.
RAW: [DELETE]
/v1/applications/*application_token*/videos/*video_token*
Arguments video_token_or_key Token or a key identifying the same.
var response = ziggeo_app.videos.destroy_file(token_or_key); response.success( function (data) { //Your success code here. }); response.error(function (error) { //Your error handling code here });
This function can also be used with auth tokens as follows:var response = ziggeo_app.videos.destroy_file(token_or_key, {"server_auth": "your_auth_token" }); response.success( function (data) { //Your success code here. }); response.error(function (error) { //Your error handling code here });
- create
Create a new video.
RAW: [POST]
/v1/applications/*application_token*/videos
Return type: JSON
Arguments file Video file to be uploaded. min_duration Minimal duration of video. max_duration Maximal duration of video. tags Video Tags. key Unique (optional) name of video. volatile Automatically remove this video if it remains empty.
var response = ziggeo_app.videos.create(data_object); response.success( function (data) { //Your success code here. }); response.error(function (error) { //Your error handling code here });
This function can also be used with auth tokens as follows:var response = ziggeo_app.videos.create(data_object, {"server_auth": "your_auth_token" }); response.success( function (data) { //Your success code here. }); response.error(function (error) { //Your error handling code here });
- update
Update an existing video.
RAW: [POST]
/v1/applications/*application_token*/videos/*video_token*
Return type: JSON
Arguments min_duration Minimal duration of video. max_duration Maximal duration of video. tags Video Tags. key Unique (optional) name of video. volatile Automatically remove this video if it remains empty. expiration_days After how many days will this video be deleted.
var response = ziggeo_app.videos.update(video_token_or_key, data_object); response.success( function (data) { //Your success code here. }); response.error(function (error) { //Your error handling code here });
This function can also be used with auth tokens as follows:var response = ziggeo_app.videos.update(video_token_or_key, data_object, {"server_auth": "your_auth_token" }); response.success( function (data) { //Your success code here. }); response.error(function (error) { //Your error handling code here });
- get
Read an existing video.
RAW: [GET]
/v1/applications/*application_token*/videos/*video_token*
Return type: JSON
Arguments video_token_or_key Token or a key identifying the same.
var response = ziggeo_app.videos.get(token_or_key); response.success( function (data) { //Your success code here. }); response.error(function (error) { //Your error handling code here });
This function can also be used with auth tokens as follows:var response = ziggeo_app.videos.get(token_or_key, {"server_auth": "your_auth_token" }); response.success( function (data) { //Your success code here. }); response.error(function (error) { //Your error handling code here });
- image
Get URL of the thumbnail.
RAW:
/v1/applications/*application_token*/videos/*video_token*
Return type: URL
Arguments video_token_or_key Token or a key identifying the same.
var response = ziggeo_app.videos.image(token_or_key);
This function can also be used with auth tokens as follows:ziggeo_app.videos.image(token_or_key, {"server_auth": "your_auth_token" } );
- source
Get URL of the video file.
RAW:
/v1/applications/*application_token*/videos/*video_token*
Return type: URL
Arguments video_token_or_key Token or a key identifying the same.
var response = ziggeo_app.videos.source(token_or_key);
This function can also be used with auth tokens as follows:ziggeo_app.videos.source(token_or_key, {"server_auth": "your_auth_token" } );
- index
Working with Video Streams API
- Streams
- destroy
Delete the stream
RAW: [DELETE]
/v1/applications/*application_token*/videos/*video_token_or_key*/streams/*stream_token*
Arguments video_token Token or a key identifying the video. stream_token_or_key Token or a key identifying the same.
var response = ziggeo_app.streams.destroy(video_token, stream_token_or_key); response.success( function (data) { //Your success code here. }); response.error(function (error) { //Your error handling code here });
This function can also be used with auth tokens as follows:var response = ziggeo_app.streams.destroy(video_token, stream_token_or_key, {"server_auth": "your_auth_token" }); response.success( function (data) { //Your success code here. }); response.error(function (error) { //Your error handling code here });
- destroy_file
Delete the stream's file
RAW: [DELETE]
/v1/applications/*application_token*/videos/*video_token_or_key*/streams/*stream_token*
Arguments video_token Token or a key identifying the video. stream_token_or_key Token or a key identifying the same.
var response = ziggeo_app.streams.destroy_file(video_token, stream_token_or_key); response.success( function (data) { //Your success code here. }); response.error(function (error) { //Your error handling code here });
This function can also be used with auth tokens as follows:var response = ziggeo_app.streams.destroy_file(video_token, stream_token_or_key, {"server_auth": "your_auth_token" }); response.success( function (data) { //Your success code here. }); response.error(function (error) { //Your error handling code here });
- create
Create a new stream
RAW: [POST]
/v1/applications/*application_token*/videos/*video_token_or_key*/streams
Return type: JSON
Arguments video_token Token or a key identifying the video. file Video file to be uploaded
var response = ziggeo_app.streams.create(video_token, data_object); response.success( function (data) { //Your success code here. }); response.error(function (error) { //Your error handling code here });
This function can also be used with auth tokens as follows:var response = ziggeo_app.streams.create(video_token, data_object, {"server_auth": "your_auth_token" }); response.success( function (data) { //Your success code here. }); response.error(function (error) { //Your error handling code here });
- accept
Accept stream
RAW: [POST]
/v1/applications/*application_token*/videos/*video_token_or_key*/streams/*stream_token*
Return type: JSON
Arguments video_token Token or a key identifying the video. stream_token_or_key Token or a key identifying the same.
var response = ziggeo_app.streams.accept(video_token, stream_token_or_key); response.success( function (data) { //Your success code here. }); response.error(function (error) { //Your error handling code here });
This function can also be used with auth tokens as follows:var response = ziggeo_app.streams.accept(video_token, stream_token_or_key, {"server_auth": "your_auth_token" }); response.success( function (data) { //Your success code here. }); response.error(function (error) { //Your error handling code here });
- destroy