Security Headers Check API
Grade a website’s HTTP security from A+ to F: HTTPS redirect, HSTS (preload), Content-Security-Policy, framing, cookies, CORS, mixed content and version leaks.
The security headers API fetches a URL and reviews the protections browsers apply from its response: an HTTPS redirect from http://, Strict-Transport-Security (max-age, includeSubDomains and whether the site is eligible for the HSTS preload list), Content-Security-Policy (flagging unsafe-inline without nonces, unsafe-eval and wildcard script sources), clickjacking protection with X-Frame-Options or frame-ancestors, X-Content-Type-Options, Referrer-Policy, Permissions-Policy and the cross-origin isolation headers.
It also checks the flags of the cookies the page sets (Secure, HttpOnly, SameSite), dangerous CORS combinations (* with credentials), resources loaded over http:// on an https page (mixed content) and headers that reveal software versions. Each finding is a check with a status and a message in English or Vietnamese (lang=vi); the score and grade (A+ when nothing is left to improve) summarise them.
The parsed HSTS and CSP directives, the cookies and all response headers are returned for your own rules. Results are cached for 10 minutes (fresh=true to re-check).
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
url | body|query | string | yes | Page URL. | |
lang | body|query | string | no | en | Language of the messages: en or vi. |
fresh | body|query | boolean | no | false | Bypass the 10-minute cache. |
Example
curl "https://apibox.io.vn/v1/security-headers?url=https://github.com/" \
-H "Authorization: Bearer YOUR_API_KEY"const res = await fetch('https://apibox.io.vn/v1/security-headers?url=https://github.com/', {
method: 'GET',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
},
});
const data = await res.json();
console.log(data);import requests
res = requests.get(
"https://apibox.io.vn/v1/security-headers?url=https://github.com/",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/security-headers?url=https://github.com/');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"url": "https://github.com/",
"final_url": "https://github.com/",
"status": 200,
"score": 100,
"grade": "A+",
"summary": {
"passed": 8,
"info": 1,
"warnings": 0,
"errors": 0
},
"hsts": {
"max_age": 31536000,
"include_subdomains": true,
"preload": true,
"preload_eligible": true
},
"csp": {
"default-src": "'none'",
"frame-ancestors": "'none'",
"…": "…"
},
"checks": [
{
"id": "http_redirect",
"status": "pass",
"message": "http:// redirects to https://"
},
{
"id": "hsts",
"status": "pass",
"message": "HSTS max-age 365 days, includeSubDomains, preload",
"value": "max-age=31536000; includeSubdomains; preload"
},
{
"id": "csp",
"status": "pass",
"message": "Content-Security-Policy restricts scripts",
"value": "…"
},
"…"
]
}
Use cases
- Security checklists before launching a website
- Monitor client sites in agencies and MSPs
- Security scoring in website builders and hosting panels
- Teach web security with concrete feedback
FAQ
What does A+ mean?
A score of 90 or more with no warning or failure left: HTTPS with redirect, a long HSTS, a script-restricting CSP, framing protection, nosniff and a Referrer-Policy.
Is unsafe-inline always bad?
For scripts it disables most of the XSS protection of CSP, unless nonces or hashes are used (then browsers ignore it). For styles the risk is lower and it is not penalised.
Does it scan for vulnerabilities?
No. It only reads one response like a browser does; it does not probe the site.
Related APIs
Hash Generator
Compute MD5, SHA-1, SHA-256, SHA-384, SHA-512 and CRC32 of text or files in one call, as hex or base64, with optional HMAC signing.
B64Encode / Decode
Encode or decode text as Base64, Base64URL, hex, URL encoding, HTML entities, Unicode escapes, ROT13 or binary with one simple API call.
***Password Generator
Generate cryptographically secure random passwords (4–256 chars, up to 100 at once) or check a password’s strength, entropy and estimated crack time.