3.2 Retrieving scan reports for multiple data hashes

Request

Value

Method

POST

URL

https://api.metadefender.com/v2/hash

Throttled

Yes

Summary

Bulk lookup of scan results based on MD5, SHA1, or SHA256.

Request

Header Parameters

 

Description

Allowed Values

Required

apikey

Give rights to use the endpoint (API Authentication Mechanisms)

<your apikey>

YES

include_scan_details

Include scan details.

Default value: 0

0 - get only hashes

1 - get hash details also

NO

Body (payload)

The maximum number of hashes to be retrieved in 1 request is 1000.

 

Format

Required

Example

HTTP Body

json

YES

{
"hash": ["3CF81C30D780631294CF9576EF6B6A7E", "34BB9CCC946E76B162E97983BAA4FD29"]
}

Response

HTTP Status Codes

Please refer to Status Codes for more information.

Body

Example of successful scan request:

[
{
"hash":hash_value_1,
"scan_result_i":0,
"data_id":data_id_1
},
{
"hash":hash_value_2,
"scan_result_i":1,
"data_id":data_id_2
},
{
"hash":hash_value_3,
"scan_result":5,
"scan_result_i":5,
"data_id":null
}
]

A "scan_result_i" value of "5" means the hash is not found, or it is invalid.

Example of successful scan request:

include_scan_details = 1

[
{
"data_id": "ZDE3MTAxNUJ5Zkx2X0NnVFpyMVFMdmRSZ1RX",
"scan_result_i": 0,
"hash": "8F7920DA1D52B06A61D7A41C51D595AC",
"scan_details": {
"Lavasoft": {
"scan_time": 10609,
"def_time": "2017-10-15T00:00:00.000Z",
"scan_result_i": 0,
"threat_found": ""
},
...
}
},
...
]

Example of input body being empty:

{
"err" : "hashes in body content is null or empty"
}

Example of maximum hashes input:

{
"err" : "Exceeded maximum allowed. Allow maximum 1000 hashes"
}

Example of input body in the wrong format:

{
"err" : "Could not parse body content."
}

Descriptions of response:

scan_result

The newest final scan result of hash.

data_id

The newest data_id of hash.

Errors

Please refer to Errors for more information.

Sample code (Node.js)

var http = require("https");
 
var options = {
"method": "POST",
"hostname": "api.metadefender.com",
"path": "/v2/hash/",
"headers": {
"apikey": process.env.APIKEY,
"content-type": "application/json"
}
};
 
var req = http.request(options, function (res) {
var chunks = [];
 
res.on("data", function (chunk) {
chunks.push(chunk);
});
 
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
 
req.write(JSON.stringify({ hash:
[ '76D5D80B5CA3EED75031EBEE8AF2765C',
'196693DCABDAE6E066A804CCA774182B' ] }));
req.end();

Sample code (cURL)

curl -X POST \
https://api.metadefender.com/v2/hash \
-H 'apikey: ${APIKEY}' \
-H 'x-include-scan-details: 1' \
-d '{"hash": ["76D5D80B5CA3EED75031EBEE8AF2765C", "196693DCABDAE6E066A804CCA774182B"]}'