SafeShare.TV API (Legacy)

Generate safe links from your site or App!

With a simple HTTP call, you can generate SafeShare links from your own site or application. The API is straightforward and dead simple. This document describes how to do it.

The easiest way to generate a safe link is to call a url. Go ahead and click the link:

http://safeshare.tv/api/generate?yt_id=jNQXAC9IVRw

If you are looking for more control, check out the inputs and outputs in below table:

Input parameters (query strings)

Parameter Description Validation
yt_id (required) YouTube id. If the YouTube URL is http://www.youtube.com/watch?v=jNQXAC9IVRw, the yt_id would be jNQXAC9IVRw Max 25 characters, Valid YouTube ID
title Pass this parameter if you want to override the default video title Max 100 characters
b Define where the video should start playing in seconds, should be somewhere within total video length
e Define where the video should stop playing in seconds, should be somewhere within total video length. Shouldn't be smaller than b
theme Override the default black theme Any number from 1 to 99. (You can pick from the current available themes: 0,1,2,3,5 or 6)
sbe Show or hide sharing button. Default is 1 0 or 1

Response will be in JSON format. You want to build the right logic based on the code returned.

In case of successful response, you would get:

{"code":0, "desc":"success", "data":{"title":"[The title of the video]",
  "duration":"[The total duration of the video]",
  "safe_share_id":"[The ID of the safe link]",
  "thumbnail":"[One JPG image of video]",
  "theme":[Theme number or false if not set]} }

In case of error response, you would get:

{"code":[Error code],"desc":"[Error description]"}

Let's examine what kind of codes you might get other than 0

code desc Hint
1 Youtube id required. yt_id is the only mandatory parameter. You have to pass a YouTube ID
2 Theme should be within range 1-99. If you decide to change the video theme, ensure the value of theme is between 1 and 99
3 Youtube id too long! Maximum 25 There should not be a YouTube ID longer than 25 characters
4 Title too long! Maximum 100 If you want to override the default title, ensure title parameter is less than 100 character
5 b and e should be in mm:ss format If not set in the mentioned format, b or e will not be accepted
6 Error getting youtube video data. Check youtube id or try again. This error can occur if you pass wrong YouTube ID
7 Ending should be larger than Beggining. If b is set, e obviously cannot be set to an earlier position in the video
8 Beggining and Ending should fall within the total video duration. You will get this error if b or e set is actually larger than the total video length
9 Could not generate video.. This error occur if other internal error occurs while generating the safe link. You can try again.
10 The owner of this YouTube video restricted viewing it on other sites Safe link cannot be generated if the user restricted embedding his/her video on other sites
11 Maximum video length currently supported is 100 minutes! This is a current limitation. Safe links can only be generated for videos less or equal to 100 minutes
12 SBE should be 1 or 0 SBE is 1 by default, set it to 0 if you want to hide the sharing button

We have created a sandbox for you to have a little fun with the API and to give you a sample code to kick start your project ! http://www.safeshare.tv/api/sandbox