API Extensions

The Emby MediaBrowser provides an extensible API system that gives external developers the ability to integrate external applications with Emby.  (ScripterX version

For example, you can call the API to get more information about a Media item, you can use the API to create a user, delete a user, etcetera.

Now - ScripterX Packages can implement their own API functions, which gives the power to a package developer to provide API endpoints to external developers (or themselves if they wish to integrate external software with their package).

How does it work?

By now you should be familiar with the ScripterX Package subscription functions, namely _package_init().  This is where we will put our API function registration.

What's the syntax?  It is elegant and simple.

ScripterX.Api.Register("Method", "Function", "CallbackFunction");

So what are the parameters, what do they mean?

"Method" should be replaced with one of the supported Http Methods.  The following are supported in ScripterX's API Extensions:


"Function" is the function parameter of the API endpoint.  For example, a package with the installationId 8b91c4d0-66f2-47c8-9471-ae9c741d6b6f  will have an API endpoint in the format:


so "Function" in the example above is function_here.

And lastly, "CallbackFunction" is where you define the string-value of the function in your Package.js you wish to have called when somebody (or something) opens the API url.  

Lets take a look at a real-life example.

In my _package_init() I have an API registration call:

ScripterX.Api.Register("POST", "testapipost", "api_test_post");

This tells ScripterX to register an API function called testapipost, and only take effect if the POST method is used to open the API url.

And somewhere in my Package.js I have the callback function defined called api_test_post, which looks like this (take note of the callback function arguments):

function api_test_post(content_type, method, data)
	var response = {};
	response.id = "01";
	response.Text = "This is a test!";
	ScripterX.Log.Info("API Test Post called, content_type = " + content_type + " data = " + data);

Very cool new feature, which is currently in beta stages so please report any issues you find to our GitHub issues page.