EnterMediaDB JSON API

The REST JSON API is a comprehensive collection of programming API that can be used to remotely manage your media database.  There are currently over 90 separate API used to create, search, update and delete from any database table within EnterMedia.

Authentication

To get started with calling the API you will need to have a valid login. Please use the MediaDB tool /mediadb/

The user and password that are used should have permissions enabled using the EMShare Permissions select the Users role and choose JSON API view. Turn on all the available permissions or just read only options.

The first API you will need to call will load up the entermedia.key Cookie into the clients HTTP session that does not expire. This will allow auto login for subsequent API requests so that you will not need to worry about being disconnected and having to login again. As long as the entermedia.key cookie is saved the client with log in automatically.

Entermedia-API-UserLogin-Annotated

Calling The API

Assets and Asset Media are the main API that most users will need. When you search for assets or upload assets the results will be filtered by the permissions for that user.

The MediaDB tool has three parts:

1. Select the section you are interested in such as Asset Search
2. The URL should be of HTTP type POST, UPDATE, DELETE or GET
3. The request should be JSON syntax and the results will normally come back as JSON results or a JSON error message
4. Example curl command to search for assets:

curl -H "Content-Type: application/json" -X POST http://em9dev.entermediadb.org/openinstitute/mediadb/services/module/asset/search -b 'entermedia.key=adminmd5421c0af185908a6c0c40d50fd5e3f16760d5580bc' -d '{
 "page": "1",
 "hitsperpage": "20",
 "query": {
  "terms": [{
   "field": "id",
   "operator": "matches",
   "value": "*"
 }]
 }
}'| python -mjson.tool
curl -X GET -b 'entermedia.key=adminmd5421c0af185908a6c0c40d50fd5e3f16760d5580bc'  'http://em9dev.entermediadb.org/openinstitute/mediadb/services/module/asset/data/AVVKhPmnX6umoHWGYgtH' | python -mjson.tool
Module API

Each time you create a new module the system will automatically define the end points and add that module CRUD operations to the MediaDB API. To reload existing modules you may need to click on the “Load Modules” link at the top left side of the MediaDB tool. This only has to be done once after upgrading EnterMedia.

Creating your custom API

A trained EnterMedia developer can create their own Custom API can be added to the list of API.

  1. Creating your own configurations such as /mediadb/services/mystuff/hello.xconf file
  2. Define the path-action that will be called. To define your own objects copy this file: /WEB-INF/base/mediadb/src/plugin.xml to /WEB-INF/base/mystuffapp/src/plugin.xml
  3. Restart the tomcat web server since mediadb objects are cached.
  4. Use the DataManager to add your API to the database tables called docsection and endpoint