Developer Guide


This is the API documentation for MetaDefender Core Public API. If you would like to evaluate or have any questions about this documentation, please contact us via our Contact Us form.


How to Interact with MetaDefender Core using REST

Beginning with MetaDefender Core 4.x, OPSWAT recommends using the JSON-based REST API. The available methods are documented below.

Note: MetaDefender API doesn't support chunk upload, however is recommended to stream the files to MetaDefender Core as part of the upload process.


File Analysis Process

MetaDefender's main functionality is to analyze large volumes with a high throughput. Depending on the configuration and licensed technologies, the analysis times can vary. Below is a brief description of the API integration flow:

  1. Upload a file for analysis (POST /file), which returns the data_id: File Analysis).

    Note: The performance depends on:

    • number of engines
    • type of file to be scanned
    • MetaDefender Core's hardware
  1. You have 2 ways to retrieve the analysis report:

    • Polling: Fetch the result with previously received data_id (GET /file/{data_id} resource) until scan result belonging to data_id doesn't reach the 100 percent progress_percentage: (Fetch analysis result)

    Note: Too many data_id requests can reduce performance. It is enough to just check every few hundred milliseconds.

    • Callbackurl: Specify a callbackurl that will be called once the analysis is complete.
  2. Retrieve the analysis results anytime after the analysis is completed with hash for files (md5, sha1, sha256, sha512) by calling Fetch analysis result by hash.

    • The hash can be found in the scan results
  3. Retrieve processed file (sanitized, redacted, watermarked, etc.) after the analysis is complete.

    Note: Based on the configured retention policy, the files might be available for retrieval at a later time.


OPSWAT provides some sample codes on GitHub to make it easier to understand how the MetaDefender REST API works.

Server
http://localhost:8008
Server Variables
apiKey apikey

Generated session_id from Login call can be used as an apikey for API calls that require authentication.

Fields
KeyIn
apikeyHeader

Auth

Authentication APIs

User authentication is done via username & password. Additional integrations are available within the product:

  • LDAP integration
  • Active Directory integration
  • SAML integration (starting with v4.18.0)

Login

Initiate a new session. Required for using protected REST APIs.

Auth
Request Body
objectobject
userstring

Username

passwordstring

User's password

POST /login
Copy
Responses
200

OK

objectobject
oms-csrf-tokenstring

The randomly generated token used to prevent CSRF attacks

session_idstring

The apikey used to make API calls which requires authentication

403

Invalid credentials

500

Unexpected event on server

Response
Copy

Logout

Destroy session for not using protected REST APIs.

Auth
Headers
apikeystring

Generated session_id from Login call can be used as an apikey for API calls that require authentication.

POST /logout
Copy
Responses
200

OK

objectobject
responsestring
400

Bad Request.

403

Invalid user information.

500

Unexpected event on server

Response
Copy

Change Password

Modify the current password for the user identified by apikey

Auth
Headers
apikeystring

Generated session_id from Login call can be used as an apikey for API calls that require authentication.

Request Body
objectobject
old_passwordstring

The current password in plain text

new_passwordstring

The new password in plain text

POST /user/changepassword
Copy
Responses
200

Request processed successfully

objectobject
successboolean
400

Bad Request (e.g. invalid header, apikey is missing or invalid).

405

The user has no rights for this operation.

500

Unexpected event on server

Response
Copy