3.4 File Badge
Request |
Value |
Method |
GET |
URL |
https://api.metadefender.com/v4/hash/:hash/badge?size&type |
Summary
API for retrieving scan result images, called "badges", which reflect the scan result status of a particular hash. If the hash was scanned by MetaDefender Cloud and there was no threat detected, the "No threat detected" badge will be returned (see a preview below in the "Response" "Body" section). If the hash was detected as infected, the "Threat detected" badge will be returned. If the hash was never scanned by MetaDefender Cloud, the "No information available" badge is displayed.
The point of these badges is to integrate them into your website or application in order to increase the confidence of files provided. For example, a website that offers a software installer package will show this badge with the scan results of the installer saying (ideally) that the file is clean. Here is an HTML sample code showing the recommended way of integrating this functionality:
<
a
href="
https://metadefender.opswat.com/results
#!/file/<:your hash>/hash/overview" target="_blank" rel="noopener">
<
img
src="
https://api.metadefender.com/v4/hash/
<:your hash>/badge?size=medium&type=svg"/>
</
a
>
Obtaining the badge is straightforward, just compose the URL with the hash of the file, and specify badge type (size and image format). In order for the site visitors to be able to get more information about the scan results of the file, insert the image into an <a> link tag which will open the scan results page on our website.
The "small" badge size can be used in markdown readme files from code repositories.
Request
URL Parameters
|
Description |
Allowed Values |
Required |
size |
Select the image size. Default: small |
small | medium |
NO |
type |
Select image type. Default: svg |
svg | png | jpg |
NO |
Response
HTTP Status Codes
Please refer to Status Codes for more information.
Body
"No threat detected" badge (small and medium):
"Threat detected" badge (small and medium):
"No information available" badge (small and medium):
Example of a failed request:
{
"error"
: {
"code"
:
400064
,
"messages"
: [
"The hash value is not valid"
]
}
}
Errors
Please refer to Errors for more information.
Sample code (Node.js)
var
http = require(
"https"
);
var
options = {
"method"
:
"GET"
,
"hostname"
: [
"api"
,
"metadefender"
,
"com"
],
"path"
: [
"v4"
,
"hash"
,
"6A5C19D9FFE8804586E8F4C0DFCC66DE"
,
"badge"
]
};
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.end();
Sample code (cURL)
curl -X GET \
'https://api.metadefender.com/v4/hash/6A5C19D9FFE8804586E8F4C0DFCC66DE/badge?size=medium&type=svg'
\