Files - Search For Files

This guide explains how to search for assets in EnterMediaDB using:

  • JSON REST API
  • EnterMediaDB API UI

Both methods perform the same operation.


1. Overview

The search API allows you to:

  • Search for assets in EnterMediaDB
  • Filter results using query conditions
  • Retrieve paginated results

Search results are filtered based on the permissions of the logged-in user.


2. API Endpoint

The API endpoint is the URL used to search for assets via the REST API.

POST /assets/mediadb/services/module/asset/search

This endpoint processes a search request and returns matching assets.


3. Required Parameters

The following parameters are commonly used when searching for assets:

  • page: Page number of results to return
  • hitsperpage: Number of results per page
  • query: Search criteria used to filter results

These values tell the API which results to return and how to filter them.


4. Search for Files Using JSON REST API

Step 1: Prepare your request
{
  "page": "1",
  "hitsperpage": "20",
  "query": {
    "terms": [
      {
        "field": "id",
        "operator": "matches",
        "value": "*"
      }
    ]
  }
}
 

Step 2: Send the request
curl -H "Content-Type: application/json" \
-X POST http://entermediadb.org/openinstitute/mediadb/services/module/asset/search \
-b "entermedia.key=YOUR_SESSION_KEY" \
-d '{
  "page": "1",
  "hitsperpage": "20",
  "query": {
    "terms": [
      {
        "field": "id",
        "operator": "matches",
        "value": "*"
      }
    ]
  }
}' | python -m json.tool
 

Notes
  • Replace YOUR_SESSION_KEY with your entermedia.key
  • Ensure your API session is initialized (see Authentication section)
  • Requests must use JSON format
  • Results are returned in JSON format

5. Search for Files Using EnterMediaDB API UI

You can search for assets directly using the EnterMediaDB API interface.

Steps
  1. Open the EnterMediaDB API UI

    Example:
    https://emedialibrary.org/mediadb

  2. In the left sidebar, navigate to:
    Files → Search for Files

  3. In the Request editor, enter:
{
  "page": "1",
  "hitsperpage": "20",
  "query": {
    "terms": [
      {
        "field": "id",
        "operator": "matches",
        "value": "*"
      }
    ]
  }
}
 
  1. Click Execute

6. Get Asset by ID

You can retrieve a specific asset using its ID using the JSON REST API.

Example Request
curl -X GET \
-b "entermedia.key=YOUR_SESSION_KEY" \
"http://entermediadb.org/openinstitute/mediadb/services/module/asset/data/ASSET_ID" \
| python -m json.tool
 

Notes
  • Replace ASSET_ID with the actual asset ID
  • This request returns detailed information about a single asset

7. Response

A successful search request returns:

  • JSON results containing matching assets

Example (simplified):

{
  "response": {
    "status": "ok"
  },
  "results": [
    {
      "id": "AVVKhPmnX6umoHWGYgtH",
      "name": "example.jpg"
    }
  ]
}
 

8. What Happens After Search

After a successful search:

  • Matching assets are returned
  • Results can be paginated
  • Each asset can be:
    • viewed
    • downloaded
    • converted
    • updated

9. Troubleshooting

1. No results returned
  • Check query conditions
  • Ensure assets exist
  • Verify user permissions

2. Unauthorized request
  • Ensure entermedia.key is included
  • Ensure session is initialized
  • Verify API permissions are enabled

3. Invalid JSON request
  • Check JSON formatting
  • Ensure required fields are included