API JavaScript documentation

Getting Started

We offer a JavaScript helper library as an example of how to access and consume the API REST service from a JavaScript application. The library wraps the encryption resp. decryption process and the handling of the low level API. The deftlr.com page utilizes the same low level API, so every entry created using the library is instantly accessible from the website and vice versa (including entries created with libraries for another programming language). The JavaScript library is a module that should be instanciated with a constructor call, that accepts three parameters:

// your API key
var clientVerificationToken = 'ABC123XYZ';
	
// the API (custom) base url
var url = 'https://deftlr.com/api/';
	
// the secret to use for all requests using the current object
var token = 'secret';
	
var deftlrCryptoLibrary = new DeftlrCryptoLibrary(clientVerificationToken, url, token);
						

Currently four methods are available, all with the same signature (with one small exception):

  • searchTag(tag, doneCallback, failCallback) check if the specified tag exists
  • readMessage(tag, doneCallback, failCallback) retrieve the decrypted content for the specified tag
  • createMessage(tag, message, doneCallback, failCallback) create new entry for the specified tag
  • deleteMessage(tag, doneCallback, failCallback) delete the entry for the specified tag

Search for a specified tag and handle the result example:

deftlrCryptoLibrary.searchTag('hello', 
	// doneCallback handler
	function(result, error) {
		if (!error) {
			console.log(result);
		} else {
			console.log(error);
		}
	}, 
	// failCallback handler
	function (generalError) {
		console.log(generalError);
	});
					

Download the JavaScript DeftlrCryptoLibrary here.

We are currently working on:

  • listTags find all tags belonging to the specified master tag
  • readFile retrieve an entry containing file info and offer the file to the user
  • createFile create an entry from a file content

Find out more about the API here: API documentation