Initializing the JavaScript Library

Include this script anywhere on your HTML page:
We recommend you defer it towards the end of the document before the </body> closing tag.

<script type="text/javascript" src="http://binbox.io/api.js"></script>
<script type="text/javascript">
var BB = new Binbox.API("http://binbox.io/");
</script>

API Methods


Shrinking a Link

BB.create({
	title: "Untitled",
	url: "http://exampledomain.com/demo"
}, callback);

Parameters

  • options
    • title
      • A plaintext string, used in the dashboard as well as for display. Titles are not encrypted and limited to 40 characters. Defaults to "Untitled" when null or not set.
    • url
      • The URL to be shortened
    • folder (optional)
      • Specify id of the folder where this link should be stored.
      • Default is primary folder (0). A JSON-encoded list of your folders can be found here: https://binbox.io/history/folders
  • callback
    • This function will be called whether success or error.

Example

var BB = new Binbox.API("http://binbox.io/");
BB.create({
	title: "Untitled",
	text: "Hello world!",
}, function(result)
{
	console.log(result);
	
	if(result.ok)
	{
		console.log(result.id, result.salt);
	}
	else
	{
		console.log(result.error);
	}
});

Creating a Paste

BB.create({
	title: "Untitled",
	text: "Hello world!"
}, callback);

Parameters

  • options
    • title
      • A plaintext string, used in the dashboard as well as for display. Titles are not encrypted and limited to 40 characters. Defaults to "Untitled" when null or not set.
    • text
      • This string will be encrypted client-side and decrypted with a hash salt.
    • folder (optional)
      • Specify id of the folder where this link should be stored.
      • Default is primary folder (0). A JSON-encoded list of your folders can be found here: https://binbox.io/history/folders
  • callback
    • This function will be called whether success or error.

Example

var BB = new Binbox.API("http://binbox.io/");
BB.create({
	title: "Untitled",
	text: "Hello world!",
}, function(result)
{
	console.log(result);
	
	if(result.ok)
	{
		console.log(result.id, result.salt);
	}
	else
	{
		console.log(result.error);
	}
});

Retrieving a Paste

BB.retrieve('paste_id', function(paste) { });
BB.retrieve('paste_id#password', function(paste, text) { });

Parameters

  • Paste ID (string)
  • Callback (function)

Example

var BB = new Binbox.API("http://binbox.io/");
var password = "unlock_key";
BB.retrieve('paste_id', function(result)
{
	if(!result.ok)
	{
		return;
	}
	
	var text = result.decrypt(password);
	console.log(text);
});	

BB.retrieve('paste_id#'+password, function(result, text)
{
	console.log(text);
});
		

Encrypting a Paste

BB.encrypt(text, salt);

Parameters

  • text (string) The text to be encrypted
  • salt (string) - The hash #password to use to unlock the paste. A-Z/a-z/0-9 only.

Example

var BB = new Binbox.API("http://binbox.io/");
var password = "unlock_key";
var text = "Hello world!";
var data = BB.encrypt(text, password);

console.log("Result", data);