Documentation

What if you wanted to work with the videos through the API + from your Ruby server codes? Well with Ziggeo that is very simple and here you will see more about how exactly you can do that.

You will see each method available and then example code that you can check to see a working example of the same.

Fork me on GitHub
  • index
    Query an array of videos (will return at most 50 videos by default). Newest videos come first.
    ziggeo.videos().index(arguments = nil)
    
    1. limit Limit the number of returned videos. Can be set up to 100.
    2. skip Skip the first [n] entries.
    3. reverse Reverse the order in which videos are returned.
    4. states Filter videos by state
    5. tags Filter the search result to certain tags, encoded as a comma-separated string
    This method returns JSON
    [
    	{
    	"volatile":false,
    	"token":"a7edab8c635ec37047d8ae75411528e3",
    	"key":null,
    	"state":5,
    	"max_duration":null,
    	"duration":1,
    	"tags":null,
    	"submission_date":1390257799,
    	"resubmission_date":1390257799,
    	"stream_submission_date":1390257799,
    	"delete_old_streams":true,
    	"type":"ApiVideo",
    	"created":1390257798,
    	"owned":false,
    	"state_string":"READY",
    	"streams":[
    	{
    		"volatile":false,
    		"token":"d751140b4e1cf0a243f32092f6110296",
    		"key":null,
    		"creation_type":5,
    		"state":5,
    		"streamable":2,
    		"video_type":"mp4",
    		"video_sub_type":"other",
    		"image_size":0,
    		"video_size":36078,
    		"video_width":640,
    		"video_height":360,
    		"duration":1,
    		"has_video":true,
    		"has_image":true,
    		"submission_date":1390257799,
    		"type":"ApiVideoStream",
    		"created":1390257799,
    		"owned":true,
    		"creation_type_string":"SERVER_UPLOAD",
    		"streamable_string":"DEGRADED",
    		"state_string":"READY"
    	}],
    	"original_stream":
    	{
    		"volatile":false,
    		"token":"d751140b4e1cf0a243f32092f6110296",
    		"key":null,
    		"creation_type":5,
    		"state":5,
    		"streamable":2,
    		"video_type":"mp4",
    		"video_sub_type":"other",
    		"image_size":0,
    		"video_size":36078,
    		"video_width":640,
    		"video_height":360,
    		"duration":1,
    		"has_video":true,
    		"has_image":true,
    		"submission_date":1390257799,
    		"type":"ApiVideoStream",
    		"created":1390257799,
    		"owned":true,
    		"creation_type_string":"SERVER_UPLOAD",
    		"streamable_string":"DEGRADED",
    		"state_string":"READY"
    	},
    	"default_stream":
    	{
    		"volatile":false,
    		"token":"d751140b4e1cf0a243f32092f6110296",
    		"key":null,
    		"creation_type":5,
    		"state":5,
    		"streamable":2,
    		"video_type":"mp4",
    		"video_sub_type":"other",
    		"image_size":0,
    		"video_size":36078,
    		"video_width":640,
    		"video_height":360,
    		"duration":1,
    		"has_video":true,
    		"has_image":true,
    		"submission_date":1390257799,
    		"type":"ApiVideoStream",
    		"created":1390257799,
    		"owned":true,
    		"creation_type_string":"SERVER_UPLOAD",
    		"streamable_string":"DEGRADED",
    		"state_string":"READY"
    	}}]
    
    Example:
    =begin
      This script shows you how to list all videos from your application.
    
      Parameters you need to pass:
        1. APP_TOKEN
        2. PRIVATE_KEY
    
      Example call:
        ruby videos_index.rb APP_TOKEN PRIVATE_KEY
        ruby videos_index.rb APP_TOKEN PRIVATE_KEY ENCRIPTION_KEY
    =end
    
    require_relative "../lib/Ziggeo"
    
    @ziggeo = Ziggeo.new(*ARGV)
    
    videos = []
    skip = 0
    limit = 100
    
    loop do
      videos = @ziggeo.videos.index(
        "skip": skip,
        "limit": limit
      )
    
      videos.each {
        |video| puts "Listing " + video["token"]
        skip += 1
      }
    
      break if videos.length == 0
    end
    
  • count
    Get the video count for the application.
    ziggeo.videos().count(arguments = nil)
    
    1. states Filter videos by state
    2. tags Filter the search result to certain tags, encoded as a comma-separated string
    This method returns JSON
    Example:
    =begin
      This script shows you how get the total number of videos in your application.
    
      Parameters you need to pass:
        1. APP_TOKEN
        2. PRIVATE_KEY
    
      Example call:
        ruby videos_count.rb APP_TOKEN PRIVATE_KEY
        ruby videos_count.rb APP_TOKEN PRIVATE_KEY ENCRIPTION_KEY
    =end
    
    require_relative "../lib/Ziggeo"
    
    result = Ziggeo.new(*ARGV).videos.count()
    
    puts result["count"]
    
  • get
    Get a single video by token or key.
    ziggeo.videos().get(token_or_key)
    
    This method returns JSON
    {
    	"volatile":false,
    	"token":"a7edab8c635ec37047d8ae75411528e3",
    	"key":null,
    	"state":5,
    	"max_duration":null,
    	"duration":1,
    	"tags":null,
    	"submission_date":1390257799,
    	"resubmission_date":1390257799,
    	"stream_submission_date":1390257799,
    	"delete_old_streams":true,
    	"type":"ApiVideo",
    	"created":1390257798,
    	"owned":false,
    	"state_string":"READY",
    	"streams":[
    	{
    		"volatile":false,
    		"token":"d751140b4e1cf0a243f32092f6110296",
    		"key":null,
    		"creation_type":5,
    		"state":5,
    		"streamable":2,
    		"video_type":"mp4",
    		"video_sub_type":"other",
    		"image_size":0,
    		"video_size":36078,
    		"video_width":640,
    		"video_height":360,
    		"duration":1,
    		"has_video":true,
    		"has_image":true,
    		"submission_date":1390257799,
    		"type":"ApiVideoStream",
    		"created":1390257799,
    		"owned":true,
    		"creation_type_string":"SERVER_UPLOAD",
    		"streamable_string":"DEGRADED",
    		"state_string":"READY"
    	}],
    	"original_stream":
    	{
    		"volatile":false,
    		"token":"d751140b4e1cf0a243f32092f6110296",
    		"key":null,
    		"creation_type":5,
    		"state":5,
    		"streamable":2,
    		"video_type":"mp4",
    		"video_sub_type":"other",
    		"image_size":0,
    		"video_size":36078,
    		"video_width":640,
    		"video_height":360,
    		"duration":1,
    		"has_video":true,
    		"has_image":true,
    		"submission_date":1390257799,
    		"type":"ApiVideoStream",
    		"created":1390257799,
    		"owned":true,
    		"creation_type_string":"SERVER_UPLOAD",
    		"streamable_string":"DEGRADED",
    		"state_string":"READY"
    	},
    	"default_stream":
    	{
    		"volatile":false,
    		"token":"d751140b4e1cf0a243f32092f6110296",
    		"key":null,
    		"creation_type":5,
    		"state":5,
    		"streamable":2,
    		"video_type":"mp4",
    		"video_sub_type":"other",
    		"image_size":0,
    		"video_size":36078,
    		"video_width":640,
    		"video_height":360,
    		"duration":1,
    		"has_video":true,
    		"has_image":true,
    		"submission_date":1390257799,
    		"type":"ApiVideoStream",
    		"created":1390257799,
    		"owned":true,
    		"creation_type_string":"SERVER_UPLOAD",
    		"streamable_string":"DEGRADED",
    		"state_string":"READY"
    	}}
    
    Example:
    =begin
      This script shows you how to get data from a single video.
    
      Parameters you need to pass:
        1. APP_TOKEN
        2. PRIVATE_KEY
        3. VIDEO_TOKEN
    
      Example call:
        ruby videos_get.rb APP_TOKEN PRIVATE_KEY VIDEO_TOKEN
    =end
    
    require 'json'
    require_relative "../lib/Ziggeo"
    
    app_token = ARGV[0]
    private_key = ARGV[1]
    video_token = ARGV[2]
    
    @ziggeo = Ziggeo.new(app_token, private_key)
    video_data = @ziggeo.videos.get(video_token)
    
    puts JSON.pretty_generate(video_data)
    
  • get_bulk
    Get multiple videos by tokens or keys.
    ziggeo.videos().get_bulk(arguments = nil)
    
    1. tokens_or_keys Comma-separated list with the desired videos tokens or keys (Limit: 100 tokens or keys).
    This method returns JSON
    Example:
    =begin
      This script shows you how to get data from more than one video at once.
    
      Parameters you need to pass:
        1. APP_TOKEN
        2. PRIVATE_KEY
        3. VIDEO_TOKENS
    
      Example call:
        ruby videos_get_bulk.rb APP_TOKEN PRIVATE_KEY VIDEO_TOKEN1 VIDEO_TOKEN2 ... VIDEO_TOKENn
    =end
    
    require_relative "../lib/Ziggeo"
    
    app_token, private_key = ARGV.shift(2)
    video_tokens = ARGV.join(",")
    
    puts "Comma-separated list of tokens/keys: " + "\"" + video_tokens + "\""
    
    @ziggeo = Ziggeo.new(app_token, private_key)
    
    result = @ziggeo.videos.get_bulk(
      tokens_or_keys: video_tokens
    )
    
    puts result
    
  • stats_bulk
    Get stats for multiple videos by tokens or keys.
    ziggeo.videos().stats_bulk(arguments = nil)
    
    1. tokens_or_keys Comma-separated list with the desired videos tokens or keys (Limit: 100 tokens or keys).
    2. summarize Boolean. Set it to TRUE to get the stats summarized. Set it to FALSE to get the stats for each video in a separate array. Default: TRUE.
    This method returns JSON
    Example:
    =begin
      This script shows you how to get stats from more than one video at once.
    
      Parameters you need to pass:
        1. APP_TOKEN
        2. PRIVATE_KEY
        3. VIDEO_TOKENS
    
      Example call:
        ruby videos_stats_bulk.rb APP_TOKEN PRIVATE_KEY VIDEO_TOKEN1 VIDEO_TOKEN2 ... VIDEO_TOKENn
    =end
    
    require_relative "../lib/Ziggeo"
    
    app_token, private_key = ARGV.shift(2)
    video_tokens = ARGV.join(",")
    
    puts "Comma-separated list of tokens/keys: " + video_tokens
    
    @ziggeo = Ziggeo.new(app_token, private_key)
    
    result = @ziggeo.videos.stats_bulk(
      tokens_or_keys: video_tokens,
      summarize: false
    )
    
    puts result
    
  • download_video
    Download the video data file
    ziggeo.videos().download_video(token_or_key)
    
    This method returns DATA
    Example:
    =begin
      This script shows you how to download a single video.
    
      Parameters you need to pass:
        1. APP_TOKEN
        2. PRIVATE_KEY
        3. VIDEO_TOKEN
        4. FILE_NAME
    
      Example call:
        ruby videos_download_video.rb APP_TOKEN PRIVATE_KEY VIDEO_TOKEN
    =end
    
    require_relative "../lib/Ziggeo"
    
    app_token = ARGV[0]
    private_key = ARGV[1]
    video_token = ARGV[2]
    file_name = ARGV[3]
    
    @ziggeo = Ziggeo.new(app_token, private_key)
    
    # Get video extension and add it to filename
    video_data = @ziggeo.videos.get(video_token)
    file_extension = video_data["original_stream"]["video_type"]
    file_name = file_name + "." + file_extension
    
    # Download video
    video_blob = @ziggeo.videos.download_video(video_token)
    
    # Save video to file
    File.open(file_name, "w") {
      |file|
      file.print video_blob
    }
    
  • download_image
    Download the image data file
    ziggeo.videos().download_image(token_or_key)
    
    This method returns DATA
    Example:
    =begin
      This script shows you how to download a video's covershot.
    
      Parameters you need to pass:
        1. APP_TOKEN
        2. PRIVATE_KEY
        3. VIDEO_TOKEN
    
      Example call:
        ruby videos_download_image.rb APP_TOKEN PRIVATE_KEY VIDEO_TOKEN
    =end
    
    require_relative "../lib/Ziggeo"
    
    app_token = ARGV[0]
    private_key = ARGV[1]
    video_token = ARGV[2]
    file_name = ARGV[3]
    
    @ziggeo = Ziggeo.new(app_token, private_key)
    
    covershot_blob = @ziggeo.videos.download_image(video_token)
    
    File.open("covershot.jpeg", "w") {
      |file|
      file.print covershot_blob
    }
    
  • get_stats
    Get the video's stats
    ziggeo.videos().get_stats(token_or_key)
    
    This method returns JSON
    Example:
    =begin
      This script shows you how to get stats from a single video.
    
      Parameters you need to pass:
        1. APP_TOKEN
        2. PRIVATE_KEY
        3. VIDEO_TOKEN
    
      Example call:
        ruby videos_get_stats.rb APP_TOKEN PRIVATE_KEY VIDEO_TOKEN
    =end
    
    require 'json'
    require_relative "../lib/Ziggeo"
    
    app_token = ARGV[0]
    private_key = ARGV[1]
    video_token = ARGV[2]
    
    @ziggeo = Ziggeo.new(app_token, private_key)
    video_data = @ziggeo.videos.get_stats(video_token)
    
    puts JSON.pretty_generate(video_data)
    
  • push_to_service
    Push a video to a provided push service.
    ziggeo.videos().push_to_service(token_or_key, arguments = nil)
    
    1. pushservicetoken Push Services's token (from the Push Services configured for the app)
    This method returns JSON
    Example:
    =begin
      This script explains how to push an existing video to an auto push service you have previously configured.
    
      Parameters you need to pass:
        1. APP_TOKEN
        2. PRIVATE_KEY
        3. VIDEO_TOKEN
        4. PUSH_SERVICE_TOKEN
    
      Example call:
        ruby videos_count.rb APP_TOKEN PRIVATE_KEY VIDEO_TOKEN PUSH_SERVICE_TOKEN
    =end
    
    require_relative "../lib/Ziggeo"
    
    app_token = ARGV[0]
    private_key = ARGV[1]
    video_token = ARGV[2]
    push_service_token = ARGV[3]
    
    @ziggeo = Ziggeo.new(app_token, private_key)
    
    @ziggeo.videos.push_to_service(
      video_token,
      "pushservicetoken": push_service_token
    )
    
  • apply_effect
    Apply an effect profile to a video.
    ziggeo.videos().apply_effect(token_or_key, arguments = nil)
    
    1. effectprofiletoken Effect Profile token (from the Effect Profiles configured for the app)
    This method returns JSON
    Example:
    =begin
      This script shows you how to apply an effect profile to an existing video.
    
      Parameters you need to pass:
        1. APP_TOKEN
        2. PRIVATE_KEY
        3. VIDEO_TOKEN
        4. EFFECT_PROFILE_TOKEN
    
      Example call:
        ruby videos_apply_effect.rb APP_TOKEN PRIVATE_KEY VIDEO_TOKEN EFFECT_PROFILE_TOKEN
    =end
    
    require_relative "../lib/Ziggeo"
    
    app_token = ARGV[0]
    private_key = ARGV[1]
    video_token = ARGV[2]
    effect_profile_token = ARGV[3]
    
    @ziggeo = Ziggeo.new(app_token, private_key)
    
    result = @ziggeo.videos.apply_effect(
      video_token,
      "effectprofiletoken": effect_profile_token
    )
    
    puts result
    
  • apply_meta
    Apply a meta profile to a video.
    ziggeo.videos().apply_meta(token_or_key, arguments = nil)
    
    1. metaprofiletoken Meta Profile token (from the Meta Profiles configured for the app)
    This method returns JSON
    Example:
    =begin
      This script shows you how to apply a meta profile to an existing video.
    
      Parameters you need to pass:
        1. APP_TOKEN
        2. PRIVATE_KEY
        3. VIDEO_TOKEN
        4. META_PROFILE_TOKEN
    
      Example call:
        ruby videos_apply_meta.rb APP_TOKEN PRIVATE_KEY VIDEO_TOKEN META_PROFILE_TOKEN
    =end
    
    require_relative "../lib/Ziggeo"
    
    app_token = ARGV[0]
    private_key = ARGV[1]
    video_token = ARGV[2]
    meta_profile_token = ARGV[3]
    
    @ziggeo = Ziggeo.new(app_token, private_key)
    
    result = @ziggeo.videos.apply_meta(
      video_token,
      "metaprofiletoken": meta_profile_token
    )
    
    puts result
    
  • update
    Update single video by token or key.
    ziggeo.videos().update(token_or_key, arguments = nil)
    
    1. min_duration Minimal duration of video
    2. max_duration Maximal duration of video
    3. tags Video Tags
    4. key Unique (optional) name of video
    5. volatile Automatically removed this video if it remains empty
    6. expiration_days After how many days will this video be deleted
    7. expire_on On which date will this video be deleted. String in ISO 8601 format: YYYY-MM-DD
    This method returns JSON
    {
    	"volatile":false,
    	"token":"a7edab8c635ec37047d8ae75411528e3",
    	"key":"brandnewname",
    	"state":5,
    	"max_duration":"10",
    	"duration":1,
    	"tags":null,
    	"submission_date":1390257799,
    	"resubmission_date":1390257799,
    	"stream_submission_date":1390257799,
    	"delete_old_streams":true,
    	"type":"ApiVideo",
    	"created":1390257798,
    	"owned":false,
    	"state_string":"READY",
    	"streams":[
    	{
    		"volatile":false,
    		"token":"d751140b4e1cf0a243f32092f6110296",
    		"key":null,
    		"creation_type":5,
    		"state":5,
    		"streamable":2,
    		"video_type":"mp4",
    		"video_sub_type":"other",
    		"image_size":0,
    		"video_size":36078,
    		"video_width":640,
    		"video_height":360,
    		"duration":1,
    		"has_video":true,
    		"has_image":true,
    		"submission_date":1390257799,
    		"type":"ApiVideoStream",
    		"created":1390257799,
    		"owned":true,
    		"creation_type_string":"SERVER_UPLOAD",
    		"streamable_string":"DEGRADED",
    		"state_string":"READY"
    	}],
    	"original_stream":
    	{
    		"volatile":false,
    		"token":"d751140b4e1cf0a243f32092f6110296",
    		"key":null,
    		"creation_type":5,
    		"state":5,
    		"streamable":2,
    		"video_type":"mp4",
    		"video_sub_type":"other",
    		"image_size":0,
    		"video_size":36078,
    		"video_width":640,
    		"video_height":360,
    		"duration":1,
    		"has_video":true,
    		"has_image":true,
    		"submission_date":1390257799,
    		"type":"ApiVideoStream",
    		"created":1390257799,
    		"owned":true,
    		"creation_type_string":"SERVER_UPLOAD",
    		"streamable_string":"DEGRADED",
    		"state_string":"READY"
    	},
    	"default_stream":
    	{
    		"volatile":false,
    		"token":"d751140b4e1cf0a243f32092f6110296",
    		"key":null,
    		"creation_type":5,
    		"state":5,
    		"streamable":2,
    		"video_type":"mp4",
    		"video_sub_type":"other",
    		"image_size":0,
    		"video_size":36078,
    		"video_width":640,
    		"video_height":360,
    		"duration":1,
    		"has_video":true,
    		"has_image":true,
    		"submission_date":1390257799,
    		"type":"ApiVideoStream",
    		"created":1390257799,
    		"owned":true,
    		"creation_type_string":"SERVER_UPLOAD",
    		"streamable_string":"DEGRADED",
    		"state_string":"READY"
    	}}
    
    Example:
    =begin
      This script will show you how to update information from an existing video.
    
      Parameters you need to pass:
        1. APP_TOKEN
        2. PRIVATE_KEY
        3. VIDEO_TOKEN
    
      Example call:
        ruby videos_update.rb APP_TOKEN PRIVATE_KEY VIDEO_TOKEN
    =end
    
    require_relative "../lib/Ziggeo"
    
    app_token = ARGV[0]
    private_key = ARGV[1]
    video_token = ARGV[2]
    
    @ziggeo = Ziggeo.new(app_token, private_key)
    
    result = @ziggeo.videos.update(
      video_token,
      "tags": "updated_with_sdk, ruby"
    )
    
    puts result
    
  • update_bulk
    Update multiple videos by token or key.
    ziggeo.videos().update_bulk(arguments = nil)
    
    1. tokens_or_keys Comma-separated list with the desired videos tokens or keys (Limit: 100 tokens or keys).
    2. min_duration Minimal duration of video
    3. max_duration Maximal duration of video
    4. tags Video Tags
    5. volatile Automatically removed this video if it remains empty
    6. expiration_days After how many days will this video be deleted
    7. expire_on On which date will this video be deleted. String in ISO 8601 format: YYYY-MM-DD
    This method returns JSON
    Example:
    =begin
      This script shows you how to update more than one video at once.
    
      Parameters you need to pass:
        1. APP_TOKEN
        2. PRIVATE_KEY
        3. VIDEO_TOKENS
    
      Example call:
        ruby videos_update_bulk.rb APP_TOKEN PRIVATE_KEY VIDEO_TOKEN1 VIDEO_TOKEN2 ... VIDEO_TOKENn
    =end
    
    require_relative "../lib/Ziggeo"
    
    app_token, private_key = ARGV.shift(2)
    video_tokens = ARGV.join(",")
    
    puts "Comma-separated list of tokens/keys: " + "\"" + video_tokens + "\""
    
    @ziggeo = Ziggeo.new(app_token, private_key)
    
    result = @ziggeo.videos.update_bulk(
      tokens_or_keys: video_tokens,
      tags: "bulk_updated_with_sdk, ruby"
    )
    
    puts result
    
  • delete
    Delete a single video by token or key.
    ziggeo.videos().delete(token_or_key)
    
    Example:
    =begin
      This script shows you how to delete a single video.
    
      Parameters you need to pass:
        1. APP_TOKEN
        2. PRIVATE_KEY
        3. VIDEO_TOKEN
    
      Example call:
        ruby videos_delete.rb APP_TOKEN PRIVATE_KEY VIDEO_TOKEN
    =end
    
    require_relative "../lib/Ziggeo"
    
    app_token = ARGV[0]
    private_key = ARGV[1]
    video_token = ARGV[2]
    
    @ziggeo = Ziggeo.new(app_token, private_key)
    @ziggeo.videos.delete(video_token)
    
  • create
    Create a new video.
    ziggeo.videos().create(arguments = nil, file = nil)
    
    1. file Video file to be uploaded
    2. min_duration Minimal duration of video
    3. max_duration Maximal duration of video
    4. tags Video Tags
    5. key Unique (optional) name of video
    6. volatile Automatically removed this video if it remains empty
    This method returns JSON
    {
    	"volatile":true,
    	"token":"a7edab8c635ec37047d8ae75411528e3",
    	"key":null,
    	"state":3,
    	"max_duration":null,
    	"duration":null,
    	"tags":null,
    	"submission_date":null,
    	"resubmission_date":null,
    	"stream_submission_date":null,
    	"delete_old_streams":true,
    	"type":"ApiVideo",
    	"created":1390257798,
    	"owned":false,
    	"state_string":"EMPTY",
    	"streams":[],
    	"original_stream":null,
    	"default_stream":null
    }
    
    Example:
    =begin
      This script shows you how to upload a video.
    
      Parameters you need to pass:
        1. APP_TOKEN
        2. PRIVATE_KEY
        3. FILE
    
      Example call:
        ruby videos_create.rb APP_TOKEN PRIVATE_KEY FILE
    =end
    
    require_relative "../lib/Ziggeo"
    
    puts Ziggeo.new(ARGV[0], ARGV[1]).videos.create(nil, ARGV[2])
    
  • analytics
    Get analytics for a specific videos with the given params
    ziggeo.videos().analytics(token_or_key, arguments = nil)
    
    1. from A UNIX timestamp in microseconds used as the start date of the query
    2. to A UNIX timestamp in microseconds used as the end date of the query
    3. date A UNIX timestamp in microseconds to retrieve data from a single date. If set, it overwrites the from and to params.
    4. query The query you want to run. It can be one of the following: device_views_by_os, device_views_by_date, total_plays_by_country, full_plays_by_country, total_plays_by_hour, full_plays_by_hour, total_plays_by_browser, full_plays_by_browser
    This method returns JSON