Spaces:
Running
Running
File size: 3,219 Bytes
e83acd1 979b1d2 e83acd1 3cc985e 979b1d2 3cc985e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | # MalwareGuard Partner API
Use this API when another project needs a simple malware verdict for a URL or
Windows PE file.
## Deployments
- Frontend on Vercel: `https://malwareguard-one.vercel.app`
- Backend on Hugging Face Space: `https://heshamxor-malwareguard.hf.space`
- Recommended public API base URL through Vercel: `https://malwareguard-one.vercel.app/api/partner`
- Direct backend API base URL: `https://heshamxor-malwareguard.hf.space/api/partner`
The Vercel app rewrites `/api/*` requests to the Hugging Face backend, so partner
projects can use the Vercel base URL and avoid browser CORS issues.
## Authentication
Production deployments should set:
```env
PARTNER_API_KEYS=shared-secret-key
```
Partners must send the key in every request:
```http
X-API-Key: shared-secret-key
```
If partners call the API directly from a browser frontend, add their deployed
frontend origin to the backend `CORS_ORIGINS` environment variable.
If multiple groups need access, set comma-separated keys:
```env
PARTNER_API_KEYS=group-a-key,group-b-key
```
## Health
```bash
curl https://malwareguard-one.vercel.app/api/partner/health \
-H "X-API-Key: shared-secret-key"
```
## Analyze a URL
```bash
curl -X POST https://malwareguard-one.vercel.app/api/partner/analyze-url \
-H "Content-Type: application/json" \
-H "X-API-Key: shared-secret-key" \
-d '{"url":"https://example.com/login"}'
```
Response:
```json
{
"analysis_type": "url",
"target": "https://example.com/login",
"verdict": "Malicious",
"is_malicious": true,
"malicious_score": 0.84,
"confidence_level": "High",
"threshold_used": 0.5,
"source": "malwareguard-url-hypermodel",
"details": {
"base_model_scores": {},
"top_signals": {}
}
}
```
## Analyze a File
Only Windows PE files are supported, such as `.exe`, `.dll`, and `.sys`.
Maximum file size is 200 MB for partner API keys.
```bash
curl -X POST https://malwareguard-one.vercel.app/api/partner/analyze-file \
-H "X-API-Key: shared-secret-key" \
-F "file=@sample.exe"
```
Response:
```json
{
"analysis_type": "file",
"target": "sample.exe",
"verdict": "Malicious",
"is_malicious": true,
"malicious_score": 0.91,
"confidence_level": "High",
"threshold_used": 0.5,
"source": "malwareguard-ember-xgboost",
"sha256": "file_sha256_hash",
"file_size": 123456,
"feature_count": 2381,
"inference_time_ms": 3.2,
"details": {}
}
```
## Analyze a Generic File (CSV, MP4)
Supported generic files include `.csv`, `.tsv`, `.mp4`, `.m4v`, `.mov`.
Maximum file size is 200 MB for partner API keys.
```bash
curl -X POST https://malwareguard-one.vercel.app/api/partner/analyze-generic \
-H "X-API-Key: shared-secret-key" \
-F "file=@data.csv"
```
Response:
```json
{
"analysis_type": "file",
"target": "data.csv",
"verdict": "Malicious",
"is_malicious": true,
"malicious_score": 0.99,
"confidence_level": "High",
"threshold_used": 0.5,
"source": "malwareguard-csv-xgboost",
"sha256": "file_sha256_hash",
"file_size": 1234,
"details": {
"threats": [
{
"type": "Formula Injection",
"severity": "Critical",
"description": "Found DDE injection payload"
}
]
}
}
```
|